| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -412,3 +412,29 @@ test('expect error when executing a TypeScript file with generics', async () => | |||
| 412 | 412 | strictEqual(result.stdout, ''); | |
| 413 | 413 | strictEqual(result.code, 1); | |
| 414 | 414 | }); | |
| 415 | + | ||
| 416 | + test('execute a TypeScript loader and a .ts file', async () => { | ||
| 417 | + const result = await spawnPromisified(process.execPath, [ | ||
| 418 | + '--experimental-strip-types', | ||
| 419 | + '--no-warnings', | ||
| 420 | + '--import', | ||
| 421 | + fixtures.fileURL('typescript/ts/test-loader.ts'), | ||
| 422 | + fixtures.path('typescript/ts/test-typescript.ts'), | ||
| 423 | + ]); | ||
| 424 | + strictEqual(result.stderr, ''); | ||
| 425 | + match(result.stdout, /Hello, TypeScript!/); | ||
| 426 | + strictEqual(result.code, 0); | ||
| 427 | + }); | ||
| 428 | + | ||
| 429 | + test('execute a TypeScript loader and a .js file', async () => { | ||
| 430 | + const result = await spawnPromisified(process.execPath, [ | ||
| 431 | + '--experimental-strip-types', | ||
| 432 | + '--no-warnings', | ||
| 433 | + '--import', | ||
| 434 | + fixtures.fileURL('typescript/ts/test-loader.ts'), | ||
| 435 | + fixtures.path('typescript/ts/test-simple.js'), | ||
| 436 | + ]); | ||
| 437 | + strictEqual(result.stderr, ''); | ||
| 438 | + match(result.stdout, /Hello, TypeScript!/); | ||
| 439 | + strictEqual(result.code, 0); | ||
| 440 | + }); | ||
| 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