diff --git a/scripts/get_frequency.test.ts b/scripts/get_frequency.test.ts new file mode 100644 index 0000000..5911864 --- /dev/null +++ b/scripts/get_frequency.test.ts @@ -0,0 +1,45 @@ +import assert from 'node:assert/strict'; +import fs from 'node:fs'; +import path from 'node:path'; +import test from 'node:test'; +import { spawnSync } from 'node:child_process'; + +function createWorkspace(name: string): string { + const baseDir = path.join(process.cwd(), '.tmp', 'get-frequency-typecheck-test'); + fs.mkdirSync(baseDir, { recursive: true }); + return fs.mkdtempSync(path.join(baseDir, `${name}-`)); +} + +test('scripts/get_frequency.ts typechecks in isolation', () => { + const workspace = createWorkspace('isolated-script'); + const tsconfigPath = path.join(workspace, 'tsconfig.json'); + + fs.writeFileSync( + tsconfigPath, + JSON.stringify( + { + extends: '../../../tsconfig.typecheck.json', + include: ['../../../scripts/get_frequency.ts'], + exclude: [], + }, + null, + 2, + ), + 'utf8', + ); + + try { + const result = spawnSync('bunx', ['tsc', '--noEmit', '-p', tsconfigPath], { + cwd: process.cwd(), + encoding: 'utf8', + }); + + assert.equal( + result.status, + 0, + `expected scripts/get_frequency.ts to typecheck\nstdout:\n${result.stdout}\nstderr:\n${result.stderr}`, + ); + } finally { + fs.rmSync(workspace, { recursive: true, force: true }); + } +}); diff --git a/scripts/get_frequency.ts b/scripts/get_frequency.ts index 5b61532..893d77e 100644 --- a/scripts/get_frequency.ts +++ b/scripts/get_frequency.ts @@ -484,7 +484,6 @@ interface YomitanRuntimeState { yomitanExt: unknown | null; yomitanSession: unknown | null; parserWindow: unknown | null; - yomitanSession: unknown | null; parserReadyPromise: Promise | null; parserInitPromise: Promise | null; available: boolean; @@ -544,7 +543,6 @@ async function createYomitanRuntimeState( yomitanExt: null, yomitanSession: null, parserWindow: null, - yomitanSession: null, parserReadyPromise: null, parserInitPromise: null, available: false,