mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
test: check typescript loader
PR-URL: https://github.com/nodejs/node/pull/54657 Refs: https://github.com/nodejs/node/issues/54645 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
This commit is contained in:
1 parent
53b29b0469
commit
4352bf69e9
4 files changed
+43
No files matched your search
@@ -412,3 +412,29 @@ test('expect error when executing a TypeScript file with generics', async () =>
|
||||
strictEqual(result.stdout, '');
|
||||
strictEqual(result.code, 1);
|
||||
});
|
||||
|
||||
test('execute a TypeScript loader and a .ts file', 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);
|
||||
});
|
||||
|
||||
test('execute a TypeScript loader and a .js file', 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-simple.js'),
|
||||
]);
|
||||
strictEqual(result.stderr, '');
|
||||
match(result.stdout, /Hello, TypeScript!/);
|
||||
strictEqual(result.code, 0);
|
||||
});
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
import type { ResolveHook } from 'node:module';
|
||||
|
||||
// Pass through
|
||||
export const resolve: ResolveHook = async function resolve(specifier, context, nextResolve) {
|
||||
if(false){
|
||||
// https://github.com/nodejs/node/issues/54645
|
||||
// A bug in the typescript parsers swc causes
|
||||
// the next line to not be parsed correctly
|
||||
}
|
||||
return nextResolve(specifier, context);
|
||||
};
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import { register } from 'node:module';
|
||||
import * as fixtures from '../../../common/fixtures.mjs';
|
||||
|
||||
register(fixtures.fileURL('typescript/ts/hook.ts'));
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
const str = "Hello, TypeScript!";
|
||||
console.log(str);
|
||||
Reference in new issue
Block a user