change transpile to compile (#55881)

This commit is contained in:
Oleksandr T
2023-09-27 01:32:49 +03:00
committed by GitHub
parent 1b70ac32b2
commit fbe426e7d3
8 changed files with 28 additions and 28 deletions

View File

@@ -45210,10 +45210,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);
}

View File

@@ -3603,7 +3603,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
},
@@ -3675,7 +3675,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
},

View File

@@ -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.

View File

@@ -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.

View File

@@ -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" };

View File

@@ -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 {}

View File

@@ -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" };

View File

@@ -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 {}