| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -323,3 +323,29 @@ test('expect error when executing a TypeScript file with generics', async () => | |||
| 323 | 323 | strictEqual(result.stdout, ''); | |
| 324 | 324 | strictEqual(result.code, 1); | |
| 325 | 325 | }); | |
| 326 | + | ||
| 327 | + test('execute a TypeScript loader and a .ts file', async () => { | ||
| 328 | + const result = await spawnPromisified(process.execPath, [ | ||
| 329 | + '--experimental-strip-types', | ||
| 330 | + '--no-warnings', | ||
| 331 | + '--import', | ||
| 332 | + fixtures.fileURL('typescript/ts/test-loader.ts'), | ||
| 333 | + fixtures.path('typescript/ts/test-typescript.ts'), | ||
| 334 | + ]); | ||
| 335 | + strictEqual(result.stderr, ''); | ||
| 336 | + match(result.stdout, /Hello, TypeScript!/); | ||
| 337 | + strictEqual(result.code, 0); | ||
| 338 | + }); | ||
| 339 | + | ||
| 340 | + test('execute a TypeScript loader and a .js file', async () => { | ||
| 341 | + const result = await spawnPromisified(process.execPath, [ | ||
| 342 | + '--experimental-strip-types', | ||
| 343 | + '--no-warnings', | ||
| 344 | + '--import', | ||
| 345 | + fixtures.fileURL('typescript/ts/test-loader.ts'), | ||
| 346 | + fixtures.path('typescript/ts/test-simple.js'), | ||
| 347 | + ]); | ||
| 348 | + strictEqual(result.stderr, ''); | ||
| 349 | + match(result.stdout, /Hello, TypeScript!/); | ||
| 350 | + strictEqual(result.code, 0); | ||
| 351 | + }); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,11 @@ | |||
| 1 | + import type { ResolveHook } from 'node:module'; | ||
| 2 | + | ||
| 3 | + // Pass through | ||
| 4 | + export const resolve: ResolveHook = async function resolve(specifier, context, nextResolve) { | ||
| 5 | + if(false){ | ||
| 6 | + // https://github.com/nodejs/node/issues/54645 | ||
| 7 | + // A bug in the typescript parsers swc causes | ||
| 8 | + // the next line to not be parsed correctly | ||
| 9 | + } | ||
| 10 | + return nextResolve(specifier, context); | ||
| 11 | + }; | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,4 @@ | |||
| 1 | + import { register } from 'node:module'; | ||
| 2 | + import * as fixtures from '../../../common/fixtures.mjs'; | ||
| 3 | + | ||
| 4 | + register(fixtures.fileURL('typescript/ts/hook.ts')); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,2 @@ | |||
| 1 | + const str = "Hello, TypeScript!"; | ||
| 2 | + console.log(str); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments