Skip to content

Commit 5e68e76

Browse files
authored
Type check all Vite plugin playgrounds (#11450)
* Replace check:types with check:type * Fix type errors
1 parent 67ffcd0 commit 5e68e76

File tree

73 files changed

+121
-120
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+121
-120
lines changed

packages/vite-plugin-cloudflare/playground/additional-modules/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"type": "module",
55
"scripts": {
66
"build": "vite build --app",
7-
"check:types": "tsc --build",
7+
"check:type": "tsc --build",
88
"dev": "vite dev",
99
"preview": "vite preview"
1010
},

packages/vite-plugin-cloudflare/playground/additional-modules/src/index.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ import wasm from "./modules/wasm-example.wasm";
66
import init from "./modules/wasm-example.wasm?init";
77
import wasmWithModuleParam from "./modules/wasm-example.wasm?module";
88

9+
interface Instance {
10+
exports: {
11+
add(a: number, b: number): number;
12+
};
13+
}
14+
915
export default {
1016
async fetch(request) {
1117
const url = new URL(request.url);
@@ -28,19 +34,21 @@ export default {
2834
});
2935
}
3036
case "/wasm": {
31-
const instance = await WebAssembly.instantiate(wasm);
37+
const instance = (await WebAssembly.instantiate(wasm)) as Instance;
3238
const result = instance.exports.add(3, 4);
3339

3440
return Response.json({ result });
3541
}
3642
case "/wasm-with-module-param": {
37-
const instance = await WebAssembly.instantiate(wasmWithModuleParam);
43+
const instance = (await WebAssembly.instantiate(
44+
wasmWithModuleParam
45+
)) as Instance;
3846
const result = instance.exports.add(5, 6);
3947

4048
return Response.json({ result });
4149
}
4250
case "/wasm-with-init-param": {
43-
const instance = await init();
51+
const instance = (await init()) as Instance;
4452
const result = instance.exports.add(7, 8);
4553

4654
return Response.json({ result });
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
declare module '*.bin' {
2+
const arrayBuffer: ArrayBuffer;
3+
export default arrayBuffer;
4+
}
5+
6+
declare module '*.html' {
7+
const html: string
8+
export default html
9+
}
10+
11+
declare module '*.wasm' {
12+
const wasm: WebAssembly.Module
13+
export default wasm
14+
}
15+
16+
declare module '*.wasm?module' {
17+
const wasm: WebAssembly.Module
18+
export default wasm
19+
}

packages/vite-plugin-cloudflare/playground/assets/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"build": "vite build",
77
"build:no-client-entry": "vite build -c vite.config.no-client-entry.ts",
88
"build:public-dir-only": "vite build -c vite.config.public-dir-only.ts",
9-
"check:types": "tsc --build",
9+
"check:type": "tsc --build",
1010
"dev": "vite dev",
1111
"dev:no-client-entry": "vite dev -c vite.config.no-client-entry.ts",
1212
"dev:public-dir-only": "vite dev -c vite.config.public-dir-only.ts",
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
{
22
"extends": ["@cloudflare/workers-tsconfig/base.json"],
3-
"include": [
4-
"vite.config.ts",
5-
"vite.config.no-client-entry.ts",
6-
"vite.config.public-dir-only.ts",
7-
"__tests__"
8-
]
3+
"include": ["vite.config.ts", "vite.config.*.ts", "__tests__"]
94
}

packages/vite-plugin-cloudflare/playground/bindings/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"scripts": {
66
"build": "vite build --app",
77
"cf-typegen": "wrangler types --include-runtime=false",
8-
"check:types": "tsc --build",
8+
"check:type": "tsc --build",
99
"dev": "vite dev",
1010
"preview": "vite preview"
1111
},

packages/vite-plugin-cloudflare/playground/bindings/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export default {
7777
const value = Math.floor(Date.now() * Math.random()).toString(36);
7878
await env.HELLO_WORLD.set(value);
7979

80-
const result = await env.HELLO_WORLD.get(value);
80+
const result = await env.HELLO_WORLD.get();
8181
if (value !== result.value) {
8282
return new Response("Hello World binding failed to set value", {
8383
status: 500,

packages/vite-plugin-cloudflare/playground/block-concurrency-while/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"type": "module",
55
"scripts": {
66
"build": "vite build --app",
7-
"check:types": "tsc --build",
7+
"check:type": "tsc --build",
88
"dev": "vite dev",
99
"preview": "vite preview"
1010
},

packages/vite-plugin-cloudflare/playground/cloudflare-env/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"scripts": {
66
"build": "vite build --app",
77
"build:custom-mode": "vite build --app -c vite.config.custom-mode.ts",
8-
"check:types": "tsc --build",
8+
"check:type": "tsc --build",
99
"dev": "vite dev",
1010
"dev:custom-mode": "vite dev -c vite.config.custom-mode.ts",
1111
"preview": "vite preview",

packages/vite-plugin-cloudflare/playground/cloudflare-env/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ interface Env {
33
}
44

55
export default {
6-
async fetch(request, env) {
6+
async fetch(_, env) {
77
return new Response(env.MY_VAR);
88
},
99
} satisfies ExportedHandler<Env>;

0 commit comments

Comments
 (0)