You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Copy file name to clipboardExpand all lines: README.md
+30Lines changed: 30 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,36 @@ This repo also generates typedoc docs here: https://gpuweb.github.io/types
13
13
See the [TypeScript handbook](http://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html).
14
14
15
15
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.
0 commit comments