Skip to content

Commit 3d0e834

Browse files
committed
Remove error message in node16
1 parent 8b482b5 commit 3d0e834

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
@@ -45755,7 +45755,7 @@ namespace ts {
4575545755
}
4575645756

4575745757
const nodeArguments = node.arguments;
45758-
if (moduleKind !== ModuleKind.ESNext && moduleKind !== ModuleKind.NodeNext) {
45758+
if (moduleKind !== ModuleKind.ESNext && moduleKind !== ModuleKind.NodeNext && moduleKind !== ModuleKind.Node16) {
4575945759
// We are allowed trailing comma after proposal-import-assertions.
4576045760
checkGrammarForDisallowedTrailingComma(nodeArguments);
4576145761

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)