Home

Awesome

Typescript Type Definitions for WebGPU

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.

API style docs

This repo also generates typedoc docs here: https://gpuweb.github.io/types

What are declaration files?

See the TypeScript handbook.

How can I use them?

Install

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.

Configure

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:

TypeScript tsc and tsc-based bundlers

In tsconfig.json:

{
  // ...
  "compilerOptions": {
    // ...
    "types": ["@webgpu/types"]
  }
}

Or you can use typeRoots:

{
  // ...
  "compilerOptions": {
    // ...
    "typeRoots": ["./node_modules/@webgpu/types", "./node_modules/@types"]
  }
}

Inline in TypeScript

This may work better if your toolchain doesn't read tsconfig.json.

/// <reference types="@webgpu/types" />

Webpack

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"]

Others?

Please contribute a PR to add instructions for other setups or improve existing instructions. :)

How to update these types

Intentional differences between generator output and final result

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.

Publish a new npm package version

(only for people who have npm publish access)