Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(usage): add chrome namespace to Window and add usage directions, fixes #17 #34

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ chrome-*.json
.DS_Store
node_modules/
dist/*.d.ts
!dist/global.d.ts
dist/package.json
.cache/
coverage/
23 changes: 23 additions & 0 deletions dist/README.md
Original file line number Diff line number Diff line change
@@ -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"]
}
```
8 changes: 8 additions & 0 deletions dist/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/// <reference name="chrome" types="./index" />

interface Window {
/**
* Global Chrome namespace generated from Chromium source code.
*/
chrome: typeof chrome;
}
7 changes: 6 additions & 1 deletion dist/package.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}