From 4b9aafcdcf0dd3a0eb015f183bfc9a01339c0ca2 Mon Sep 17 00:00:00 2001 From: Elijah Potter <me@elijahpotter.dev> Date: Wed, 18 Dec 2024 07:48:01 -0700 Subject: [PATCH] fix: TypeScript doesn't like black magic More specifically, hooking into some low-level `wasm-bindgen` stuff is awkwardly typed. --- packages/.eslintrc.cjs | 3 ++- packages/harper.js/src/loadWasm.ts | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/.eslintrc.cjs b/packages/.eslintrc.cjs index 903a39b7..75fb9730 100644 --- a/packages/.eslintrc.cjs +++ b/packages/.eslintrc.cjs @@ -9,7 +9,8 @@ module.exports = { rules: { 'prettier/prettier': 'error', // Just annoying - '@typescript-eslint/no-explicit-any': ['off'] + '@typescript-eslint/no-explicit-any': ['off'], + '@typescript-eslint/ban-ts-comment': ['off'] }, parser: '@typescript-eslint/parser', plugins: ['@typescript-eslint', 'prettier'], diff --git a/packages/harper.js/src/loadWasm.ts b/packages/harper.js/src/loadWasm.ts index fbca1481..a6bfe56e 100644 --- a/packages/harper.js/src/loadWasm.ts +++ b/packages/harper.js/src/loadWasm.ts @@ -1,9 +1,10 @@ -// @ts-ignore +// @ts-expect-error because this virtual module hasn't been added to a `d.ts` file. import wasmUri from 'virtual:wasm'; let curWasmUri = wasmUri; -/** Get the currently set data URI for the WebAssembly module. */ +/** Get the currently set data URI for the WebAssembly module. + * I'm not a huge of the singleton, but we're swapping out same data, just from a different source, so the state doesn't meaningfully change. */ export function getWasmUri(): string { return curWasmUri; } @@ -18,6 +19,7 @@ export function setWasmUri(uri: string) { * */ export default async function loadWasm() { const wasm = await import('wasm'); + // @ts-ignore await wasm.default(getWasmUri()); return wasm;