Skip to content

Commit b5e6ee5

Browse files
committed
Update error message
1 parent f961c34 commit b5e6ee5

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3595,7 +3595,7 @@ namespace ts {
35953595
if (scope && !scope.packageJsonContent.type) {
35963596
addRelatedInfo(diag, createDiagnosticForNode(
35973597
errorNode,
3598-
Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_type_Colon_module_to_its_package_json_file_with_path_1,
3598+
Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_the_field_type_Colon_module_to_1,
35993599
targetExt,
36003600
combinePaths(scope.packageDirectory, "package.json")));
36013601
}

src/compiler/diagnosticMessages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1509,7 +1509,7 @@
15091509
"category": "Message",
15101510
"code": 1480
15111511
},
1512-
"To convert this file to an ECMAScript module, change its file extension to '{0}', or add `\"type\": \"module\"` to its package.json file with path '{1}'.": {
1512+
"To convert this file to an ECMAScript module, change its file extension to '{0}', or add the field `\"type\": \"module\"` to '{1}'.": {
15131513
"category": "Message",
15141514
"code": 1481
15151515
},

tests/baselines/reference/nodeModulesCJSResolvingToESM1_emptyPackageJson.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
import {} from "./module.mjs";
1414
~~~~~~~~~~~~~~
1515
!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead.
16-
!!! related TS1481 /tsExtension.ts:1:16: To convert this file to an ECMAScript module, change its file extension to '.mts', or add `"type": "module"` to its package.json file with path '/package.json'.
16+
!!! related TS1481 /tsExtension.ts:1:16: To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `"type": "module"` to '/package.json'.
1717

1818
==== /jsExtension.js (1 errors) ====
1919
import {} from "./module.mjs";
2020
~~~~~~~~~~~~~~
2121
!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead.
22-
!!! related TS1481 /jsExtension.js:1:16: To convert this file to an ECMAScript module, change its file extension to '.mjs', or add `"type": "module"` to its package.json file with path '/package.json'.
22+
!!! related TS1481 /jsExtension.js:1:16: To convert this file to an ECMAScript module, change its file extension to '.mjs', or add the field `"type": "module"` to '/package.json'.
2323

2424
==== /ctsExtension.cts (1 errors) ====
2525
import {} from "./module.mjs";

0 commit comments

Comments
 (0)