mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 04:43:37 -05:00
fix(15230): change the diagnostic message about a non-module file in an --isolatedModules project (#40032)
This commit is contained in:
@@ -659,7 +659,7 @@
|
||||
"category": "Error",
|
||||
"code": 1207
|
||||
},
|
||||
"All files must be modules when the '--isolatedModules' flag is provided.": {
|
||||
"'{0}' cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export {}' statement to make it a module.": {
|
||||
"category": "Error",
|
||||
"code": 1208
|
||||
},
|
||||
|
||||
@@ -3110,7 +3110,8 @@ namespace ts {
|
||||
const firstNonExternalModuleSourceFile = find(files, f => !isExternalModule(f) && !isSourceFileJS(f) && !f.isDeclarationFile && f.scriptKind !== ScriptKind.JSON);
|
||||
if (firstNonExternalModuleSourceFile) {
|
||||
const span = getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile);
|
||||
programDiagnostics.add(createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, Diagnostics.All_files_must_be_modules_when_the_isolatedModules_flag_is_provided));
|
||||
programDiagnostics.add(createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length,
|
||||
Diagnostics._0_cannot_be_compiled_under_isolatedModules_because_it_is_considered_a_global_script_file_Add_an_import_export_or_an_empty_export_statement_to_make_it_a_module, getBaseFileName(firstNonExternalModuleSourceFile.fileName)));
|
||||
}
|
||||
}
|
||||
else if (firstNonAmbientExternalModuleSourceFile && languageVersion < ScriptTarget.ES2015 && options.module === ModuleKind.None) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/compiler/script.ts(1,1): error TS1208: All files must be modules when the '--isolatedModules' flag is provided.
|
||||
tests/cases/compiler/script.ts(1,1): error TS1208: 'script.ts' cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export {}' statement to make it a module.
|
||||
|
||||
|
||||
==== tests/cases/compiler/external.ts (0 errors) ====
|
||||
@@ -16,7 +16,7 @@ tests/cases/compiler/script.ts(1,1): error TS1208: All files must be modules whe
|
||||
==== tests/cases/compiler/script.ts (1 errors) ====
|
||||
class A { }
|
||||
~~~~~
|
||||
!!! error TS1208: All files must be modules when the '--isolatedModules' flag is provided.
|
||||
!!! error TS1208: 'script.ts' cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export {}' statement to make it a module.
|
||||
class B extends A { }
|
||||
|
||||
declare var dec: any;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
tests/cases/compiler/file1.ts(1,1): error TS1208: All files must be modules when the '--isolatedModules' flag is provided.
|
||||
tests/cases/compiler/file1.ts(1,1): error TS1208: 'file1.ts' cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export {}' statement to make it a module.
|
||||
|
||||
|
||||
==== tests/cases/compiler/file1.ts (1 errors) ====
|
||||
var x;
|
||||
~~~
|
||||
!!! error TS1208: All files must be modules when the '--isolatedModules' flag is provided.
|
||||
!!! error TS1208: 'file1.ts' cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export {}' statement to make it a module.
|
||||
@@ -1,6 +1,6 @@
|
||||
error TS5053: Option 'out' cannot be specified with option 'isolatedModules'.
|
||||
tests/cases/compiler/file1.ts(1,1): error TS6131: Cannot compile modules using option 'out' unless the '--module' flag is 'amd' or 'system'.
|
||||
tests/cases/compiler/file2.ts(1,1): error TS1208: All files must be modules when the '--isolatedModules' flag is provided.
|
||||
tests/cases/compiler/file2.ts(1,1): error TS1208: 'file2.ts' cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export {}' statement to make it a module.
|
||||
|
||||
|
||||
!!! error TS5053: Option 'out' cannot be specified with option 'isolatedModules'.
|
||||
@@ -11,4 +11,4 @@ tests/cases/compiler/file2.ts(1,1): error TS1208: All files must be modules when
|
||||
==== tests/cases/compiler/file2.ts (1 errors) ====
|
||||
var y;
|
||||
~~~
|
||||
!!! error TS1208: All files must be modules when the '--isolatedModules' flag is provided.
|
||||
!!! error TS1208: 'file2.ts' cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export {}' statement to make it a module.
|
||||
@@ -1,9 +1,9 @@
|
||||
tests/cases/compiler/isolatedModulesPlainFile-AMD.ts(1,1): error TS1208: All files must be modules when the '--isolatedModules' flag is provided.
|
||||
tests/cases/compiler/isolatedModulesPlainFile-AMD.ts(1,1): error TS1208: 'isolatedModulesPlainFile-AMD.ts' cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export {}' statement to make it a module.
|
||||
|
||||
|
||||
==== tests/cases/compiler/isolatedModulesPlainFile-AMD.ts (1 errors) ====
|
||||
declare function run(a: number): void;
|
||||
~~~~~~~
|
||||
!!! error TS1208: All files must be modules when the '--isolatedModules' flag is provided.
|
||||
!!! error TS1208: 'isolatedModulesPlainFile-AMD.ts' cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export {}' statement to make it a module.
|
||||
run(1);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
tests/cases/compiler/isolatedModulesPlainFile-CommonJS.ts(1,1): error TS1208: All files must be modules when the '--isolatedModules' flag is provided.
|
||||
tests/cases/compiler/isolatedModulesPlainFile-CommonJS.ts(1,1): error TS1208: 'isolatedModulesPlainFile-CommonJS.ts' cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export {}' statement to make it a module.
|
||||
|
||||
|
||||
==== tests/cases/compiler/isolatedModulesPlainFile-CommonJS.ts (1 errors) ====
|
||||
declare function run(a: number): void;
|
||||
~~~~~~~
|
||||
!!! error TS1208: All files must be modules when the '--isolatedModules' flag is provided.
|
||||
!!! error TS1208: 'isolatedModulesPlainFile-CommonJS.ts' cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export {}' statement to make it a module.
|
||||
run(1);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
tests/cases/compiler/isolatedModulesPlainFile-ES6.ts(1,1): error TS1208: All files must be modules when the '--isolatedModules' flag is provided.
|
||||
tests/cases/compiler/isolatedModulesPlainFile-ES6.ts(1,1): error TS1208: 'isolatedModulesPlainFile-ES6.ts' cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export {}' statement to make it a module.
|
||||
|
||||
|
||||
==== tests/cases/compiler/isolatedModulesPlainFile-ES6.ts (1 errors) ====
|
||||
declare function run(a: number): void;
|
||||
~~~~~~~
|
||||
!!! error TS1208: All files must be modules when the '--isolatedModules' flag is provided.
|
||||
!!! error TS1208: 'isolatedModulesPlainFile-ES6.ts' cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export {}' statement to make it a module.
|
||||
run(1);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
tests/cases/compiler/isolatedModulesPlainFile-System.ts(1,1): error TS1208: All files must be modules when the '--isolatedModules' flag is provided.
|
||||
tests/cases/compiler/isolatedModulesPlainFile-System.ts(1,1): error TS1208: 'isolatedModulesPlainFile-System.ts' cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export {}' statement to make it a module.
|
||||
|
||||
|
||||
==== tests/cases/compiler/isolatedModulesPlainFile-System.ts (1 errors) ====
|
||||
declare function run(a: number): void;
|
||||
~~~~~~~
|
||||
!!! error TS1208: All files must be modules when the '--isolatedModules' flag is provided.
|
||||
!!! error TS1208: 'isolatedModulesPlainFile-System.ts' cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export {}' statement to make it a module.
|
||||
run(1);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
tests/cases/compiler/isolatedModulesPlainFile-UMD.ts(1,1): error TS1208: All files must be modules when the '--isolatedModules' flag is provided.
|
||||
tests/cases/compiler/isolatedModulesPlainFile-UMD.ts(1,1): error TS1208: 'isolatedModulesPlainFile-UMD.ts' cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export {}' statement to make it a module.
|
||||
|
||||
|
||||
==== tests/cases/compiler/isolatedModulesPlainFile-UMD.ts (1 errors) ====
|
||||
declare function run(a: number): void;
|
||||
~~~~~~~
|
||||
!!! error TS1208: All files must be modules when the '--isolatedModules' flag is provided.
|
||||
!!! error TS1208: 'isolatedModulesPlainFile-UMD.ts' cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export {}' statement to make it a module.
|
||||
run(1);
|
||||
|
||||
@@ -37,7 +37,7 @@ Output::
|
||||
[[90m12:00:23 AM[0m] Starting compilation in watch mode...
|
||||
|
||||
|
||||
[96ma/b/globalFile3.ts[0m:[93m1[0m:[93m1[0m - [91merror[0m[90m TS1208: [0mAll files must be modules when the '--isolatedModules' flag is provided.
|
||||
[96ma/b/globalFile3.ts[0m:[93m1[0m:[93m1[0m - [91merror[0m[90m TS1208: [0m'globalFile3.ts' cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export {}' statement to make it a module.
|
||||
|
||||
[7m1[0m interface GlobalFoo { age: number }
|
||||
[7m [0m [91m~~~~~~~~~[0m
|
||||
@@ -136,7 +136,7 @@ Output::
|
||||
[[90m12:00:38 AM[0m] File change detected. Starting incremental compilation...
|
||||
|
||||
|
||||
[96ma/b/globalFile3.ts[0m:[93m1[0m:[93m1[0m - [91merror[0m[90m TS1208: [0mAll files must be modules when the '--isolatedModules' flag is provided.
|
||||
[96ma/b/globalFile3.ts[0m:[93m1[0m:[93m1[0m - [91merror[0m[90m TS1208: [0m'globalFile3.ts' cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export {}' statement to make it a module.
|
||||
|
||||
[7m1[0m interface GlobalFoo { age: number }
|
||||
[7m [0m [91m~~~~~~~~~[0m
|
||||
|
||||
Reference in New Issue
Block a user