From b3c5132692f6f72183f0258341122ccbc30b799a Mon Sep 17 00:00:00 2001 From: camc314 <18101008+camc314@users.noreply.github.com> Date: Mon, 6 Oct 2025 23:27:44 +0000 Subject: [PATCH] feat(parser): use typescript for raw transfer tests (#14390) --- .../test/{parse-raw-common.js => parse-raw-common.ts} | 0 .../test/{parse-raw-worker.js => parse-raw-worker.ts} | 4 ++-- napi/parser/test/parse-raw.test.ts | 6 +++--- ...nits-from-test.js => typescript-make-units-from-test.ts} | 0 napi/parser/tsconfig.json | 3 ++- 5 files changed, 7 insertions(+), 6 deletions(-) rename napi/parser/test/{parse-raw-common.js => parse-raw-common.ts} (100%) rename napi/parser/test/{parse-raw-worker.js => parse-raw-worker.ts} (99%) rename napi/parser/test/{typescript-make-units-from-test.js => typescript-make-units-from-test.ts} (100%) diff --git a/napi/parser/test/parse-raw-common.js b/napi/parser/test/parse-raw-common.ts similarity index 100% rename from napi/parser/test/parse-raw-common.js rename to napi/parser/test/parse-raw-common.ts diff --git a/napi/parser/test/parse-raw-worker.js b/napi/parser/test/parse-raw-worker.ts similarity index 99% rename from napi/parser/test/parse-raw-worker.js rename to napi/parser/test/parse-raw-worker.ts index e07c2cb8f8d41..1c2aadfebb1bd 100644 --- a/napi/parser/test/parse-raw-worker.js +++ b/napi/parser/test/parse-raw-worker.ts @@ -20,8 +20,8 @@ import { TEST_TYPE_TS, TS_DIR_PATH, TS_ESTREE_DIR_PATH, -} from './parse-raw-common.js'; -import { makeUnitsFromTest } from './typescript-make-units-from-test.js'; +} from './parse-raw-common.ts'; +import { makeUnitsFromTest } from './typescript-make-units-from-test.ts'; const { hasOwn } = Object, { isArray } = Array; diff --git a/napi/parser/test/parse-raw.test.ts b/napi/parser/test/parse-raw.test.ts index e16cb2bb8dc97..f0efb09a1335b 100644 --- a/napi/parser/test/parse-raw.test.ts +++ b/napi/parser/test/parse-raw.test.ts @@ -27,7 +27,7 @@ import { TS_ESTREE_DIR_PATH, TS_SHORT_DIR_PATH, TS_SNAPSHOT_PATH, -} from './parse-raw-common.js'; +} from './parse-raw-common'; const { env } = process; const isEnabled = envValue => envValue === 'true' || envValue === '1'; @@ -43,7 +43,7 @@ const [describeLazy, itLazy] = isEnabled(env.RUN_LAZY_TESTS) // Worker pool for running test cases. // Vitest provides parallelism across test files, but not across cases within a single test file. // So we run each case in a worker to achieve parallelism. -const pool = new Tinypool({ filename: new URL('./parse-raw-worker.js', import.meta.url).href }); +const pool = new Tinypool({ filename: new URL('./parse-raw-worker.ts', import.meta.url).href }); let runCase; @@ -54,7 +54,7 @@ async function runCaseInWorker(type, props) { // If test failed in worker, run it again in main thread with Vitest's `expect`, // to get a nice diff and stack trace if (!success) { - if (!runCase) ({ runCase } = await import('./parse-raw-worker.js')); + if (!runCase) ({ runCase } = await import('./parse-raw-worker.ts')); type |= TEST_TYPE_PRETTY; await runCase({ type, props }, expect); diff --git a/napi/parser/test/typescript-make-units-from-test.js b/napi/parser/test/typescript-make-units-from-test.ts similarity index 100% rename from napi/parser/test/typescript-make-units-from-test.js rename to napi/parser/test/typescript-make-units-from-test.ts diff --git a/napi/parser/tsconfig.json b/napi/parser/tsconfig.json index c878e86a202a1..ceb5fb7929a88 100644 --- a/napi/parser/tsconfig.json +++ b/napi/parser/tsconfig.json @@ -3,6 +3,7 @@ "module": "Preserve", "moduleResolution": "Bundler", "noEmit": true, - "target": "ESNext" + "target": "ESNext", + "allowImportingTsExtensions": true } }