From b93130df4f1a96061399cd5ea76efba0fe047702 Mon Sep 17 00:00:00 2001 From: Michael Solati Date: Wed, 2 Mar 2022 13:04:05 -0800 Subject: [PATCH] fix(usage): add `chrome` namespace to `Window` and add usage directions, fixes #17 --- .gitignore | 1 + dist/README.md | 23 +++++++++++++++++++++++ dist/global.d.ts | 8 ++++++++ dist/package.template.json | 7 ++++++- 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 dist/global.d.ts diff --git a/.gitignore b/.gitignore index 71e830e..7828615 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ chrome-*.json .DS_Store node_modules/ dist/*.d.ts +!dist/global.d.ts dist/package.json .cache/ coverage/ \ No newline at end of file diff --git a/dist/README.md b/dist/README.md index ac24cd4..48bab0d 100644 --- a/dist/README.md +++ b/dist/README.md @@ -1,5 +1,28 @@ +# chrome-types Published TypeScript definition files for Chrome Extensions, automatically generated from Chromium source code. The default types file "index.d.ts" contains MV3+ types only. The helper "_all.d.ts" contains types including the deprecated Platform Apps APIs, and is used for the developer.chrome.com site. + +## Set Up + +To expose the global `chrome` namespace be sure to include `chrome-types` in your `tsconfig.json`. You could add `"chrome-types"` to the `compilerOptions.types` array, though you will then need to include each type definitions you want. It is recommended that you add `"node_modules/chrome-types/global.d.ts"` to the `include` array instead. + +### `compilerOptions.types` + +```JSON +{ + "compilerOptions": { + "types": ["chrome-types"] + } +} +``` + +### `include` + +```JSON +{ + "include": ["node_modules/chrome-types/global.d.ts"] +} +``` diff --git a/dist/global.d.ts b/dist/global.d.ts new file mode 100644 index 0000000..ec56279 --- /dev/null +++ b/dist/global.d.ts @@ -0,0 +1,8 @@ +/// + +interface Window { + /** + * Global Chrome namespace generated from Chromium source code. + */ + chrome: typeof chrome; +} \ No newline at end of file diff --git a/dist/package.template.json b/dist/package.template.json index 44c1448..1940131 100644 --- a/dist/package.template.json +++ b/dist/package.template.json @@ -15,5 +15,10 @@ "bugs": { "url": "https://github.com/GoogleChrome/chrome-types/issues" }, - "homepage": "https://github.com/GoogleChrome/chrome-types" + "homepage": "https://github.com/GoogleChrome/chrome-types", + "keywords": [ + "chrome", + "chromium", + "types" + ] } \ No newline at end of file