From fa110634a91ddb82d5b0cb26ef34da0407d6f152 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 12 Sep 2022 21:42:28 +0000 Subject: [PATCH] Cherry-pick PR #50673 into release-4.8 Component commits: 3d0e834041 Remove error message in node16 --- src/compiler/checker.ts | 2 +- .../nodeModulesImportAssertions(module=node16).errors.txt | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 194f51256860b..c25e2cac93b4c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -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); diff --git a/tests/baselines/reference/nodeModulesImportAssertions(module=node16).errors.txt b/tests/baselines/reference/nodeModulesImportAssertions(module=node16).errors.txt index 5730914f8677d..aa5cae15aeee3 100644 --- a/tests/baselines/reference/nodeModulesImportAssertions(module=node16).errors.txt +++ b/tests/baselines/reference/nodeModulesImportAssertions(module=node16).errors.txt @@ -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",