Skip to content

change transpile to compile #55881

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 1 commit into from
Sep 26, 2023
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
4 changes: 2 additions & 2 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down Expand Up @@ -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
},
Expand Down
Original file line number Diff line number Diff line change
@@ -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.


Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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.


Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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) ====
Expand All @@ -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" };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
/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
import { ImportInterface } 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.
// 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 {}

Expand Down
Original file line number Diff line number Diff line change
@@ -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) ====
Expand All @@ -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" };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
/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
import { ImportInterface } 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.
// 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 {}

Expand Down