Skip to content

Commit 3b34f2b

Browse files
committed
Make tsc check JS files with @ts-check annotations
1 parent db1af39 commit 3b34f2b

File tree

5 files changed

+9
-6
lines changed

5 files changed

+9
-6
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ async function loadModule() {
6363
mod = await WebAssembly.compile(bytes);
6464
}
6565

66-
/** @type {{exports: typeof import("./pkg/matrix_sdk_crypto_wasm_bg.wasm.d")}} */
66+
/** @type {{exports: typeof import("./pkg/matrix_sdk_crypto_wasm_bg.wasm.d.ts")}} */
6767
// @ts-expect-error: Typescript doesn't know what the instance exports exactly
6868
const instance = new WebAssembly.Instance(mod, {
6969
// @ts-expect-error: The bindings don't exactly match the 'ExportValue' type

index.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ async function loadModule() {
6363
mod = await WebAssembly.compile(bytes);
6464
}
6565

66-
/** @type {{exports: typeof import("./pkg/matrix_sdk_crypto_wasm_bg.wasm.d")}} */
66+
/** @type {{exports: typeof import("./pkg/matrix_sdk_crypto_wasm_bg.wasm.d.ts")}} */
6767
// @ts-expect-error: Typescript doesn't know what the instance exports exactly
6868
const instance = new WebAssembly.Instance(mod, {
6969
// @ts-expect-error: The bindings don't exactly match the 'ExportValue' type

node.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ bindings.__wbg_set_wasm(
3535
{
3636
get(_target, prop) {
3737
const mod = loadModuleSync();
38+
// @ts-expect-error: This results to an `any` type, which is fine
3839
return initInstance(mod)[prop];
3940
},
4041
},
@@ -85,7 +86,7 @@ async function loadModule() {
8586
function initInstance(mod) {
8687
if (initialised) throw new Error("initInstance called twice");
8788

88-
/** @type {{exports: typeof import("./pkg/matrix_sdk_crypto_wasm_bg.wasm.d")}} */
89+
/** @type {{exports: typeof import("./pkg/matrix_sdk_crypto_wasm_bg.wasm.d.ts")}} */
8990
// @ts-expect-error: Typescript doesn't know what the instance exports exactly
9091
const instance = new WebAssembly.Instance(mod, {
9192
// @ts-expect-error: The bindings don't exactly match the 'ExportValue' type

node.mjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ bindings.__wbg_set_wasm(
3535
{
3636
get(_target, prop) {
3737
const mod = loadModuleSync();
38+
// @ts-expect-error: This results to an `any` type, which is fine
3839
return initInstance(mod)[prop];
3940
},
4041
},
@@ -80,12 +81,12 @@ async function loadModule() {
8081
* Initializes the WASM module and returns the exports from the WASM module.
8182
*
8283
* @param {WebAssembly.Module} mod
83-
* @returns {typeof import("./pkg/matrix_sdk_crypto_wasm_bg.wasm.d")}
84+
* @returns {typeof import("./pkg/matrix_sdk_crypto_wasm_bg.wasm.d.ts")}
8485
*/
8586
function initInstance(mod) {
8687
if (initialised) throw new Error("initInstance called twice");
8788

88-
/** @type {{exports: typeof import("./pkg/matrix_sdk_crypto_wasm_bg.wasm.d")}} */
89+
/** @type {{exports: typeof import("./pkg/matrix_sdk_crypto_wasm_bg.wasm.d.ts")}} */
8990
// @ts-expect-error: Typescript doesn't know what the instance exports exactly
9091
const instance = new WebAssembly.Instance(mod, {
9192
// @ts-expect-error: The bindings don't exactly match the 'ExportValue' type

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"extends": "@tsconfig/node18/tsconfig.json",
33
"compilerOptions": {
4-
"lib": ["DOM"]
4+
"lib": ["DOM"],
5+
"allowJs": true
56
},
67
"typedocOptions": {
78
"entryPoints": ["index.d.ts"],

0 commit comments

Comments
 (0)