From cbecf4eb1b39fb6b89d593e38f225786716aa90b Mon Sep 17 00:00:00 2001 From: navya9singh Date: Fri, 27 Mar 2026 10:04:45 -0700 Subject: [PATCH 1/3] fix for a snapshot update without a tsconfig crash --- internal/api/proto.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/api/proto.go b/internal/api/proto.go index bc4595fde8..fc1d04c0d6 100644 --- a/internal/api/proto.go +++ b/internal/api/proto.go @@ -393,11 +393,17 @@ type ProjectResponse struct { } func NewProjectResponse(p *project.Project) *ProjectResponse { + var rootFiles []string + var opts *core.CompilerOptions + if p.CommandLine != nil { + rootFiles = p.CommandLine.FileNames() + opts = p.CommandLine.CompilerOptions() + } return &ProjectResponse{ Id: ProjectHandle(p), ConfigFileName: p.Name(), - RootFiles: p.CommandLine.FileNames(), - CompilerOptions: p.CommandLine.CompilerOptions(), + RootFiles: rootFiles, + CompilerOptions: opts, } } From 2d6114ad3b58dbdd0c30540fe9ab936cda8a35b3 Mon Sep 17 00:00:00 2001 From: navya9singh Date: Fri, 27 Mar 2026 12:29:20 -0700 Subject: [PATCH 2/3] addressing copilot comments --- internal/api/proto.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/api/proto.go b/internal/api/proto.go index fc1d04c0d6..68da823633 100644 --- a/internal/api/proto.go +++ b/internal/api/proto.go @@ -393,7 +393,7 @@ type ProjectResponse struct { } func NewProjectResponse(p *project.Project) *ProjectResponse { - var rootFiles []string + rootFiles := []string{} var opts *core.CompilerOptions if p.CommandLine != nil { rootFiles = p.CommandLine.FileNames() From 061e8049e682ef98f882a5eddc958cf68789409e Mon Sep 17 00:00:00 2001 From: navya9singh Date: Fri, 27 Mar 2026 14:55:45 -0700 Subject: [PATCH 3/3] adding test --- internal/api/proto_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/internal/api/proto_test.go b/internal/api/proto_test.go index 6ed8625e12..44bac19334 100644 --- a/internal/api/proto_test.go +++ b/internal/api/proto_test.go @@ -5,6 +5,7 @@ import ( "github.com/microsoft/typescript-go/internal/api" "github.com/microsoft/typescript-go/internal/json" + "github.com/microsoft/typescript-go/internal/project" "gotest.tools/v3/assert" ) @@ -58,3 +59,12 @@ func TestDocumentIdentifierUnmarshalJSON(t *testing.T) { }) } } + +func TestNewProjectResponse_NilCommandLine(t *testing.T) { + t.Parallel() + p := &project.Project{} + resp := api.NewProjectResponse(p) + assert.Assert(t, resp != nil) + assert.DeepEqual(t, resp.RootFiles, []string{}) + assert.Assert(t, resp.CompilerOptions == nil) +}