-
Notifications
You must be signed in to change notification settings - Fork 735
Don't error on referenced project's noEmit if program has empty files #1614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a bug in the validation of TypeScript project references where the compiler incorrectly errored on referenced projects with noEmit: true or composite: false when the parent project had no files. The fix ensures that these validation errors only occur when the parent project actually contains files to compile.
- Changes the condition to check the parent project's files instead of the referenced project's files
- Adds a test case demonstrating a valid scenario where a parent config with empty files references a project with
noEmit: true
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| internal/compiler/program.go | Fixes the validation logic to check parent project files instead of referenced project files |
| internal/execute/tsc_test.go | Adds test case for valid config reference scenario with empty parent files |
| refOptions := config.CompilerOptions() | ||
| if !refOptions.Composite.IsTrue() || refOptions.NoEmit.IsTrue() { | ||
| if len(config.FileNames()) > 0 { | ||
| if len(parent.FileNames()) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The old code said:
const inputs = parent ? parent.commandLine.fileNames : rootNames;
if (inputs.length) {
I assume parent simply always exists?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to be the case in Corsa: this function starts with ref := parent.ProjectReferences()[index], which would crash if parent is nil.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks. yes with being able to use and store parsedCommandLine in program, we always have parent
I had this in #1484 fixed incorrectly too (was always checking program's file names) so thank you for doing the right fix.
Fixes what seems like a porting bug in checking config references. If a tsconfig has no files (i.e. it's a top-level tsconfig that refers every project entry point in your monorepo), it's ok for a project it references to have
noEmittrue (same for havingcompositefalse).