Skip to content

Commit b93130d

Browse files
committed
fix(usage): add chrome namespace to Window and add usage directions, fixes #17
1 parent dfe80f3 commit b93130d

File tree

4 files changed

+38
-1
lines changed

4 files changed

+38
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ chrome-*.json
22
.DS_Store
33
node_modules/
44
dist/*.d.ts
5+
!dist/global.d.ts
56
dist/package.json
67
.cache/
78
coverage/

dist/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
1+
# chrome-types
12
Published TypeScript definition files for Chrome Extensions, automatically generated from Chromium source code.
23

34
The default types file "index.d.ts" contains MV3+ types only.
45

56
The helper "_all.d.ts" contains types including the deprecated Platform Apps APIs, and is used for the developer.chrome.com site.
7+
8+
## Set Up
9+
10+
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.
11+
12+
### `compilerOptions.types`
13+
14+
```JSON
15+
{
16+
"compilerOptions": {
17+
"types": ["chrome-types"]
18+
}
19+
}
20+
```
21+
22+
### `include`
23+
24+
```JSON
25+
{
26+
"include": ["node_modules/chrome-types/global.d.ts"]
27+
}
28+
```

dist/global.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/// <reference name="chrome" types="./index" />
2+
3+
interface Window {
4+
/**
5+
* Global Chrome namespace generated from Chromium source code.
6+
*/
7+
chrome: typeof chrome;
8+
}

dist/package.template.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,10 @@
1515
"bugs": {
1616
"url": "https://github.com/GoogleChrome/chrome-types/issues"
1717
},
18-
"homepage": "https://github.com/GoogleChrome/chrome-types"
18+
"homepage": "https://github.com/GoogleChrome/chrome-types",
19+
"keywords": [
20+
"chrome",
21+
"chromium",
22+
"types"
23+
]
1924
}

0 commit comments

Comments
 (0)