| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
This package defines Typescript types (.d.ts) for the upcoming WebGPU standard.
Use this package to augment the ambient "dom" type definitions with the new definitions for WebGPU.
This repo also generates typedoc docs here: https://gpuweb.github.io/types
See the TypeScript handbook.
WebGPU types have been integrated into the "dom" starting with TypeScript 6. It appears that v6.0.4 and above will include a full set of WebGPU types and thus should not need the supplemental types from this repo.
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 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 to be package v0.0.352 or greater, and use it instead of the built-in "dom" library:
Install:
npm install @types/web
Usage in tsconfig.json:
{
// ...
"compilerOptions": {
// ...
"lib": ["esnext"], // Do not include "dom"!
"types": ["@types/web"],
}
}For TypeScript v5 and below, this library is still necessary to provide WebGPU types.
If you are on TypeScript < 5.1, you will also need to install @types/dom-webcodecs as a sibling dependency. The version you need depends on the TypeScript version; see the tests for examples.
Since this package is outside DefinitelyTyped, the dependency won't be picked up automatically. There are several ways to add a additional TypeScript type definition dependencies to your TypeScript project:
In tsconfig.json:
{
// ...
"compilerOptions": {
// ...
"types": ["@webgpu/types"]
}
}Or you can use typeRoots:
{
// ...
"compilerOptions": {
// ...
"typeRoots": ["./node_modules/@webgpu/types", "./node_modules/@types"]
}
}This may work better if your toolchain doesn't read tsconfig.json.
/// <reference types="@webgpu/types" />If you use Webpack and the options above aren't sufficient (this has not been verified), you may need the following in webpack.config.js:
"types": ["@webgpu/types"]Please contribute a PR to add instructions for other setups or improve existing instructions. :)
Most or all of these should be fixed in the generator over time.
The following differences are TODO: should be changed in the final result.
The following differences will remain.
(only for people who have npm publish access)
| Back | FazBrowse Home | New Git URL |