Skip to content
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 internal/checker/grammarchecks.go
Original file line number Diff line number Diff line change
Expand Up @@ -2191,7 +2191,7 @@ func (c *Checker) checkGrammarImportCallExpression(node *ast.Node) bool {

nodeArguments := nodeAsCall.Arguments
argumentNodes := nodeArguments.Nodes
if c.moduleKind != core.ModuleKindESNext && c.moduleKind != core.ModuleKindNodeNext && c.moduleKind != core.ModuleKindNode16 && c.moduleKind != core.ModuleKindPreserve {
if !(core.ModuleKindNode16 <= c.moduleKind && c.moduleKind <= core.ModuleKindNodeNext) && c.moduleKind != core.ModuleKindESNext && c.moduleKind != core.ModuleKindPreserve {
// We are allowed trailing comma after proposal-import-assertions.
c.checkGrammarForDisallowedTrailingComma(nodeArguments, diagnostics.Trailing_comma_not_allowed)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
otherc.cts(1,35): error TS2836: Import assertions are not allowed on statements that compile to CommonJS 'require' calls.
otherc.cts(2,40): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', 'node18', 'node20', 'nodenext', or 'preserve'.


==== index.ts (0 errors) ====
import json from "./package.json" assert { type: "json" };
==== otherc.cts (2 errors) ====
==== otherc.cts (1 errors) ====
import json from "./package.json" assert { type: "json" }; // should error, cjs mode imports don't support assertions
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2836: Import assertions are not allowed on statements that compile to CommonJS 'require' calls.
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', 'node18', 'node20', 'nodenext', or 'preserve'.
==== package.json (0 errors) ====
{
"name": "pkg",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
index.ts(1,35): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
otherc.cts(1,35): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
otherc.cts(2,40): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', 'node18', 'node20', 'nodenext', or 'preserve'.


==== index.ts (1 errors) ====
import json from "./package.json" assert { type: "json" };
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
==== otherc.cts (2 errors) ====
==== otherc.cts (1 errors) ====
import json from "./package.json" assert { type: "json" }; // should error, cjs mode imports don't support assertions
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
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', 'node18', 'node20', 'nodenext', or 'preserve'.
==== package.json (0 errors) ====
{
"name": "pkg",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
--- old.nodeModulesImportAssertions(module=node20).errors.txt
+++ new.nodeModulesImportAssertions(module=node20).errors.txt
@@= skipped -0, +0 lines =@@
index.ts(1,35): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
otherc.cts(1,35): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
+otherc.cts(2,40): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', 'node18', 'node20', 'nodenext', or 'preserve'.

@@= skipped -3, +3 lines =@@

==== index.ts (1 errors) ====
import json from "./package.json" assert { type: "json" };
- ~~~~~~
+ ~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
-==== otherc.cts (1 errors) ====
+==== otherc.cts (2 errors) ====
==== otherc.cts (1 errors) ====
import json from "./package.json" assert { type: "json" }; // should error, cjs mode imports don't support assertions
- ~~~~~~
+ ~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
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', 'node18', 'node20', 'nodenext', or 'preserve'.
==== package.json (0 errors) ====
{
"name": "pkg",
==== package.json (0 errors) ====
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
otherc.cts(1,35): error TS2856: Import attributes are not allowed on statements that compile to CommonJS 'require' calls.
otherc.cts(2,40): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', 'node18', 'node20', 'nodenext', or 'preserve'.


==== index.ts (0 errors) ====
import json from "./package.json" with { type: "json" };
==== otherc.cts (2 errors) ====
==== otherc.cts (1 errors) ====
import json from "./package.json" with { type: "json" }; // should error, cjs mode imports don't support attributes
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2856: Import attributes are not allowed on statements that compile to CommonJS 'require' calls.
const json2 = import("./package.json", { with: { type: "json" } }); // should be fine
~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', 'node18', 'node20', 'nodenext', or 'preserve'.
==== package.json (0 errors) ====
{
"name": "pkg",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
otherc.cts(1,35): error TS2856: Import attributes are not allowed on statements that compile to CommonJS 'require' calls.
otherc.cts(2,40): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', 'node18', 'node20', 'nodenext', or 'preserve'.


==== index.ts (0 errors) ====
import json from "./package.json" with { type: "json" };
==== otherc.cts (2 errors) ====
==== otherc.cts (1 errors) ====
import json from "./package.json" with { type: "json" }; // should error, cjs mode imports don't support attributes
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2856: Import attributes are not allowed on statements that compile to CommonJS 'require' calls.
const json2 = import("./package.json", { with: { type: "json" } }); // should be fine
~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', 'node18', 'node20', 'nodenext', or 'preserve'.
==== package.json (0 errors) ====
{
"name": "pkg",
Expand Down

This file was deleted.

Loading