Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/compiler/program.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
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.

if !refOptions.Composite.IsTrue() {
createDiagnosticForReference(parent, index, diagnostics.Referenced_project_0_must_have_setting_composite_Colon_true, ref.Path)
}
Expand Down
24 changes: 24 additions & 0 deletions internal/execute/tsc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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::

Loading