Open ericmorand opened 6 months ago
While investigating the issue, I stumbled upon a very strange part of the code that seems to handle non-yet discovered files but always ends up throwing an error:
if (!parsedOptions.fileNames.includes(fileName)) {
// Discovered new file that was not known when originally parsing the TypeScript config
parsedOptions.fileNames.push(fileName);
}
There, the newly discovered file is added to parsedOptions.fileNames
but since it was never compiled by the TypeScript program, it is missing from emittedFiles
or ts cache, and ends being considered by Rollup as non handled which triggers an error.
What is the rational that drives this part of the code? Can someone guide me to the test that covers this part of the code?
Expected Behavior
In the reproduction repository, we find 3 TS files:
src/index.ts
, the entry pointsrc/valid.ts
, imported by the entry pointsrc/invalid.ts
, containing non valid TypeScript syntax and imported by neithersrc/index.ts
orsrc/valid.ts
When executing rollup on
src/index.ts
, the build should be successful since thesrc/invalid.ts
file is not imported.Actual Behavior
The build is unsuccessful, and the error suggests that
src/invalid.ts
is syntax-checked by the plugin even though it is not part of the dependency graph of the entry point:Additional Information
Note that the behaviour of
tsc
is correct in that regard:No error is emitted and
src/index.ts
andsrc/valid.ts
are successfully compiled.So the error is coming from the plugin, not from the TypeScript compiler.