diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0eb1a99609473..72989b31702e0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -45227,10 +45227,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (mode !== ModuleKind.ESNext && moduleKind !== ModuleKind.ESNext) { const message = isImportAttributes ? moduleKind === ModuleKind.NodeNext - ? Diagnostics.Import_attributes_are_not_allowed_on_statements_that_transpile_to_CommonJS_require_calls + ? Diagnostics.Import_attributes_are_not_allowed_on_statements_that_compile_to_CommonJS_require_calls : Diagnostics.Import_attributes_are_only_supported_when_the_module_option_is_set_to_esnext_or_nodenext : moduleKind === ModuleKind.NodeNext - ? Diagnostics.Import_assertions_are_not_allowed_on_statements_that_transpile_to_CommonJS_require_calls + ? Diagnostics.Import_assertions_are_not_allowed_on_statements_that_compile_to_CommonJS_require_calls : Diagnostics.Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_or_nodenext; return grammarErrorOnNode(node, message); } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 9083506fbeb38..f937446714ea6 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3611,7 +3611,7 @@ "category": "Error", "code": 2835 }, - "Import assertions are not allowed on statements that transpile to CommonJS 'require' calls.": { + "Import assertions are not allowed on statements that compile to CommonJS 'require' calls.": { "category": "Error", "code": 2836 }, @@ -3683,7 +3683,7 @@ "category": "Error", "code": 2855 }, - "Import attributes are not allowed on statements that transpile to CommonJS 'require' calls.": { + "Import attributes are not allowed on statements that compile to CommonJS 'require' calls.": { "category": "Error", "code": 2856 }, diff --git a/tests/baselines/reference/nodeModulesImportAssertions(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesImportAssertions(module=nodenext).errors.txt index 19217bd404ddb..e78f38f74f786 100644 --- a/tests/baselines/reference/nodeModulesImportAssertions(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesImportAssertions(module=nodenext).errors.txt @@ -1,5 +1,5 @@ error TS2468: Cannot find global value 'Promise'. -otherc.cts(1,35): error TS2836: Import assertions are not allowed on statements that transpile to CommonJS 'require' calls. +otherc.cts(1,35): error TS2836: Import assertions are not allowed on statements that compile to CommonJS 'require' calls. otherc.cts(2,15): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. @@ -9,7 +9,7 @@ otherc.cts(2,15): error TS2712: A dynamic import call in ES5/ES3 requires the 'P ==== otherc.cts (2 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 transpile to CommonJS 'require' calls. +!!! 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 TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. diff --git a/tests/baselines/reference/nodeModulesImportAttributes(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesImportAttributes(module=nodenext).errors.txt index e2dcc518d7ceb..659dbbc99867f 100644 --- a/tests/baselines/reference/nodeModulesImportAttributes(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesImportAttributes(module=nodenext).errors.txt @@ -1,5 +1,5 @@ error TS2468: Cannot find global value 'Promise'. -otherc.cts(1,35): error TS2856: Import attributes are not allowed on statements that transpile to CommonJS 'require' calls. +otherc.cts(1,35): error TS2856: Import attributes are not allowed on statements that compile to CommonJS 'require' calls. otherc.cts(2,15): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. @@ -9,7 +9,7 @@ otherc.cts(2,15): error TS2712: A dynamic import call in ES5/ES3 requires the 'P ==== otherc.cts (2 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 transpile to CommonJS 'require' calls. +!!! 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 TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. diff --git a/tests/baselines/reference/nodeModulesImportAttributesModeDeclarationEmit1(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesImportAttributesModeDeclarationEmit1(module=nodenext).errors.txt index fa85f6353ea68..bf4698ad28e95 100644 --- a/tests/baselines/reference/nodeModulesImportAttributesModeDeclarationEmit1(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesImportAttributesModeDeclarationEmit1(module=nodenext).errors.txt @@ -1,6 +1,6 @@ -/index.ts(6,50): error TS2856: Import attributes are not allowed on statements that transpile to CommonJS 'require' calls. +/index.ts(6,50): error TS2856: Import attributes are not allowed on statements that compile to CommonJS 'require' calls. /index.ts(7,14): error TS2305: Module '"pkg"' has no exported member 'ImportInterface'. -/index.ts(7,49): error TS2856: Import attributes are not allowed on statements that transpile to CommonJS 'require' calls. +/index.ts(7,49): error TS2856: Import attributes are not allowed on statements that compile to CommonJS 'require' calls. ==== /index.ts (3 errors) ==== @@ -11,12 +11,12 @@ import {type RequireInterface as Req} from "pkg" with { "resolution-mode": "require" }; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2856: Import attributes are not allowed on statements that transpile to CommonJS 'require' calls. +!!! error TS2856: Import attributes are not allowed on statements that compile to CommonJS 'require' calls. import {type ImportInterface as Imp} from "pkg" with { "resolution-mode": "import" }; ~~~~~~~~~~~~~~~ !!! error TS2305: Module '"pkg"' has no exported member 'ImportInterface'. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2856: Import attributes are not allowed on statements that transpile to CommonJS 'require' calls. +!!! error TS2856: Import attributes are not allowed on statements that compile to CommonJS 'require' calls. export interface Loc extends Req, Imp {} export type { RequireInterface } from "pkg" with { "resolution-mode": "require" }; diff --git a/tests/baselines/reference/nodeModulesImportAttributesModeDeclarationEmitErrors(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesImportAttributesModeDeclarationEmitErrors(module=nodenext).errors.txt index 7d8663cd444e5..c45ca1322b3a8 100644 --- a/tests/baselines/reference/nodeModulesImportAttributesModeDeclarationEmitErrors(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesImportAttributesModeDeclarationEmitErrors(module=nodenext).errors.txt @@ -1,15 +1,15 @@ -/index.ts(2,45): error TS2856: Import attributes are not allowed on statements that transpile to CommonJS 'require' calls. +/index.ts(2,45): error TS2856: Import attributes are not allowed on statements that compile to CommonJS 'require' calls. /index.ts(2,71): error TS1453: `resolution-mode` should be either `require` or `import`. /index.ts(4,10): error TS2305: Module '"pkg"' has no exported member 'ImportInterface'. -/index.ts(4,39): error TS2856: Import attributes are not allowed on statements that transpile to CommonJS 'require' calls. -/index.ts(6,76): error TS2856: Import attributes are not allowed on statements that transpile to CommonJS 'require' calls. +/index.ts(4,39): error TS2856: Import attributes are not allowed on statements that compile to CommonJS 'require' calls. +/index.ts(6,76): error TS2856: Import attributes are not allowed on statements that compile to CommonJS 'require' calls. ==== /index.ts (5 errors) ==== // incorrect mode import type { RequireInterface } from "pkg" with { "resolution-mode": "foobar" }; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2856: Import attributes are not allowed on statements that transpile to CommonJS 'require' calls. +!!! error TS2856: Import attributes are not allowed on statements that compile to CommonJS 'require' calls. ~~~~~~~~ !!! error TS1453: `resolution-mode` should be either `require` or `import`. // not type-only @@ -17,11 +17,11 @@ ~~~~~~~~~~~~~~~ !!! error TS2305: Module '"pkg"' has no exported member 'ImportInterface'. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2856: Import attributes are not allowed on statements that transpile to CommonJS 'require' calls. +!!! error TS2856: Import attributes are not allowed on statements that compile to CommonJS 'require' calls. // not exclusively type-only import {type RequireInterface as Req, RequireInterface as Req2} from "pkg" with { "resolution-mode": "require" }; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2856: Import attributes are not allowed on statements that transpile to CommonJS 'require' calls. +!!! error TS2856: Import attributes are not allowed on statements that compile to CommonJS 'require' calls. export interface LocalInterface extends RequireInterface, ImportInterface {} diff --git a/tests/baselines/reference/nodeModulesImportModeDeclarationEmit1(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesImportModeDeclarationEmit1(module=nodenext).errors.txt index dd57016e6b7d1..e77140972a1ce 100644 --- a/tests/baselines/reference/nodeModulesImportModeDeclarationEmit1(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesImportModeDeclarationEmit1(module=nodenext).errors.txt @@ -1,6 +1,6 @@ -/index.ts(6,50): error TS2836: Import assertions are not allowed on statements that transpile to CommonJS 'require' calls. +/index.ts(6,50): error TS2836: Import assertions are not allowed on statements that compile to CommonJS 'require' calls. /index.ts(7,14): error TS2305: Module '"pkg"' has no exported member 'ImportInterface'. -/index.ts(7,49): error TS2836: Import assertions are not allowed on statements that transpile to CommonJS 'require' calls. +/index.ts(7,49): error TS2836: Import assertions are not allowed on statements that compile to CommonJS 'require' calls. ==== /index.ts (3 errors) ==== @@ -11,12 +11,12 @@ import {type RequireInterface as Req} from "pkg" assert { "resolution-mode": "require" }; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2836: Import assertions are not allowed on statements that transpile to CommonJS 'require' calls. +!!! error TS2836: Import assertions are not allowed on statements that compile to CommonJS 'require' calls. import {type ImportInterface as Imp} from "pkg" assert { "resolution-mode": "import" }; ~~~~~~~~~~~~~~~ !!! error TS2305: Module '"pkg"' has no exported member 'ImportInterface'. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2836: Import assertions are not allowed on statements that transpile to CommonJS 'require' calls. +!!! error TS2836: Import assertions are not allowed on statements that compile to CommonJS 'require' calls. export interface Loc extends Req, Imp {} export type { RequireInterface } from "pkg" assert { "resolution-mode": "require" }; diff --git a/tests/baselines/reference/nodeModulesImportModeDeclarationEmitErrors1(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesImportModeDeclarationEmitErrors1(module=nodenext).errors.txt index 98a0b7fcfa6f7..e1be07261876a 100644 --- a/tests/baselines/reference/nodeModulesImportModeDeclarationEmitErrors1(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesImportModeDeclarationEmitErrors1(module=nodenext).errors.txt @@ -1,15 +1,15 @@ -/index.ts(2,45): error TS2836: Import assertions are not allowed on statements that transpile to CommonJS 'require' calls. +/index.ts(2,45): error TS2836: Import assertions are not allowed on statements that compile to CommonJS 'require' calls. /index.ts(2,73): error TS1453: `resolution-mode` should be either `require` or `import`. /index.ts(4,10): error TS2305: Module '"pkg"' has no exported member 'ImportInterface'. -/index.ts(4,39): error TS2836: Import assertions are not allowed on statements that transpile to CommonJS 'require' calls. -/index.ts(6,76): error TS2836: Import assertions are not allowed on statements that transpile to CommonJS 'require' calls. +/index.ts(4,39): error TS2836: Import assertions are not allowed on statements that compile to CommonJS 'require' calls. +/index.ts(6,76): error TS2836: Import assertions are not allowed on statements that compile to CommonJS 'require' calls. ==== /index.ts (5 errors) ==== // incorrect mode import type { RequireInterface } from "pkg" assert { "resolution-mode": "foobar" }; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2836: Import assertions are not allowed on statements that transpile to CommonJS 'require' calls. +!!! error TS2836: Import assertions are not allowed on statements that compile to CommonJS 'require' calls. ~~~~~~~~ !!! error TS1453: `resolution-mode` should be either `require` or `import`. // not type-only @@ -17,11 +17,11 @@ ~~~~~~~~~~~~~~~ !!! error TS2305: Module '"pkg"' has no exported member 'ImportInterface'. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2836: Import assertions are not allowed on statements that transpile to CommonJS 'require' calls. +!!! error TS2836: Import assertions are not allowed on statements that compile to CommonJS 'require' calls. // not exclusively type-only import {type RequireInterface as Req, RequireInterface as Req2} from "pkg" assert { "resolution-mode": "require" }; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2836: Import assertions are not allowed on statements that transpile to CommonJS 'require' calls. +!!! error TS2836: Import assertions are not allowed on statements that compile to CommonJS 'require' calls. export interface LocalInterface extends RequireInterface, ImportInterface {}