Skip to content

Commit 9ba8a06

Browse files
authored
Update README for TypeScript v6 and v7 instructions (#204)
Adds some instructions for how to best get WebGPU types with TypeScript v6 and v7, including how to work around the incomplete types included in some versions of the `"dom"` library.
1 parent acad56b commit 9ba8a06

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,36 @@ This repo also generates typedoc docs here: https://gpuweb.github.io/types
1313
See the [TypeScript handbook](http://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html).
1414

1515

16+
## Integration into `"dom"` type definitions.
17+
18+
WebGPU types have been integrated into the [`"dom"`](https://www.typescriptlang.org/docs/handbook/compiler-options.html#compiler-options) starting with TypeScript 6. It appears that
19+
v6.0.4 and above will include a full set of WebGPU types and thus should not need the supplemental types from this repo.
20+
21+
Unfortunately some versions of TypeScript include a `"dom"` library which only contained a partial set of WebGPU types, preventing WebGPU code from building cleanly. This is confirmed
22+
the case in TypeScript v6.0.3 and lower and TypeScript v7.0.2 and lower. To build WebGPU with the affected versions install the [`@types/web`](https://www.npmjs.com/package/@types/web)
23+
to be package v0.0.352 or greater, and use it instead of the built-in `"dom"` library:
24+
25+
Install:
26+
```
27+
npm install @types/web
28+
```
29+
30+
Usage in `tsconfig.json`:
31+
```js
32+
{
33+
// ...
34+
"compilerOptions": {
35+
// ...
36+
"lib": ["esnext"], // Do not include "dom"!
37+
"types": ["@types/web"],
38+
}
39+
}
40+
```
41+
42+
For TypeScript v5 and below, this library is still necessary to provide WebGPU types.
43+
44+
45+
1646
## How can I use them?
1747

1848
### Install

0 commit comments

Comments
 (0)