From 0365c1a421222c999821f195e4b62f3eb3f1d9ba Mon Sep 17 00:00:00 2001 From: Marco Ippolito Date: Fri, 23 Aug 2024 10:00:39 +0200 Subject: [PATCH] module: use amaro default transform values --- lib/internal/modules/helpers.js | 4 ---- test/es-module/test-typescript-transform.mjs | 12 ++++++++++++ test/fixtures/typescript/cts/test-import-require.cts | 5 +++++ 3 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 test/fixtures/typescript/cts/test-import-require.cts diff --git a/lib/internal/modules/helpers.js b/lib/internal/modules/helpers.js index d805572cc8bb69..bba89a970ba3e0 100644 --- a/lib/internal/modules/helpers.js +++ b/lib/internal/modules/helpers.js @@ -360,10 +360,6 @@ function stripTypeScriptTypes(source, filename) { mode: typeScriptParsingMode, sourceMap: sourceMapEnabled, filename, - // Transform option is only applied in transform mode. - transform: { - verbatimModuleSyntax: true, - }, }; const { code, map } = parse(source, options); if (map) { diff --git a/test/es-module/test-typescript-transform.mjs b/test/es-module/test-typescript-transform.mjs index 85a5cf96f3cc02..06faa3ddfcf932 100644 --- a/test/es-module/test-typescript-transform.mjs +++ b/test/es-module/test-typescript-transform.mjs @@ -114,3 +114,15 @@ test('execute a transpiled JavaScript file', async () => { strictEqual(result.stdout, ''); strictEqual(result.code, 1); }); + +test('execute TypeScript file with import = require', async () => { + const result = await spawnPromisified(process.execPath, [ + '--experimental-transform-types', + '--no-warnings', + fixtures.path('typescript/cts/test-import-require.cts'), + ]); + + strictEqual(result.stderr, ''); + match(result.stdout, /Hello, TypeScript!/); + strictEqual(result.code, 0); +}); diff --git a/test/fixtures/typescript/cts/test-import-require.cts b/test/fixtures/typescript/cts/test-import-require.cts new file mode 100644 index 00000000000000..2d21a9c6ec3d66 --- /dev/null +++ b/test/fixtures/typescript/cts/test-import-require.cts @@ -0,0 +1,5 @@ +import util = require("node:util"); + +const foo: string = "Hello, TypeScript!"; + +console.log(util.styleText(["red"], foo));