Skip to content

Commit bca9518

Browse files
authored
Don't error on referenced project's noEmit if program has empty files (#1614)
1 parent 3f675f1 commit bca9518

File tree

3 files changed

+54
-1
lines changed

3 files changed

+54
-1
lines changed

internal/compiler/program.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,7 @@ func (p *Program) verifyProjectReferences() {
862862
}
863863
refOptions := config.CompilerOptions()
864864
if !refOptions.Composite.IsTrue() || refOptions.NoEmit.IsTrue() {
865-
if len(config.FileNames()) > 0 {
865+
if len(parent.FileNames()) > 0 {
866866
if !refOptions.Composite.IsTrue() {
867867
createDiagnosticForReference(parent, index, diagnostics.Referenced_project_0_must_have_setting_composite_Colon_true, ref.Path)
868868
}

internal/execute/tsc_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,30 @@ func TestTscCommandline(t *testing.T) {
122122
subScenario: "Parse watch interval option without tsconfig.json",
123123
commandLineArgs: []string{"-w", "--watchInterval", "1000"},
124124
},
125+
{
126+
subScenario: "Config with references and empty file and refers to config with noEmit",
127+
files: FileMap{
128+
"/home/src/workspaces/project/tsconfig.json": stringtestutil.Dedent(`{
129+
"files": [],
130+
"references": [
131+
{
132+
"path": "./packages/pkg1"
133+
},
134+
],
135+
}`),
136+
"/home/src/workspaces/project/packages/pkg1/tsconfig.json": stringtestutil.Dedent(`{
137+
"compilerOptions": {
138+
"composite": true,
139+
"noEmit": true
140+
},
141+
"files": [
142+
"./index.ts",
143+
],
144+
}`),
145+
"/home/src/workspaces/project/packages/pkg1/index.ts": `export const a = 1;`,
146+
},
147+
commandLineArgs: []string{"-p", "."},
148+
},
125149
}
126150

127151
for _, testCase := range testCases {
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
currentDirectory::/home/src/workspaces/project
2+
useCaseSensitiveFileNames::true
3+
Input::
4+
//// [/home/src/workspaces/project/packages/pkg1/index.ts] *new*
5+
export const a = 1;
6+
//// [/home/src/workspaces/project/packages/pkg1/tsconfig.json] *new*
7+
{
8+
"compilerOptions": {
9+
"composite": true,
10+
"noEmit": true
11+
},
12+
"files": [
13+
"./index.ts",
14+
],
15+
}
16+
//// [/home/src/workspaces/project/tsconfig.json] *new*
17+
{
18+
"files": [],
19+
"references": [
20+
{
21+
"path": "./packages/pkg1"
22+
},
23+
],
24+
}
25+
26+
tsgo -p .
27+
ExitStatus:: Success
28+
Output::
29+

0 commit comments

Comments
 (0)