mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
test: module syntax should throw
PR-URL: https://github.com/nodejs/node/pull/57121 Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com>
This commit is contained in:
parent
5b7ebbc7b3
commit
1347d424e2
2 changed files with 24 additions and 3 deletions
|
@ -242,3 +242,23 @@ test('check syntax error is thrown when passing invalid syntax with --input-type
|
|||
match(result.stderr, /ERR_INVALID_TYPESCRIPT_SYNTAX/);
|
||||
strictEqual(result.code, 1);
|
||||
});
|
||||
|
||||
test('should not allow module keyword', async () => {
|
||||
const result = await spawnPromisified(process.execPath, [
|
||||
'--input-type=module-typescript',
|
||||
'--eval',
|
||||
'module F { export type x = number }']);
|
||||
strictEqual(result.stdout, '');
|
||||
match(result.stderr, /ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX/);
|
||||
strictEqual(result.code, 1);
|
||||
});
|
||||
|
||||
test('should not allow declare module keyword', async () => {
|
||||
const result = await spawnPromisified(process.execPath, [
|
||||
'--input-type=module-typescript',
|
||||
'--eval',
|
||||
'declare module F { export type x = number }']);
|
||||
strictEqual(result.stdout, '');
|
||||
match(result.stderr, /ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX/);
|
||||
strictEqual(result.code, 1);
|
||||
});
|
||||
|
|
|
@ -85,9 +85,10 @@ test('execute a TypeScript file with legacy-module', async () => {
|
|||
fixtures.path('typescript/ts/transformation/test-legacy-module.ts'),
|
||||
]);
|
||||
|
||||
strictEqual(result.stderr, '');
|
||||
match(result.stdout, /Hello, TypeScript!/);
|
||||
strictEqual(result.code, 0);
|
||||
match(result.stderr, /ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX/);
|
||||
match(result.stderr, /`module` keyword is not supported\. Use `namespace` instead/);
|
||||
strictEqual(result.stdout, '');
|
||||
strictEqual(result.code, 1);
|
||||
});
|
||||
|
||||
test('execute a TypeScript file with modern typescript syntax', async () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue