
Company News
Socket Joins New OpenJS Program to Fund Node.js Security Work
Socket is joining the OpenJS Security Stewardship Program to fund Node.js vulnerability research, maintainer remediation, and security releases.
@webgpu/types
Advanced tools
This package defines Typescript types (`.d.ts`) for the upcoming [WebGPU standard](https://github.com/gpuweb/gpuweb/wiki/Implementation-Status).
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.
"dom" type definitions.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.
npm install --save-dev @webgpu/typesyarn add --dev @webgpu/typespnpm add -D @webgpu/typesIf 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:
tsc and tsc-based bundlersIn 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. :)
git submodule update --initgpuweb changes: pushd gpuweb && git checkout main && git pull && popdnpm cigenerated/index.d.ts: npm run generategenerated/index.d.ts and dist/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 the generated/ and dist/ files are not the same.
See below for intentional differences.npm run formatMost or all of these should be fixed in the generator over time.
any changed to object for WebIDL object.The following differences are TODO: should be changed in the final result.
textureBindingViewDimension.The following differences will remain.
onuncapturederror strongly typed.addEventListener('uncapturederror') type support.getContext definitions.GPUExtent3DStrict and GPUOrigin2DStrict.New patch releases are published to NPM and tagged in Git automatically by GitHub Actions on pushes to main when dist/index.d.ts has changed since the last release.
package.json intentionally omits a version field in Git; the workflow finds the latest version tag in Git, increments the patch version, publishes the package, and pushes the new Git tag.
Three.js is a popular JavaScript library that simplifies the creation of 3D graphics on the web. While it abstracts many complexities of WebGL, it does not provide direct access to the WebGPU API like @webgpu/types. Three.js is more focused on ease of use and rapid development of 3D scenes.
Babylon.js is another powerful 3D engine for web development. It provides a comprehensive set of tools for creating 3D applications, including support for WebGPU. However, it is more of a high-level framework compared to the low-level access provided by @webgpu/types.
FAQs
This package defines Typescript types (`.d.ts`) for the upcoming [WebGPU standard](https://github.com/gpuweb/gpuweb/wiki/Implementation-Status).
The npm package @webgpu/types receives a total of 2,988,223 weekly downloads. As such, @webgpu/types popularity was classified as popular.
We found that @webgpu/types demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.

Company News
Socket is joining the OpenJS Security Stewardship Program to fund Node.js vulnerability research, maintainer remediation, and security releases.

Security News
Two compromised GitHub Actions were re-enabled with malicious tags intact, exposing thousands of downstream repositories to Mini Shai-Hulud.

Research
/Security News
A malicious Firefox extension fetches its payload after installation to evade detection, steal Google session cookies, and automate account takeover.