Skip to content

Commit

Permalink
test: check typescript hook
Browse files Browse the repository at this point in the history
  • Loading branch information
marco-ippolito committed Aug 30, 2024
1 parent d2479fa commit 9b1a752
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/es-module/test-typescript.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -324,3 +324,16 @@ test('execute a JavaScript file importing a cjs TypeScript file', async () => {
match(result.stdout, /Hello, TypeScript!/);
strictEqual(result.code, 0);
});

test('execute a TypeScript loader', async () => {
const result = await spawnPromisified(process.execPath, [
'--experimental-strip-types',
'--no-warnings',
'--import',
fixtures.fileURL('typescript/ts/test-loader.ts'),
fixtures.path('typescript/ts/test-typescript.ts'),
]);
strictEqual(result.stderr, '');
match(result.stdout, /Hello, TypeScript!/);
strictEqual(result.code, 0);
});
6 changes: 6 additions & 0 deletions test/fixtures/typescript/ts/hook.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { ResolveHook } from 'node:module';

// Pass through
export const resolve: ResolveHook = async function resolve(specifier, context, nextResolve) {
return nextResolve(specifier, context);
};
4 changes: 4 additions & 0 deletions test/fixtures/typescript/ts/test-loader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { register } from 'node:module';
import * as fixtures from '../../../common/fixtures.mjs';

register(fixtures.fileURL('typescript/ts/hook.ts'));

0 comments on commit 9b1a752

Please sign in to comment.