From fd6b6d68d6efde54a31d0c97376e54ab26fb582f Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Wed, 20 Aug 2025 13:42:03 -0700 Subject: [PATCH 1/2] don't error on referenced project's noEmit if program has empty files --- internal/compiler/program.go | 2 +- internal/execute/tsc_test.go | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/internal/compiler/program.go b/internal/compiler/program.go index e801aa0021..4f0f201134 100644 --- a/internal/compiler/program.go +++ b/internal/compiler/program.go @@ -862,7 +862,7 @@ func (p *Program) verifyProjectReferences() { } refOptions := config.CompilerOptions() if !refOptions.Composite.IsTrue() || refOptions.NoEmit.IsTrue() { - if len(config.FileNames()) > 0 { + if len(parent.FileNames()) > 0 { if !refOptions.Composite.IsTrue() { createDiagnosticForReference(parent, index, diagnostics.Referenced_project_0_must_have_setting_composite_Colon_true, ref.Path) } diff --git a/internal/execute/tsc_test.go b/internal/execute/tsc_test.go index 8b9f56d242..85ad87e4af 100644 --- a/internal/execute/tsc_test.go +++ b/internal/execute/tsc_test.go @@ -122,6 +122,30 @@ func TestTscCommandline(t *testing.T) { subScenario: "Parse watch interval option without tsconfig.json", commandLineArgs: []string{"-w", "--watchInterval", "1000"}, }, + { + subScenario: "Config with references and empty file and refers to config with noEmit", + files: FileMap{ + "/home/src/workspaces/project/tsconfig.json": stringtestutil.Dedent(`{ + "files": [], + "references": [ + { + "path": "./packages/pkg1" + }, + ], + }`), + "/home/src/workspaces/project/packages/pkg1/tsconfig.json": stringtestutil.Dedent(`{ + "compilerOptions": { + "composite": true, + "noEmit": true + }, + "files": [ + "./index.ts", + ], + }`), + "/home/src/workspaces/project/packages/pkg1/index.ts": `export const a = 1;`, + }, + commandLineArgs: []string{"-p", "."}, + }, } for _, testCase := range testCases { From e0824d2ee89d4e7239012f5733d6d74e5e711cab Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Wed, 20 Aug 2025 14:27:54 -0700 Subject: [PATCH 2/2] add baseline --- ...y-file-and-refers-to-config-with-noEmit.js | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 testdata/baselines/reference/tsc/commandLine/Config-with-references-and-empty-file-and-refers-to-config-with-noEmit.js diff --git a/testdata/baselines/reference/tsc/commandLine/Config-with-references-and-empty-file-and-refers-to-config-with-noEmit.js b/testdata/baselines/reference/tsc/commandLine/Config-with-references-and-empty-file-and-refers-to-config-with-noEmit.js new file mode 100644 index 0000000000..ae2aa8ea3d --- /dev/null +++ b/testdata/baselines/reference/tsc/commandLine/Config-with-references-and-empty-file-and-refers-to-config-with-noEmit.js @@ -0,0 +1,29 @@ +currentDirectory::/home/src/workspaces/project +useCaseSensitiveFileNames::true +Input:: +//// [/home/src/workspaces/project/packages/pkg1/index.ts] *new* +export const a = 1; +//// [/home/src/workspaces/project/packages/pkg1/tsconfig.json] *new* +{ + "compilerOptions": { + "composite": true, + "noEmit": true + }, + "files": [ + "./index.ts", + ], + } +//// [/home/src/workspaces/project/tsconfig.json] *new* +{ + "files": [], + "references": [ + { + "path": "./packages/pkg1" + }, + ], + } + +tsgo -p . +ExitStatus:: Success +Output:: +