Skip to content

Commit fbe426e

Browse files
authored
change transpile to compile (#55881)
1 parent 1b70ac3 commit fbe426e

8 files changed

+28
-28
lines changed

src/compiler/checker.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -45210,10 +45210,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4521045210
if (mode !== ModuleKind.ESNext && moduleKind !== ModuleKind.ESNext) {
4521145211
const message = isImportAttributes
4521245212
? moduleKind === ModuleKind.NodeNext
45213-
? Diagnostics.Import_attributes_are_not_allowed_on_statements_that_transpile_to_CommonJS_require_calls
45213+
? Diagnostics.Import_attributes_are_not_allowed_on_statements_that_compile_to_CommonJS_require_calls
4521445214
: Diagnostics.Import_attributes_are_only_supported_when_the_module_option_is_set_to_esnext_or_nodenext
4521545215
: moduleKind === ModuleKind.NodeNext
45216-
? Diagnostics.Import_assertions_are_not_allowed_on_statements_that_transpile_to_CommonJS_require_calls
45216+
? Diagnostics.Import_assertions_are_not_allowed_on_statements_that_compile_to_CommonJS_require_calls
4521745217
: Diagnostics.Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_or_nodenext;
4521845218
return grammarErrorOnNode(node, message);
4521945219
}

src/compiler/diagnosticMessages.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -3603,7 +3603,7 @@
36033603
"category": "Error",
36043604
"code": 2835
36053605
},
3606-
"Import assertions are not allowed on statements that transpile to CommonJS 'require' calls.": {
3606+
"Import assertions are not allowed on statements that compile to CommonJS 'require' calls.": {
36073607
"category": "Error",
36083608
"code": 2836
36093609
},
@@ -3675,7 +3675,7 @@
36753675
"category": "Error",
36763676
"code": 2855
36773677
},
3678-
"Import attributes are not allowed on statements that transpile to CommonJS 'require' calls.": {
3678+
"Import attributes are not allowed on statements that compile to CommonJS 'require' calls.": {
36793679
"category": "Error",
36803680
"code": 2856
36813681
},

tests/baselines/reference/nodeModulesImportAssertions(module=nodenext).errors.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error TS2468: Cannot find global value 'Promise'.
2-
otherc.cts(1,35): error TS2836: Import assertions are not allowed on statements that transpile to CommonJS 'require' calls.
2+
otherc.cts(1,35): error TS2836: Import assertions are not allowed on statements that compile to CommonJS 'require' calls.
33
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.
44

55

@@ -9,7 +9,7 @@ otherc.cts(2,15): error TS2712: A dynamic import call in ES5/ES3 requires the 'P
99
==== otherc.cts (2 errors) ====
1010
import json from "./package.json" assert { type: "json" }; // should error, cjs mode imports don't support assertions
1111
~~~~~~~~~~~~~~~~~~~~~~~
12-
!!! error TS2836: Import assertions are not allowed on statements that transpile to CommonJS 'require' calls.
12+
!!! error TS2836: Import assertions are not allowed on statements that compile to CommonJS 'require' calls.
1313
const json2 = import("./package.json", { assert: { type: "json" } }); // should be fine
1414
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1515
!!! 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.

tests/baselines/reference/nodeModulesImportAttributes(module=nodenext).errors.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error TS2468: Cannot find global value 'Promise'.
2-
otherc.cts(1,35): error TS2856: Import attributes are not allowed on statements that transpile to CommonJS 'require' calls.
2+
otherc.cts(1,35): error TS2856: Import attributes are not allowed on statements that compile to CommonJS 'require' calls.
33
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.
44

55

@@ -9,7 +9,7 @@ otherc.cts(2,15): error TS2712: A dynamic import call in ES5/ES3 requires the 'P
99
==== otherc.cts (2 errors) ====
1010
import json from "./package.json" with { type: "json" }; // should error, cjs mode imports don't support attributes
1111
~~~~~~~~~~~~~~~~~~~~~
12-
!!! error TS2856: Import attributes are not allowed on statements that transpile to CommonJS 'require' calls.
12+
!!! error TS2856: Import attributes are not allowed on statements that compile to CommonJS 'require' calls.
1313
const json2 = import("./package.json", { with: { type: "json" } }); // should be fine
1414
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1515
!!! 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.

tests/baselines/reference/nodeModulesImportAttributesModeDeclarationEmit1(module=nodenext).errors.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
/index.ts(6,50): error TS2856: Import attributes are not allowed on statements that transpile to CommonJS 'require' calls.
1+
/index.ts(6,50): error TS2856: Import attributes are not allowed on statements that compile to CommonJS 'require' calls.
22
/index.ts(7,14): error TS2305: Module '"pkg"' has no exported member 'ImportInterface'.
3-
/index.ts(7,49): error TS2856: Import attributes are not allowed on statements that transpile to CommonJS 'require' calls.
3+
/index.ts(7,49): error TS2856: Import attributes are not allowed on statements that compile to CommonJS 'require' calls.
44

55

66
==== /index.ts (3 errors) ====
@@ -11,12 +11,12 @@
1111

1212
import {type RequireInterface as Req} from "pkg" with { "resolution-mode": "require" };
1313
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14-
!!! error TS2856: Import attributes are not allowed on statements that transpile to CommonJS 'require' calls.
14+
!!! error TS2856: Import attributes are not allowed on statements that compile to CommonJS 'require' calls.
1515
import {type ImportInterface as Imp} from "pkg" with { "resolution-mode": "import" };
1616
~~~~~~~~~~~~~~~
1717
!!! error TS2305: Module '"pkg"' has no exported member 'ImportInterface'.
1818
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19-
!!! error TS2856: Import attributes are not allowed on statements that transpile to CommonJS 'require' calls.
19+
!!! error TS2856: Import attributes are not allowed on statements that compile to CommonJS 'require' calls.
2020
export interface Loc extends Req, Imp {}
2121

2222
export type { RequireInterface } from "pkg" with { "resolution-mode": "require" };

tests/baselines/reference/nodeModulesImportAttributesModeDeclarationEmitErrors(module=nodenext).errors.txt

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
/index.ts(2,45): error TS2856: Import attributes are not allowed on statements that transpile to CommonJS 'require' calls.
1+
/index.ts(2,45): error TS2856: Import attributes are not allowed on statements that compile to CommonJS 'require' calls.
22
/index.ts(2,71): error TS1453: `resolution-mode` should be either `require` or `import`.
33
/index.ts(4,10): error TS2305: Module '"pkg"' has no exported member 'ImportInterface'.
4-
/index.ts(4,39): error TS2856: Import attributes are not allowed on statements that transpile to CommonJS 'require' calls.
5-
/index.ts(6,76): error TS2856: Import attributes are not allowed on statements that transpile to CommonJS 'require' calls.
4+
/index.ts(4,39): error TS2856: Import attributes are not allowed on statements that compile to CommonJS 'require' calls.
5+
/index.ts(6,76): error TS2856: Import attributes are not allowed on statements that compile to CommonJS 'require' calls.
66

77

88
==== /index.ts (5 errors) ====
99
// incorrect mode
1010
import type { RequireInterface } from "pkg" with { "resolution-mode": "foobar" };
1111
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12-
!!! error TS2856: Import attributes are not allowed on statements that transpile to CommonJS 'require' calls.
12+
!!! error TS2856: Import attributes are not allowed on statements that compile to CommonJS 'require' calls.
1313
~~~~~~~~
1414
!!! error TS1453: `resolution-mode` should be either `require` or `import`.
1515
// not type-only
1616
import { ImportInterface } from "pkg" with { "resolution-mode": "import" };
1717
~~~~~~~~~~~~~~~
1818
!!! error TS2305: Module '"pkg"' has no exported member 'ImportInterface'.
1919
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20-
!!! error TS2856: Import attributes are not allowed on statements that transpile to CommonJS 'require' calls.
20+
!!! error TS2856: Import attributes are not allowed on statements that compile to CommonJS 'require' calls.
2121
// not exclusively type-only
2222
import {type RequireInterface as Req, RequireInterface as Req2} from "pkg" with { "resolution-mode": "require" };
2323
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24-
!!! error TS2856: Import attributes are not allowed on statements that transpile to CommonJS 'require' calls.
24+
!!! error TS2856: Import attributes are not allowed on statements that compile to CommonJS 'require' calls.
2525

2626
export interface LocalInterface extends RequireInterface, ImportInterface {}
2727

tests/baselines/reference/nodeModulesImportModeDeclarationEmit1(module=nodenext).errors.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
/index.ts(6,50): error TS2836: Import assertions are not allowed on statements that transpile to CommonJS 'require' calls.
1+
/index.ts(6,50): error TS2836: Import assertions are not allowed on statements that compile to CommonJS 'require' calls.
22
/index.ts(7,14): error TS2305: Module '"pkg"' has no exported member 'ImportInterface'.
3-
/index.ts(7,49): error TS2836: Import assertions are not allowed on statements that transpile to CommonJS 'require' calls.
3+
/index.ts(7,49): error TS2836: Import assertions are not allowed on statements that compile to CommonJS 'require' calls.
44

55

66
==== /index.ts (3 errors) ====
@@ -11,12 +11,12 @@
1111

1212
import {type RequireInterface as Req} from "pkg" assert { "resolution-mode": "require" };
1313
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14-
!!! error TS2836: Import assertions are not allowed on statements that transpile to CommonJS 'require' calls.
14+
!!! error TS2836: Import assertions are not allowed on statements that compile to CommonJS 'require' calls.
1515
import {type ImportInterface as Imp} from "pkg" assert { "resolution-mode": "import" };
1616
~~~~~~~~~~~~~~~
1717
!!! error TS2305: Module '"pkg"' has no exported member 'ImportInterface'.
1818
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19-
!!! error TS2836: Import assertions are not allowed on statements that transpile to CommonJS 'require' calls.
19+
!!! error TS2836: Import assertions are not allowed on statements that compile to CommonJS 'require' calls.
2020
export interface Loc extends Req, Imp {}
2121

2222
export type { RequireInterface } from "pkg" assert { "resolution-mode": "require" };

tests/baselines/reference/nodeModulesImportModeDeclarationEmitErrors1(module=nodenext).errors.txt

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
/index.ts(2,45): error TS2836: Import assertions are not allowed on statements that transpile to CommonJS 'require' calls.
1+
/index.ts(2,45): error TS2836: Import assertions are not allowed on statements that compile to CommonJS 'require' calls.
22
/index.ts(2,73): error TS1453: `resolution-mode` should be either `require` or `import`.
33
/index.ts(4,10): error TS2305: Module '"pkg"' has no exported member 'ImportInterface'.
4-
/index.ts(4,39): error TS2836: Import assertions are not allowed on statements that transpile to CommonJS 'require' calls.
5-
/index.ts(6,76): error TS2836: Import assertions are not allowed on statements that transpile to CommonJS 'require' calls.
4+
/index.ts(4,39): error TS2836: Import assertions are not allowed on statements that compile to CommonJS 'require' calls.
5+
/index.ts(6,76): error TS2836: Import assertions are not allowed on statements that compile to CommonJS 'require' calls.
66

77

88
==== /index.ts (5 errors) ====
99
// incorrect mode
1010
import type { RequireInterface } from "pkg" assert { "resolution-mode": "foobar" };
1111
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12-
!!! error TS2836: Import assertions are not allowed on statements that transpile to CommonJS 'require' calls.
12+
!!! error TS2836: Import assertions are not allowed on statements that compile to CommonJS 'require' calls.
1313
~~~~~~~~
1414
!!! error TS1453: `resolution-mode` should be either `require` or `import`.
1515
// not type-only
1616
import { ImportInterface } from "pkg" assert { "resolution-mode": "import" };
1717
~~~~~~~~~~~~~~~
1818
!!! error TS2305: Module '"pkg"' has no exported member 'ImportInterface'.
1919
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20-
!!! error TS2836: Import assertions are not allowed on statements that transpile to CommonJS 'require' calls.
20+
!!! error TS2836: Import assertions are not allowed on statements that compile to CommonJS 'require' calls.
2121
// not exclusively type-only
2222
import {type RequireInterface as Req, RequireInterface as Req2} from "pkg" assert { "resolution-mode": "require" };
2323
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24-
!!! error TS2836: Import assertions are not allowed on statements that transpile to CommonJS 'require' calls.
24+
!!! error TS2836: Import assertions are not allowed on statements that compile to CommonJS 'require' calls.
2525

2626
export interface LocalInterface extends RequireInterface, ImportInterface {}
2727

0 commit comments

Comments
 (0)