Skip to content

Commit 39576e6

Browse files
TypeScript Botweswigham
TypeScript Bot
andauthored
Cherry-pick PR #50673 into release-4.8 (#50742)
Component commits: 3d0e834 Remove error message in node16 Co-authored-by: Wesley Wigham <[email protected]>
1 parent 5773723 commit 39576e6

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45658,7 +45658,7 @@ namespace ts {
4565845658
}
4565945659

4566045660
const nodeArguments = node.arguments;
45661-
if (moduleKind !== ModuleKind.ESNext && moduleKind !== ModuleKind.NodeNext) {
45661+
if (moduleKind !== ModuleKind.ESNext && moduleKind !== ModuleKind.NodeNext && moduleKind !== ModuleKind.Node16) {
4566245662
// We are allowed trailing comma after proposal-import-assertions.
4566345663
checkGrammarForDisallowedTrailingComma(nodeArguments);
4566445664

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

Lines changed: 1 addition & 4 deletions
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)