From f4a877df9e297c30d018fd1a3a4d1fb9482ddaba Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 11 Jun 2026 00:53:55 +0000 Subject: [PATCH 1/2] Initial plan From 2a242f7337324d6aa76020408dce4d768a376df4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 11 Jun 2026 01:09:48 +0000 Subject: [PATCH 2/2] Fix fatal error when project reference path/circular have unexpected types Use safe type assertions (comma-ok idiom) in parseProjectReference instead of bare type assertions that panic when values are not string/bool. Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com> --- internal/tsoptions/parsinghelpers.go | 12 ++++++++---- .../compiler/projectReferenceNonStringPath.js | 8 ++++++++ .../compiler/projectReferenceNonStringPath.symbols | 6 ++++++ .../compiler/projectReferenceNonStringPath.types | 7 +++++++ .../cases/compiler/projectReferenceNonStringPath.ts | 7 +++++++ 5 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 testdata/baselines/reference/compiler/projectReferenceNonStringPath.js create mode 100644 testdata/baselines/reference/compiler/projectReferenceNonStringPath.symbols create mode 100644 testdata/baselines/reference/compiler/projectReferenceNonStringPath.types create mode 100644 testdata/tests/cases/compiler/projectReferenceNonStringPath.ts diff --git a/internal/tsoptions/parsinghelpers.go b/internal/tsoptions/parsinghelpers.go index 47a4d476bf4..b540e47a044 100644 --- a/internal/tsoptions/parsinghelpers.go +++ b/internal/tsoptions/parsinghelpers.go @@ -74,11 +74,15 @@ func parseProjectReference(json any) []*core.ProjectReference { var result []*core.ProjectReference if v, ok := json.(*collections.OrderedMap[string, any]); ok { var reference core.ProjectReference - if v, ok := v.Get("path"); ok { - reference.Path = v.(string) + if pathValue, ok := v.Get("path"); ok { + if pathStr, ok := pathValue.(string); ok { + reference.Path = pathStr + } } - if v, ok := v.Get("circular"); ok { - reference.Circular = v.(bool) + if circularValue, ok := v.Get("circular"); ok { + if circularBool, ok := circularValue.(bool); ok { + reference.Circular = circularBool + } } result = append(result, &reference) } diff --git a/testdata/baselines/reference/compiler/projectReferenceNonStringPath.js b/testdata/baselines/reference/compiler/projectReferenceNonStringPath.js new file mode 100644 index 00000000000..01e7588beb3 --- /dev/null +++ b/testdata/baselines/reference/compiler/projectReferenceNonStringPath.js @@ -0,0 +1,8 @@ +//// [tests/cases/compiler/projectReferenceNonStringPath.ts] //// + +//// [index.ts] +export const x = 1; + + +//// [index.js] +export const x = 1; diff --git a/testdata/baselines/reference/compiler/projectReferenceNonStringPath.symbols b/testdata/baselines/reference/compiler/projectReferenceNonStringPath.symbols new file mode 100644 index 00000000000..601178d7c4b --- /dev/null +++ b/testdata/baselines/reference/compiler/projectReferenceNonStringPath.symbols @@ -0,0 +1,6 @@ +//// [tests/cases/compiler/projectReferenceNonStringPath.ts] //// + +=== /src/index.ts === +export const x = 1; +>x : Symbol(x, Decl(index.ts, 0, 12)) + diff --git a/testdata/baselines/reference/compiler/projectReferenceNonStringPath.types b/testdata/baselines/reference/compiler/projectReferenceNonStringPath.types new file mode 100644 index 00000000000..802ea8c2608 --- /dev/null +++ b/testdata/baselines/reference/compiler/projectReferenceNonStringPath.types @@ -0,0 +1,7 @@ +//// [tests/cases/compiler/projectReferenceNonStringPath.ts] //// + +=== /src/index.ts === +export const x = 1; +>x : 1 +>1 : 1 + diff --git a/testdata/tests/cases/compiler/projectReferenceNonStringPath.ts b/testdata/tests/cases/compiler/projectReferenceNonStringPath.ts new file mode 100644 index 00000000000..181821407ea --- /dev/null +++ b/testdata/tests/cases/compiler/projectReferenceNonStringPath.ts @@ -0,0 +1,7 @@ +// @filename: /src/tsconfig.json +{ + "references": [{ "path": true }, { "path": "./other", "circular": "yes" }] +} + +// @filename: /src/index.ts +export const x = 1;