Skip to content

Commit f46a680

Browse files
authoredSep 8, 2022
Remove error message in node16 (#50673)
1 parent ab831d0 commit f46a680

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed
 

‎src/compiler/checker.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -45775,7 +45775,7 @@ namespace ts {
4577545775
}
4577645776

4577745777
const nodeArguments = node.arguments;
45778-
if (moduleKind !== ModuleKind.ESNext && moduleKind !== ModuleKind.NodeNext) {
45778+
if (moduleKind !== ModuleKind.ESNext && moduleKind !== ModuleKind.NodeNext && moduleKind !== ModuleKind.Node16) {
4577945779
// We are allowed trailing comma after proposal-import-assertions.
4578045780
checkGrammarForDisallowedTrailingComma(nodeArguments);
4578145781

‎tests/baselines/reference/nodeModulesImportAssertions(module=node16).errors.txt

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
tests/cases/conformance/node/index.ts(1,35): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
22
tests/cases/conformance/node/otherc.cts(1,35): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
3-
tests/cases/conformance/node/otherc.cts(2,40): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'.
43

54

65
==== tests/cases/conformance/node/index.ts (1 errors) ====
76
import json from "./package.json" assert { type: "json" };
87
~~~~~~~~~~~~~~~~~~~~~~~
98
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
10-
==== tests/cases/conformance/node/otherc.cts (2 errors) ====
9+
==== tests/cases/conformance/node/otherc.cts (1 errors) ====
1110
import json from "./package.json" assert { type: "json" }; // should error, cjs mode imports don't support assertions
1211
~~~~~~~~~~~~~~~~~~~~~~~
1312
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
1413
const json2 = import("./package.json", { assert: { type: "json" } }); // should be fine
15-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
16-
!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'.
1714
==== tests/cases/conformance/node/package.json (0 errors) ====
1815
{
1916
"name": "pkg",

0 commit comments

Comments
 (0)
Please sign in to comment.