Skip to content

Commit 9b1a752

Browse files
test: check typescript hook
1 parent d2479fa commit 9b1a752

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

test/es-module/test-typescript.mjs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,3 +324,16 @@ test('execute a JavaScript file importing a cjs TypeScript file', async () => {
324324
match(result.stdout, /Hello, TypeScript!/);
325325
strictEqual(result.code, 0);
326326
});
327+
328+
test('execute a TypeScript loader', async () => {
329+
const result = await spawnPromisified(process.execPath, [
330+
'--experimental-strip-types',
331+
'--no-warnings',
332+
'--import',
333+
fixtures.fileURL('typescript/ts/test-loader.ts'),
334+
fixtures.path('typescript/ts/test-typescript.ts'),
335+
]);
336+
strictEqual(result.stderr, '');
337+
match(result.stdout, /Hello, TypeScript!/);
338+
strictEqual(result.code, 0);
339+
});

test/fixtures/typescript/ts/hook.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import type { ResolveHook } from 'node:module';
2+
3+
// Pass through
4+
export const resolve: ResolveHook = async function resolve(specifier, context, nextResolve) {
5+
return nextResolve(specifier, context);
6+
};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff 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'));

0 commit comments

Comments
 (0)