Description
Bug Report
When more than one global script file is present within a project using isolatedModules
, only one error is raised for one of the problematic files.
File(1,1): error TS1208: 'File.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.
// No additional errors for File2.ts etc.
This behavior seems different from other errors that are logged when isolatedModules
is enabled. It hides the extent to which a project is incompatible with isolatedModules
.
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about
isolatedModules
💻 Code
The behavior appears intentional in program.ts
. It finds the first global script file and emits one diagnostic.
TypeScript/src/compiler/program.ts
Lines 3512 to 3517 in 7b76416
🙁 Actual behavior
One error of this kind is logged per compile.
🙂 Expected behavior
Log all of the violations, so that the extent of the problem can be assessed easily.
I changed the logic in program.ts
locally to be a for loop that logged each problematic file, and I found this helpful for assessing the effort required to implement isolatedModules
compatibility in an existing codebase.