diff --git a/index.js b/index.js index 142164de6..d22c3ec7c 100644 --- a/index.js +++ b/index.js @@ -63,7 +63,7 @@ async function loadModule() { mod = await WebAssembly.compile(bytes); } - /** @type {{exports: typeof import("./pkg/matrix_sdk_crypto_wasm_bg.wasm.d")}} */ + /** @type {{exports: typeof import("./pkg/matrix_sdk_crypto_wasm_bg.wasm.d.ts")}} */ // @ts-expect-error: Typescript doesn't know what the instance exports exactly const instance = new WebAssembly.Instance(mod, { // @ts-expect-error: The bindings don't exactly match the 'ExportValue' type diff --git a/index.mjs b/index.mjs index b285cc1e7..f55cc01e7 100644 --- a/index.mjs +++ b/index.mjs @@ -63,7 +63,7 @@ async function loadModule() { mod = await WebAssembly.compile(bytes); } - /** @type {{exports: typeof import("./pkg/matrix_sdk_crypto_wasm_bg.wasm.d")}} */ + /** @type {{exports: typeof import("./pkg/matrix_sdk_crypto_wasm_bg.wasm.d.ts")}} */ // @ts-expect-error: Typescript doesn't know what the instance exports exactly const instance = new WebAssembly.Instance(mod, { // @ts-expect-error: The bindings don't exactly match the 'ExportValue' type diff --git a/node.js b/node.js index b94a33eb8..4c71fc4fe 100644 --- a/node.js +++ b/node.js @@ -35,6 +35,7 @@ bindings.__wbg_set_wasm( { get(_target, prop) { const mod = loadModuleSync(); + // @ts-expect-error: This results to an `any` type, which is fine return initInstance(mod)[prop]; }, }, @@ -85,7 +86,7 @@ async function loadModule() { function initInstance(mod) { if (initialised) throw new Error("initInstance called twice"); - /** @type {{exports: typeof import("./pkg/matrix_sdk_crypto_wasm_bg.wasm.d")}} */ + /** @type {{exports: typeof import("./pkg/matrix_sdk_crypto_wasm_bg.wasm.d.ts")}} */ // @ts-expect-error: Typescript doesn't know what the instance exports exactly const instance = new WebAssembly.Instance(mod, { // @ts-expect-error: The bindings don't exactly match the 'ExportValue' type diff --git a/node.mjs b/node.mjs index 1dab77875..96d56136b 100644 --- a/node.mjs +++ b/node.mjs @@ -35,6 +35,7 @@ bindings.__wbg_set_wasm( { get(_target, prop) { const mod = loadModuleSync(); + // @ts-expect-error: This results to an `any` type, which is fine return initInstance(mod)[prop]; }, }, @@ -80,12 +81,12 @@ async function loadModule() { * Initializes the WASM module and returns the exports from the WASM module. * * @param {WebAssembly.Module} mod - * @returns {typeof import("./pkg/matrix_sdk_crypto_wasm_bg.wasm.d")} + * @returns {typeof import("./pkg/matrix_sdk_crypto_wasm_bg.wasm.d.ts")} */ function initInstance(mod) { if (initialised) throw new Error("initInstance called twice"); - /** @type {{exports: typeof import("./pkg/matrix_sdk_crypto_wasm_bg.wasm.d")}} */ + /** @type {{exports: typeof import("./pkg/matrix_sdk_crypto_wasm_bg.wasm.d.ts")}} */ // @ts-expect-error: Typescript doesn't know what the instance exports exactly const instance = new WebAssembly.Instance(mod, { // @ts-expect-error: The bindings don't exactly match the 'ExportValue' type diff --git a/package.json b/package.json index d3bbf70c7..09aecfed9 100644 --- a/package.json +++ b/package.json @@ -20,13 +20,16 @@ ], "exports": { ".": { - "node": { - "require": "./node.js", - "import": "./node.mjs" + "require": { + "types": "./index.d.ts", + "node": "./node.js", + "default": "./index.js" }, - "require": "./index.js", - "import": "./index.mjs", - "types": "./index.d.ts" + "import": { + "types": "./index.d.ts", + "node": "./node.mjs", + "default": "./index.mjs" + } } }, "files": [ diff --git a/tsconfig.json b/tsconfig.json index 8f51ae226..3c64f4579 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,8 @@ { "extends": "@tsconfig/node18/tsconfig.json", "compilerOptions": { - "lib": ["DOM"] + "lib": ["DOM"], + "allowJs": true }, "typedocOptions": { "entryPoints": ["index.d.ts"],