Skip to content

Commit

Permalink
Add tests for build on various TypeScript versions (#129)
Browse files Browse the repository at this point in the history
These also serve as examples of how to use these types with different
TypeScript versions.
  • Loading branch information
kainino0x authored Jun 21, 2023
1 parent 5d0a7ff commit 850f022
Show file tree
Hide file tree
Showing 17 changed files with 75 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/deploy-to-gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
node-version: '16.x'

- run: npm ci
- run: npm test
- run: npm run build-docs

- name: Deploy 📦
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ See the [TypeScript handbook](http://www.typescriptlang.org/docs/handbook/declar
- npm: `npm install --save @webgpu/types`
- yarn: `yarn add @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](tests/) for examples.

### Configure

#### TypeScript `tsc` and `tsc`-based bundlers
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"dist/**/*"
],
"scripts": {
"test": "for t in tests/* ; do (cd \"$t\" && npm i && npm test); done",
"test": "for t in tests/*/ ; do (cd \"$t\" && npm i && npm test); done",
"build-docs": "cd tsdoc-src && npm ci && npm run build",
"generate": "bikeshed-to-ts --in ./gpuweb/spec/index.bs --out ./generated/index.d.ts --forceGlobal --nominal && prettier -w generated/index.d.ts",
"format": "prettier -w dist/index.d.ts"
Expand Down
1 change: 1 addition & 0 deletions tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock.json
1 change: 1 addition & 0 deletions tests/ts4.6/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="@webgpu/types" />
10 changes: 10 additions & 0 deletions tests/ts4.6/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"scripts": {
"test": "tsc --version && tsc"
},
"dependencies": {
"@webgpu/types": "file:../..",
"@types/dom-webcodecs": "0.1.3",
"typescript": "~4.6.0"
}
}
4 changes: 4 additions & 0 deletions tests/ts4.6/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../tsconfig.json",
"include": ["index.ts"]
}
1 change: 1 addition & 0 deletions tests/ts4.7/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="@webgpu/types" />
10 changes: 10 additions & 0 deletions tests/ts4.7/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"scripts": {
"test": "tsc --version && tsc"
},
"dependencies": {
"@webgpu/types": "file:../..",
"@types/dom-webcodecs": "0.1.4",
"typescript": "~4.7.0"
}
}
4 changes: 4 additions & 0 deletions tests/ts4.7/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../tsconfig.json",
"include": ["index.ts"]
}
1 change: 1 addition & 0 deletions tests/ts4.9/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="@webgpu/types" />
10 changes: 10 additions & 0 deletions tests/ts4.9/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"scripts": {
"test": "tsc --version && tsc"
},
"dependencies": {
"@webgpu/types": "file:../..",
"@types/dom-webcodecs": "0.1.5",
"typescript": "~4.9.0"
}
}
4 changes: 4 additions & 0 deletions tests/ts4.9/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../tsconfig.json",
"include": ["index.ts"]
}
1 change: 1 addition & 0 deletions tests/ts5.1/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="@webgpu/types" />
9 changes: 9 additions & 0 deletions tests/ts5.1/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"scripts": {
"test": "tsc --version && tsc"
},
"dependencies": {
"@webgpu/types": "file:../..",
"typescript": "~5.1.0"
}
}
4 changes: 4 additions & 0 deletions tests/ts5.1/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../tsconfig.json",
"include": ["index.ts"]
}
9 changes: 9 additions & 0 deletions tests/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"lib": ["DOM", "ESNext"],
"module": "ESNext",
"noEmit": true,
"strict": true,
"target": "ESNext"
}
}

0 comments on commit 850f022

Please sign in to comment.