Skip to content

Conversation

gabritto
Copy link
Member

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 noEmit true (same for having composite false).

@Copilot Copilot AI review requested due to automatic review settings August 20, 2025 20:46
Copy link
Contributor

@Copilot Copilot AI left a 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 {
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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.

@gabritto gabritto added this pull request to the merge queue Aug 21, 2025
Merged via the queue into main with commit bca9518 Aug 21, 2025
22 checks passed
@gabritto gabritto deleted the gabritto/referenceNoEmit branch August 21, 2025 00:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants