This package contains the TypeScript type declaration (.d.ts
) files for the WebNN API
- npm:
npm install --save-dev @webnn/types
- yarn:
yarn add --dev @webnn/types
- pnpm:
pnpm add -D @webnn/types
Since this package is outside of DefinitelyTyped, the types won't be automatically picked up. The following is a list of ways to add it to type lookup.
{
"compilerOptions": {
"types": ["@webnn/types"]
}
}
{
"compilerOptions": {
"typeRoots": [
"./node_modules/@webnn/types",
"./node_modules/@types"
]
}
}
This package uses webnn
instead of dist
so that both @webnn/types
and @webgpu/types
can be used in typeRoots
.
- Update WebNN specification under
spec
git submodule update --init --recursive
- Generate types with
npm run generate
- Manually update
webnn/index.d.ts
with changes fromgenerate/index.d.ts
. Note that there are intentional differences between the versions undergenerate/
andwebnn/
. - Push changes to all files under
generated/
andwebnn/
.
This repository is based on the work done by the WebGPU team for their typing files. Without their work on @webgpu/types, the WebNN types would have been much harder to create.