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
5 changes: 5 additions & 0 deletions .changeset/add-sourcemap-shim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect/tsgo": minor
---

Update TypeScript-Go and expose the internal sourcemap package through generated shims.
27 changes: 15 additions & 12 deletions _patches/028-api-effect-diagnostics.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

Expand All @@ -44,15 +44,15 @@ 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"

+ "github.com/effect-ts/tsgo/etscore"
"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"
)

Expand All @@ -68,16 +68,16 @@ 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):
+ return s.handleGetEffectDiagnostics(ctx, parsed.(*GetEffectDiagnosticsParams))
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
}

Expand All @@ -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
Expand Down Expand Up @@ -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)
1 change: 1 addition & 0 deletions _tools/gen_shims/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func main() {
"project/logging",
"repo",
"scanner",
"sourcemap",
"testrunner",
"testutil",
"testutil/lsptestutil",
Expand Down
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions go.work
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use (
./shim/project/logging
./shim/repo
./shim/scanner
./shim/sourcemap
./shim/testrunner
./shim/testutil
./shim/testutil/baseline
Expand Down
3 changes: 3 additions & 0 deletions shim/api/shim.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions shim/project/shim.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions shim/sourcemap/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/microsoft/typescript-go/shim/sourcemap

go 1.26

require github.com/microsoft/typescript-go v0.0.0
37 changes: 37 additions & 0 deletions shim/sourcemap/shim.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion typescript-go
Submodule typescript-go updated 77 files
+182 −63 _packages/native-preview/src/api/async/api.ts
+34 −0 _packages/native-preview/src/api/node/node.generated.ts
+8 −0 _packages/native-preview/src/api/node/node.ts
+0 −97 _packages/native-preview/src/api/objectRegistry.ts
+46 −1 _packages/native-preview/src/api/proto.ts
+182 −63 _packages/native-preview/src/api/sync/api.ts
+8 −0 _packages/native-preview/src/ast/ast.ts
+34 −0 _packages/native-preview/src/ast/factory.generated.ts
+391 −0 _packages/native-preview/test/async/api.test.ts
+391 −0 _packages/native-preview/test/sync/api.test.ts
+186 −0 _packages/native-preview/test/sync/ast.test.ts
+34 −0 _scripts/generate-encoder.ts
+34 −0 _scripts/generate-ts-ast.ts
+29 −4 internal/api/proto.go
+455 −157 internal/api/session.go
+194 −0 internal/api/session_apistate_test.go
+2 −0 internal/ast/ast.go
+3 −1 internal/ast/positionmap.go
+17 −0 internal/ast/positionmap_test.go
+2 −1 internal/checker/checker.go
+30 −6 internal/checker/inference.go
+16 −7 internal/checker/pseudotypenodebuilder.go
+1 −1 internal/execute/tsc/emit.go
+0 −1 internal/parser/parser.go
+25 −0 internal/parser/parser_test.go
+11 −36 internal/project/api.go
+36 −4 internal/project/projectcollection.go
+164 −88 internal/project/projectcollectionbuilder.go
+3 −1 internal/project/snapshot.go
+9 −13 internal/pseudochecker/lookup.go
+7 −6 internal/pseudochecker/type.go
+4 −17 internal/scanner/scanner.go
+9 −0 internal/stringutil/util.go
+22 −0 internal/stringutil/util_test.go
+6 −1 internal/tsoptions/tsconfigparsing.go
+35 −0 internal/tsoptions/tsconfigparsing_test.go
+26 −26 testdata/baselines/reference/api/encodeSourceFileWithUnicodeEscapes.txt
+90 −0 testdata/baselines/reference/compiler/nestedGenericTypeInference.symbols
+60 −0 testdata/baselines/reference/compiler/nestedGenericTypeInference.types
+70 −0 testdata/baselines/reference/compiler/parametersAliasOverTypeofPreservedAsIsInDeclarations.js
+112 −0 testdata/baselines/reference/compiler/parametersAliasOverTypeofPreservedAsIsInDeclarations.symbols
+101 −0 testdata/baselines/reference/compiler/parametersAliasOverTypeofPreservedAsIsInDeclarations.types
+6 −6 .../baselines/reference/submodule/compiler/declarationsWithRecursiveInternalTypesProduceUniqueTypeParams.types
+1 −141 testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrorsReturnTypes.errors.txt
+5 −6 testdata/baselines/reference/submodule/conformance/assignmentCompatWithGenericCallSignatures2.errors.txt
+25 −0 testdata/baselines/reference/submodule/conformance/assignmentCompatWithGenericCallSignatures2.errors.txt.diff
+6 −6 ...ference/submoduleAccepted/compiler/declarationsWithRecursiveInternalTypesProduceUniqueTypeParams.types.diff
+0 −255 testdata/baselines/reference/submoduleTriaged/compiler/isolatedDeclarationErrorsReturnTypes.errors.txt.diff
+2 −2 testdata/baselines/reference/tsbuild/declarationEmit/reports-dts-generation-errors-with-incremental.js
+4 −4 testdata/baselines/reference/tsbuild/declarationEmit/reports-dts-generation-errors.js
+3 −3 testdata/baselines/reference/tsbuild/resolveJsonModule/files-containing-json-file-non-composite.js
+4 −4 testdata/baselines/reference/tsbuild/resolveJsonModule/files-containing-json-file.js
+3 −3 testdata/baselines/reference/tsbuild/resolveJsonModule/include-and-files-non-composite.js
+4 −4 testdata/baselines/reference/tsbuild/resolveJsonModule/include-and-files.js
+3 −3 ...d/resolveJsonModule/include-of-json-along-with-other-include-and-file-name-matches-ts-file-non-composite.js
+4 −4 ...ference/tsbuild/resolveJsonModule/include-of-json-along-with-other-include-and-file-name-matches-ts-file.js
+3 −3 ...ata/baselines/reference/tsbuild/resolveJsonModule/include-of-json-along-with-other-include-non-composite.js
+4 −4 testdata/baselines/reference/tsbuild/resolveJsonModule/include-of-json-along-with-other-include.js
+3 −3 testdata/baselines/reference/tsbuild/resolveJsonModule/include-only-non-composite.js
+2 −2 testdata/baselines/reference/tsbuild/resolveJsonModule/include-only-with-json-not-in-rootDir-non-composite.js
+3 −3 testdata/baselines/reference/tsbuild/resolveJsonModule/include-only-with-json-not-in-rootDir.js
+2 −2 ...build/resolveJsonModule/include-only-with-json-without-rootDir-but-outside-configDirectory-non-composite.js
+3 −3 ...s/reference/tsbuild/resolveJsonModule/include-only-with-json-without-rootDir-but-outside-configDirectory.js
+2 −2 testdata/baselines/reference/tsbuild/resolveJsonModule/include-only-without-outDir-non-composite.js
+3 −3 testdata/baselines/reference/tsbuild/resolveJsonModule/include-only-without-outDir.js
+4 −4 testdata/baselines/reference/tsbuild/resolveJsonModule/include-only.js
+8 −8 testdata/baselines/reference/tsbuild/resolveJsonModule/sourcemap-non-composite.js
+5 −5 testdata/baselines/reference/tsbuild/resolveJsonModule/sourcemap.js
+2 −2 testdata/baselines/reference/tsbuild/resolveJsonModule/without-outDir-non-composite.js
+3 −3 testdata/baselines/reference/tsbuild/resolveJsonModule/without-outDir.js
+26 −26 testdata/baselines/reference/tsbuild/sample/listEmittedFiles.js
+6 −6 testdata/baselines/reference/tsbuild/sample/when-target-option-changes.js
+2 −2 testdata/baselines/reference/tsc/declarationEmit/reports-dts-generation-errors-with-incremental.js
+4 −4 testdata/baselines/reference/tsc/declarationEmit/reports-dts-generation-errors.js
+0 −1 testdata/submoduleTriaged.txt
+22 −0 testdata/tests/cases/compiler/nestedGenericTypeInference.ts
+28 −0 testdata/tests/cases/compiler/parametersAliasOverTypeofPreservedAsIsInDeclarations.ts
Loading