From 53fa59cd1850cee5e8865f306c7b378da66799e7 Mon Sep 17 00:00:00 2001 From: Mattia Manzati Date: Fri, 26 Jun 2026 09:11:57 +0200 Subject: [PATCH 1/2] chore: update typescript-go and sourcemap shim --- .changeset/add-sourcemap-shim.md | 5 +++ _patches/028-api-effect-diagnostics.patch | 27 +++++++++-------- _tools/gen_shims/main.go | 1 + go.mod | 2 ++ go.work | 1 + shim/api/shim.go | 3 ++ shim/project/shim.go | 1 + shim/sourcemap/go.mod | 5 +++ shim/sourcemap/shim.go | 37 +++++++++++++++++++++++ typescript-go | 2 +- 10 files changed, 71 insertions(+), 13 deletions(-) create mode 100644 .changeset/add-sourcemap-shim.md create mode 100644 shim/sourcemap/go.mod create mode 100644 shim/sourcemap/shim.go diff --git a/.changeset/add-sourcemap-shim.md b/.changeset/add-sourcemap-shim.md new file mode 100644 index 00000000..7da48bfb --- /dev/null +++ b/.changeset/add-sourcemap-shim.md @@ -0,0 +1,5 @@ +--- +"@effect/tsgo": minor +--- + +Update TypeScript-Go and expose the internal sourcemap package through generated shims. diff --git a/_patches/028-api-effect-diagnostics.patch b/_patches/028-api-effect-diagnostics.patch index 5e124d21..c71d471f 100644 --- a/_patches/028-api-effect-diagnostics.patch +++ b/_patches/028-api-effect-diagnostics.patch @@ -9,23 +9,23 @@ diff --git a/internal/api/proto.go b/internal/api/proto.go "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/checker" "github.com/microsoft/typescript-go/internal/core" -@@ -156,6 +157,7 @@ const ( - // Diagnostic methods +@@ -142,6 +143,7 @@ const ( MethodGetSyntacticDiagnostics Method = "getSyntacticDiagnostics" + MethodGetBindDiagnostics Method = "getBindDiagnostics" MethodGetSemanticDiagnostics Method = "getSemanticDiagnostics" + MethodGetEffectDiagnostics Method = "getEffectDiagnostics" MethodGetSuggestionDiagnostics Method = "getSuggestionDiagnostics" MethodGetDeclarationDiagnostics Method = "getDeclarationDiagnostics" - MethodGetConfigFileParsingDiagnostics Method = "getConfigFileParsingDiagnostics" -@@ -357,6 +359,7 @@ var unmarshalers = map[Method]func([]byte) (any, error){ - MethodGetESSymbolType: unmarshallerFor[GetIntrinsicTypeParams], + MethodGetProgramDiagnostics Method = "getProgramDiagnostics" +@@ -415,6 +417,7 @@ var unmarshalers = map[Method]func([]byte) (any, error){ MethodGetSyntacticDiagnostics: unmarshallerFor[GetDiagnosticsParams], + MethodGetBindDiagnostics: unmarshallerFor[GetDiagnosticsParams], MethodGetSemanticDiagnostics: unmarshallerFor[GetDiagnosticsParams], + MethodGetEffectDiagnostics: unmarshallerFor[GetEffectDiagnosticsParams], MethodGetSuggestionDiagnostics: unmarshallerFor[GetDiagnosticsParams], MethodGetDeclarationDiagnostics: unmarshallerFor[GetDiagnosticsParams], - MethodGetConfigFileParsingDiagnostics: unmarshallerFor[GetProjectDiagnosticsParams], -@@ -829,6 +832,15 @@ type GetDiagnosticsParams struct { + MethodGetProgramDiagnostics: unmarshallerFor[GetProjectDiagnosticsParams], +@@ -994,6 +997,15 @@ type GetDiagnosticsParams struct { File *DocumentIdentifier `json:"file,omitempty"` } @@ -44,7 +44,7 @@ diff --git a/internal/api/proto.go b/internal/api/proto.go diff --git a/internal/api/session.go b/internal/api/session.go --- a/internal/api/session.go +++ b/internal/api/session.go -@@ -7,6 +7,7 @@ import ( +@@ -9,6 +9,7 @@ import ( "sync" "sync/atomic" @@ -52,7 +52,7 @@ diff --git a/internal/api/session.go b/internal/api/session.go "github.com/microsoft/typescript-go/internal/api/encoder" "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/astnav" -@@ -21,6 +22,15 @@ import ( +@@ -27,6 +28,15 @@ import ( "github.com/microsoft/typescript-go/internal/tspath" ) @@ -68,8 +68,8 @@ diff --git a/internal/api/session.go b/internal/api/session.go var sessionIDCounter atomic.Uint64 // snapshotData holds the per-snapshot state including the snapshot itself -@@ -459,6 +469,8 @@ func (s *Session) HandleRequest(ctx context.Context, method string, params json. - return s.handleGetSyntacticDiagnostics(ctx, parsed.(*GetDiagnosticsParams)) +@@ -675,6 +685,8 @@ func (s *Session) HandleRequest(ctx context.Context, method string, params json. + return s.handleGetBindDiagnostics(ctx, parsed.(*GetDiagnosticsParams)) case string(MethodGetSemanticDiagnostics): return s.handleGetSemanticDiagnostics(ctx, parsed.(*GetDiagnosticsParams)) + case string(MethodGetEffectDiagnostics): @@ -77,7 +77,7 @@ diff --git a/internal/api/session.go b/internal/api/session.go case string(MethodGetSuggestionDiagnostics): return s.handleGetSuggestionDiagnostics(ctx, parsed.(*GetDiagnosticsParams)) case string(MethodGetDeclarationDiagnostics): -@@ -2169,4 +2181,38 @@ func (s *Session) handleGetSemanticDiagnostics(ctx context.Context, params *GetD +@@ -2484,6 +2496,41 @@ func (s *Session) handleGetSemanticDiagnostics(ctx context.Context, params *GetD return NewDiagnosticResponses(diags), nil } @@ -87,6 +87,7 @@ diff --git a/internal/api/session.go b/internal/api/session.go + return nil, fmt.Errorf("getEffectDiagnostics callback is not registered") + } + ++ ctx = core.WithCheckerLifetime(ctx, core.CheckerLifetimeDiagnostics) + sd, err := s.getSnapshotData(params.Snapshot) + if err != nil { + return nil, err @@ -116,3 +117,5 @@ diff --git a/internal/api/session.go b/internal/api/session.go +} + // handleGetSuggestionDiagnostics returns suggestion diagnostics for a file or all files. + func (s *Session) handleGetSuggestionDiagnostics(ctx context.Context, params *GetDiagnosticsParams) ([]*DiagnosticResponse, error) { + ctx = core.WithCheckerLifetime(ctx, core.CheckerLifetimeDiagnostics) diff --git a/_tools/gen_shims/main.go b/_tools/gen_shims/main.go index c18969a2..d0b1c6af 100644 --- a/_tools/gen_shims/main.go +++ b/_tools/gen_shims/main.go @@ -75,6 +75,7 @@ func main() { "project/logging", "repo", "scanner", + "sourcemap", "testrunner", "testutil", "testutil/lsptestutil", diff --git a/go.mod b/go.mod index 7eaec22b..2010139e 100644 --- a/go.mod +++ b/go.mod @@ -31,6 +31,7 @@ replace ( github.com/microsoft/typescript-go/shim/project/logging => ./shim/project/logging github.com/microsoft/typescript-go/shim/repo => ./shim/repo github.com/microsoft/typescript-go/shim/scanner => ./shim/scanner + github.com/microsoft/typescript-go/shim/sourcemap => ./shim/sourcemap github.com/microsoft/typescript-go/shim/testrunner => ./shim/testrunner github.com/microsoft/typescript-go/shim/testutil => ./shim/testutil github.com/microsoft/typescript-go/shim/testutil/baseline => ./shim/testutil/baseline @@ -69,6 +70,7 @@ require ( github.com/microsoft/typescript-go/shim/parser v0.0.0-00010101000000-000000000000 github.com/microsoft/typescript-go/shim/project/logging v0.0.0-00010101000000-000000000000 github.com/microsoft/typescript-go/shim/scanner v0.0.0-00010101000000-000000000000 + github.com/microsoft/typescript-go/shim/sourcemap v0.0.0-00010101000000-000000000000 github.com/microsoft/typescript-go/shim/testutil/baseline v0.0.0-00010101000000-000000000000 github.com/microsoft/typescript-go/shim/testutil/harnessutil v0.0.0-00010101000000-000000000000 github.com/microsoft/typescript-go/shim/tsoptions v0.0.0-00010101000000-000000000000 diff --git a/go.work b/go.work index 844412a7..b813f4e6 100644 --- a/go.work +++ b/go.work @@ -29,6 +29,7 @@ use ( ./shim/project/logging ./shim/repo ./shim/scanner + ./shim/sourcemap ./shim/testrunner ./shim/testutil ./shim/testutil/baseline diff --git a/shim/api/shim.go b/shim/api/shim.go index 215c9ba8..2e266e7b 100644 --- a/shim/api/shim.go +++ b/shim/api/shim.go @@ -88,6 +88,7 @@ const MethodGetBaseTypeOfLiteralType = api.MethodGetBaseTypeOfLiteralType const MethodGetBaseTypeOfType = api.MethodGetBaseTypeOfType const MethodGetBaseTypes = api.MethodGetBaseTypes const MethodGetBigIntType = api.MethodGetBigIntType +const MethodGetBindDiagnostics = api.MethodGetBindDiagnostics const MethodGetBooleanType = api.MethodGetBooleanType const MethodGetCheckTypeOfType = api.MethodGetCheckTypeOfType const MethodGetCompletionsAtPosition = api.MethodGetCompletionsAtPosition @@ -104,6 +105,7 @@ const MethodGetExportSymbolOfSymbol = api.MethodGetExportSymbolOfSymbol const MethodGetExportsOfSymbol = api.MethodGetExportsOfSymbol const MethodGetExtendsTypeOfType = api.MethodGetExtendsTypeOfType const MethodGetFreshTypeOfType = api.MethodGetFreshTypeOfType +const MethodGetGlobalDiagnostics = api.MethodGetGlobalDiagnostics const MethodGetIndexInfosOfType = api.MethodGetIndexInfosOfType const MethodGetIndexTypeOfType = api.MethodGetIndexTypeOfType const MethodGetLocalTypeParametersOfType = api.MethodGetLocalTypeParametersOfType @@ -117,6 +119,7 @@ const MethodGetOuterTypeParametersOfType = api.MethodGetOuterTypeParametersOfTyp const MethodGetParameterType = api.MethodGetParameterType const MethodGetParametersOfSignature = api.MethodGetParametersOfSignature const MethodGetParentOfSymbol = api.MethodGetParentOfSymbol +const MethodGetProgramDiagnostics = api.MethodGetProgramDiagnostics const MethodGetPropertiesOfType = api.MethodGetPropertiesOfType const MethodGetReferencedSymbolsForNode = api.MethodGetReferencedSymbolsForNode const MethodGetReferencesToSymbolInFile = api.MethodGetReferencesToSymbolInFile diff --git a/shim/project/shim.go b/shim/project/shim.go index e58aae45..8ae599c5 100644 --- a/shim/project/shim.go +++ b/shim/project/shim.go @@ -14,6 +14,7 @@ import "github.com/zeebo/xxh3" import _ "unsafe" type APISnapshotRequest = project.APISnapshotRequest +type APIState = project.APIState type ATAStateChange = project.ATAStateChange type CheckerPoolOptions = project.CheckerPoolOptions type Client = project.Client diff --git a/shim/sourcemap/go.mod b/shim/sourcemap/go.mod new file mode 100644 index 00000000..a338278d --- /dev/null +++ b/shim/sourcemap/go.mod @@ -0,0 +1,5 @@ +module github.com/microsoft/typescript-go/shim/sourcemap + +go 1.26 + +require github.com/microsoft/typescript-go v0.0.0 diff --git a/shim/sourcemap/shim.go b/shim/sourcemap/shim.go new file mode 100644 index 00000000..36dd1cc5 --- /dev/null +++ b/shim/sourcemap/shim.go @@ -0,0 +1,37 @@ + +// Code generated by _tools/gen_shims. DO NOT EDIT. + +package sourcemap + +import "github.com/microsoft/typescript-go/internal/core" +import "github.com/microsoft/typescript-go/internal/sourcemap" +import "github.com/microsoft/typescript-go/internal/tspath" +import _ "unsafe" + +//go:linkname CreateECMALineInfo github.com/microsoft/typescript-go/internal/sourcemap.CreateECMALineInfo +func CreateECMALineInfo(text string, lineStarts core.ECMALineStarts) *sourcemap.ECMALineInfo +//go:linkname DecodeMappings github.com/microsoft/typescript-go/internal/sourcemap.DecodeMappings +func DecodeMappings(mappings string) *sourcemap.MappingsDecoder +type DocumentPosition = sourcemap.DocumentPosition +type DocumentPositionMapper = sourcemap.DocumentPositionMapper +type ECMALineInfo = sourcemap.ECMALineInfo +type Generator = sourcemap.Generator +//go:linkname GetDocumentPositionMapper github.com/microsoft/typescript-go/internal/sourcemap.GetDocumentPositionMapper +func GetDocumentPositionMapper(host sourcemap.Host, generatedFileName string) *sourcemap.DocumentPositionMapper +type Host = sourcemap.Host +type MappedPosition = sourcemap.MappedPosition +type Mapping = sourcemap.Mapping +type MappingsDecoder = sourcemap.MappingsDecoder +const MissingLineOrColumn = sourcemap.MissingLineOrColumn +const MissingName = sourcemap.MissingName +const MissingSource = sourcemap.MissingSource +const MissingUTF16Column = sourcemap.MissingUTF16Column +type NameIndex = sourcemap.NameIndex +//go:linkname NewGenerator github.com/microsoft/typescript-go/internal/sourcemap.NewGenerator +func NewGenerator(file string, sourceRoot string, sourcesDirectoryPath string, options tspath.ComparePathsOptions) *sourcemap.Generator +type RawSourceMap = sourcemap.RawSourceMap +type Source = sourcemap.Source +type SourceIndex = sourcemap.SourceIndex +type SourceMappedPosition = sourcemap.SourceMappedPosition +//go:linkname TryGetSourceMappingURL github.com/microsoft/typescript-go/internal/sourcemap.TryGetSourceMappingURL +func TryGetSourceMappingURL(lineInfo *sourcemap.ECMALineInfo) string diff --git a/typescript-go b/typescript-go index 9415bebd..6d68dd66 160000 --- a/typescript-go +++ b/typescript-go @@ -1 +1 @@ -Subproject commit 9415bebdeb9e69997846d2a2844c78f439ff22f1 +Subproject commit 6d68dd661d656b030149a703b6eeafffe46ee578 From 35151dbc405b4bc3def6a0a69548db16c73afe53 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 26 Jun 2026 08:08:04 +0000 Subject: [PATCH 2/2] Refresh flake vendor hash --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 76619d77..5caab87c 100644 --- a/flake.nix +++ b/flake.nix @@ -7,7 +7,7 @@ /* Source of truth: git submodule `typescript-go` commit. Keep in sync via `_tools/update-flake-vendor-hash.sh`. */ typescript-go-src = { - url = "github:microsoft/typescript-go/9415bebdeb9e69997846d2a2844c78f439ff22f1?submodules=1"; + url = "github:microsoft/typescript-go/6d68dd661d656b030149a703b6eeafffe46ee578?submodules=1"; flake = false; }; /* Source of truth: typescript-go's `_submodules/TypeScript` commit.