Skip to content

🤖 Pick PR #50673 (Remove error message in node16) into release-4.8 #50742

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45658,7 +45658,7 @@ namespace ts {
}

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
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'.
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'.
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'.


==== tests/cases/conformance/node/index.ts (1 errors) ====
import json from "./package.json" assert { type: "json" };
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
==== tests/cases/conformance/node/otherc.cts (2 errors) ====
==== tests/cases/conformance/node/otherc.cts (1 errors) ====
import json from "./package.json" assert { type: "json" }; // should error, cjs mode imports don't support assertions
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
const json2 = import("./package.json", { assert: { type: "json" } }); // should be fine
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'.
==== tests/cases/conformance/node/package.json (0 errors) ====
{
"name": "pkg",
Expand Down