From 72d70319b48b6a1ee893bfe5ed3b277a1d0504b6 Mon Sep 17 00:00:00 2001 From: Mattia Manzati Date: Tue, 7 Jul 2026 09:05:34 +0200 Subject: [PATCH] Fix effecttest LSP helpers after typescript-go update The typescript-go bump in #299 changed the LSP test client so the untyped SendRequestWorker leaves resp.Result as a raw json.Value. Decode results with RequestInfo.UnmarshalResult instead of type-asserting the typed response structs. Co-Authored-By: Claude Fable 5 --- .changeset/effecttest-lsp-unmarshal.md | 5 +++++ go.work.sum | 1 + .../effecttest/autoimport_style_consistency_test.go | 12 ++++++------ internal/effecttest/inlay_hints_baseline_test.go | 6 +++--- 4 files changed, 15 insertions(+), 9 deletions(-) create mode 100644 .changeset/effecttest-lsp-unmarshal.md diff --git a/.changeset/effecttest-lsp-unmarshal.md b/.changeset/effecttest-lsp-unmarshal.md new file mode 100644 index 00000000..bac34390 --- /dev/null +++ b/.changeset/effecttest-lsp-unmarshal.md @@ -0,0 +1,5 @@ +--- +"@effect/tsgo": patch +--- + +Fix `internal/effecttest` LSP test helpers broken by the `typescript-go` update: the untyped `SendRequestWorker` now returns the response result as a raw `json.Value`, so the inlay hint, diagnostic, and code action helpers decode it via `RequestInfo.UnmarshalResult` instead of type-asserting the typed response struct. diff --git a/go.work.sum b/go.work.sum index 0a54e745..7dde00eb 100644 --- a/go.work.sum +++ b/go.work.sum @@ -6,6 +6,7 @@ golang.org/x/crypto v0.48.0/go.mod h1:r0kV5h3qnFPlQnBSrULhlsRfryS2pmewsg+XfMgkVo golang.org/x/crypto v0.49.0/go.mod h1:ErX4dUh2UM+CFYiXZRTcMpEcN8b/1gxEuv3nODoYtCA= golang.org/x/crypto v0.50.0/go.mod h1:3muZ7vA7PBCE6xgPX7nkzzjiUq87kRItoJQM1Yo8S+Q= golang.org/x/crypto v0.51.0/go.mod h1:8AdwkbraGNABw2kOX6YFPs3WM22XqI4EXEd8g+x7Oc8= +golang.org/x/crypto v0.53.0/go.mod h1:DNLU434OwVakk9PzuwV8w62mAJpRJL3vsgcfp4Qnsio= golang.org/x/mod v0.32.0/go.mod h1:SgipZ/3h2Ci89DlEtEXWUk/HteuRin+HHhN+WbNhguU= golang.org/x/mod v0.33.0/go.mod h1:swjeQEj+6r7fODbD2cqrnje9PnziFuw4bmLbBZFrQ5w= golang.org/x/mod v0.34.0/go.mod h1:ykgH52iCZe79kzLLMhyCUzhMci+nQj+0XkbXpNYtVjY= diff --git a/internal/effecttest/autoimport_style_consistency_test.go b/internal/effecttest/autoimport_style_consistency_test.go index b3be4a0b..0d9fda84 100644 --- a/internal/effecttest/autoimport_style_consistency_test.go +++ b/internal/effecttest/autoimport_style_consistency_test.go @@ -130,9 +130,9 @@ func verifyImportFixContentsUnordered(t *testing.T, f *fourslash.FourslashTest, if !ok { t.Fatal("diagnostic request failed") } - diagResult, ok := diagResp.Result.(lsproto.DocumentDiagnosticResponse) - if !ok { - t.Fatal("unexpected diagnostic response type") + diagResult, err := lsproto.TextDocumentDiagnosticInfo.UnmarshalResult(diagResp.Result) + if err != nil { + t.Fatalf("failed to unmarshal diagnostic response: %v", err) } var diagnostics []*lsproto.Diagnostic @@ -151,9 +151,9 @@ func verifyImportFixContentsUnordered(t *testing.T, f *fourslash.FourslashTest, if !ok { t.Fatal("code action request failed") } - actionResult, ok := actionResp.Result.(lsproto.CodeActionResponse) - if !ok { - t.Fatal("unexpected code action response type") + actionResult, err := lsproto.TextDocumentCodeActionInfo.UnmarshalResult(actionResp.Result) + if err != nil { + t.Fatalf("failed to unmarshal code action response: %v", err) } var actual []string diff --git a/internal/effecttest/inlay_hints_baseline_test.go b/internal/effecttest/inlay_hints_baseline_test.go index 0c40c3fe..f579d15e 100644 --- a/internal/effecttest/inlay_hints_baseline_test.go +++ b/internal/effecttest/inlay_hints_baseline_test.go @@ -56,9 +56,9 @@ func verifyLocalBaselineInlayHints(t *testing.T, f *fourslash.FourslashTest, tes t.Fatalf("%s request returned error: %s", lsproto.MethodTextDocumentInlayHint, resp.Error.String()) } - result, ok := resp.Result.(lsproto.InlayHintResponse) - if !ok { - t.Fatalf("Unexpected %s response type: %T", lsproto.MethodTextDocumentInlayHint, resp.Result) + result, err := lsproto.TextDocumentInlayHintInfo.UnmarshalResult(resp.Result) + if err != nil { + t.Fatalf("Failed to unmarshal %s response: %v", lsproto.MethodTextDocumentInlayHint, err) } actual := formatInlayHintBaseline(t, fileContent, result)