This package defines Typescript types (.d.ts) for the upcoming WebGPU standard.
This package matches the work-in-progress WebGPU API, which is currently unstable!
Use this package to augment the ambient "dom" type definitions with the new definitions for WebGPU.
See the TypeScript handbook.
- npm:
npm install --save @webgpu/types - yarn:
yarn add @webgpu/types
In tsconfig.json:
{
// ...
"compilerOptions": {
// ...
"typeRoots": [ "./node_modules/@webgpu/types", "./node_modules/@types"]
}
}In webpack.config.js add:
"types": ["@webgpu/types"](may not be necessary with tsc config above - untested)
/// <reference types="@webgpu/types" />Please contribute a PR to add instructions for other setups or improve existing instructions. :)
- Make sure the submodule is checked out:
git submodule update --init - Pull
gpuwebchanges:pushd gpuweb && git checkout main && git pull && popd - Install dependencies:
npm ci - Generate
generated/index.d.ts:npm run generate - Open a diff between
generated/index.d.tsanddist/index.d.ts. The generated file is tracked by Git so you can see what has changed. Update the latter according to changes from the former. Note thegenerated/anddist/files are not the same. See below for intentional differences. - Format the result:
npm run format
Most or all of these should be fixed in the generator over time.
Arraychanged toIterablefor WebIDLsequences in argument positions.anychanged toobjectfor WebIDLobject.| SharedArrayBufferadded for[AllowShared] BufferSource.
The following differences are TODO: should be changed in the final result.
- Deprecated items should be removed.
The following differences will remain.
onuncapturederrorstrongly typed.getContextdefinitions.GPUExtent3DStrict(and similar).
(only for people who have npm publish access)
git checkout main && git pull [email protected]:gpuweb/types.git main && git submodule init --update && npm version patch && git push [email protected]:gpuweb/types.git main --tags && npm publish