@ttsc/wasm 0.11.0-dev.20260517
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +125 -0
- package/build/build-wasm.cjs +240 -0
- package/build/pack-prepare.cjs +68 -0
- package/cmd/ttsc-wasm/main.go +130 -0
- package/cmd/ttsc-wasm/main_wasm.go +17 -0
- package/dist/go.mod +54 -0
- package/dist/ttsc.wasm +0 -0
- package/dist/wasm_exec.js +575 -0
- package/go.mod +54 -0
- package/go.sum +26 -0
- package/host/api.go +205 -0
- package/host/doc.go +31 -0
- package/host/host.go +317 -0
- package/host/host_native.go +12 -0
- package/host/plugin.go +59 -0
- package/lib/src/MemFS.d.ts +68 -0
- package/lib/src/MemFS.js +384 -0
- package/lib/src/MemFS.js.map +1 -0
- package/lib/src/api.d.ts +87 -0
- package/lib/src/api.js +20 -0
- package/lib/src/api.js.map +1 -0
- package/lib/src/index.d.ts +6 -0
- package/lib/src/index.js +10 -0
- package/lib/src/index.js.map +1 -0
- package/lib/src/instantiate.d.ts +27 -0
- package/lib/src/instantiate.js +71 -0
- package/lib/src/instantiate.js.map +1 -0
- package/package.json +49 -0
- package/src/MemFS.ts +566 -0
- package/src/api.ts +112 -0
- package/src/index.ts +28 -0
- package/src/instantiate.ts +114 -0
- package/vendor/shim/ast/extra-shim.json +4 -0
- package/vendor/shim/ast/go.mod +5 -0
- package/vendor/shim/ast/lint.go +328 -0
- package/vendor/shim/ast/shim.go +220 -0
- package/vendor/shim/ast/surface.go +685 -0
- package/vendor/shim/bundled/extra-shim.json +1 -0
- package/vendor/shim/bundled/go.mod +5 -0
- package/vendor/shim/bundled/shim.go +23 -0
- package/vendor/shim/checker/extra-shim.json +31 -0
- package/vendor/shim/checker/go.mod +5 -0
- package/vendor/shim/checker/shim.go +174 -0
- package/vendor/shim/compiler/extra-shim.json +4 -0
- package/vendor/shim/compiler/go.mod +5 -0
- package/vendor/shim/compiler/shim.go +65 -0
- package/vendor/shim/core/extra-shim.json +4 -0
- package/vendor/shim/core/go.mod +5 -0
- package/vendor/shim/core/shim.go +29 -0
- package/vendor/shim/diagnosticwriter/go.mod +5 -0
- package/vendor/shim/diagnosticwriter/lint.go +145 -0
- package/vendor/shim/diagnosticwriter/shim.go +29 -0
- package/vendor/shim/lsp/extra-shim.json +4 -0
- package/vendor/shim/lsp/go.mod +16 -0
- package/vendor/shim/lsp/go.sum +26 -0
- package/vendor/shim/lsp/shim.go +42 -0
- package/vendor/shim/parser/extra-shim.json +4 -0
- package/vendor/shim/parser/go.mod +5 -0
- package/vendor/shim/parser/shim.go +61 -0
- package/vendor/shim/printer/go.mod +5 -0
- package/vendor/shim/printer/shim.go +23 -0
- package/vendor/shim/scanner/extra-shim.json +4 -0
- package/vendor/shim/scanner/go.mod +5 -0
- package/vendor/shim/scanner/shim.go +134 -0
- package/vendor/shim/tsoptions/extra-shim.json +4 -0
- package/vendor/shim/tsoptions/go.mod +5 -0
- package/vendor/shim/tsoptions/shim.go +173 -0
- package/vendor/shim/tspath/extra-shim.json +4 -0
- package/vendor/shim/tspath/go.mod +5 -0
- package/vendor/shim/tspath/shim.go +236 -0
- package/vendor/shim/vfs/cachedvfs/extra-shim.json +4 -0
- package/vendor/shim/vfs/cachedvfs/go.mod +5 -0
- package/vendor/shim/vfs/cachedvfs/shim.go +12 -0
- package/vendor/shim/vfs/extra-shim.json +4 -0
- package/vendor/shim/vfs/go.mod +5 -0
- package/vendor/shim/vfs/osvfs/extra-shim.json +4 -0
- package/vendor/shim/vfs/osvfs/go.mod +5 -0
- package/vendor/shim/vfs/osvfs/shim.go +13 -0
- package/vendor/shim/vfs/shim.go +22 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"ExtraMethods":{},"ExtraFields":{}}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Code generated by packages/ttsc/tools/gen_shims. DO NOT EDIT.
|
|
2
|
+
|
|
3
|
+
package bundled
|
|
4
|
+
|
|
5
|
+
import "github.com/microsoft/typescript-go/internal/bundled"
|
|
6
|
+
import "github.com/microsoft/typescript-go/internal/vfs"
|
|
7
|
+
import _ "unsafe"
|
|
8
|
+
|
|
9
|
+
const Embedded = bundled.Embedded
|
|
10
|
+
|
|
11
|
+
//go:linkname IsBundled github.com/microsoft/typescript-go/internal/bundled.IsBundled
|
|
12
|
+
func IsBundled(path string) bool
|
|
13
|
+
|
|
14
|
+
var LibNames = bundled.LibNames
|
|
15
|
+
|
|
16
|
+
//go:linkname LibPath github.com/microsoft/typescript-go/internal/bundled.LibPath
|
|
17
|
+
func LibPath() string
|
|
18
|
+
|
|
19
|
+
//go:linkname TestingLibPath github.com/microsoft/typescript-go/internal/bundled.TestingLibPath
|
|
20
|
+
func TestingLibPath() string
|
|
21
|
+
|
|
22
|
+
//go:linkname WrapFS github.com/microsoft/typescript-go/internal/bundled.WrapFS
|
|
23
|
+
func WrapFS(fs vfs.FS) vfs.FS
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"ExtraMethods": {
|
|
3
|
+
"Checker": [
|
|
4
|
+
"getApparentType",
|
|
5
|
+
"getIndexTypeOfType",
|
|
6
|
+
"getPropertiesOfType",
|
|
7
|
+
"getTypeOfSymbol",
|
|
8
|
+
"getDeclaredTypeOfSymbol",
|
|
9
|
+
"getBaseTypes",
|
|
10
|
+
"getTypeArguments",
|
|
11
|
+
"getIndexInfosOfType",
|
|
12
|
+
"isArrayType",
|
|
13
|
+
"isArrayOrTupleType",
|
|
14
|
+
"isTypeAssignableTo",
|
|
15
|
+
"isReadonlySymbol",
|
|
16
|
+
"getWidenedType",
|
|
17
|
+
"getPropertyNameForKnownSymbolName",
|
|
18
|
+
"getBaseConstraintOfType",
|
|
19
|
+
"getNullableType",
|
|
20
|
+
"getExportsOfModule"
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
"ExtraFields": {
|
|
24
|
+
"Type": [
|
|
25
|
+
"alias"
|
|
26
|
+
],
|
|
27
|
+
"Checker": [
|
|
28
|
+
"globalRegExpType"
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
// gen_shims:hand-maintained
|
|
2
|
+
//
|
|
3
|
+
// This shim file mixes generated re-exports with hand-written `go:linkname`
|
|
4
|
+
// declarations targeting unexported `*Checker` methods that the @ttsc/lint
|
|
5
|
+
// engine relies on. gen_shims detects the marker on the first line and skips
|
|
6
|
+
// this file. Remove the marker only if you are intentionally regenerating and
|
|
7
|
+
// willing to re-add the hand-maintained content.
|
|
8
|
+
|
|
9
|
+
package checker
|
|
10
|
+
|
|
11
|
+
import (
|
|
12
|
+
innerast "github.com/microsoft/typescript-go/internal/ast"
|
|
13
|
+
innerchecker "github.com/microsoft/typescript-go/internal/checker"
|
|
14
|
+
_ "unsafe"
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
type Checker = innerchecker.Checker
|
|
18
|
+
type IndexInfo = innerchecker.IndexInfo
|
|
19
|
+
type Signature = innerchecker.Signature
|
|
20
|
+
type SignatureKind = innerchecker.SignatureKind
|
|
21
|
+
type Type = innerchecker.Type
|
|
22
|
+
type TypeFlags = innerchecker.TypeFlags
|
|
23
|
+
type ObjectFlags = innerchecker.ObjectFlags
|
|
24
|
+
type ElementFlags = innerchecker.ElementFlags
|
|
25
|
+
|
|
26
|
+
const (
|
|
27
|
+
SignatureKindCall = innerchecker.SignatureKindCall
|
|
28
|
+
|
|
29
|
+
TypeFlagsAny = innerchecker.TypeFlagsAny
|
|
30
|
+
TypeFlagsUnknown = innerchecker.TypeFlagsUnknown
|
|
31
|
+
TypeFlagsUndefined = innerchecker.TypeFlagsUndefined
|
|
32
|
+
TypeFlagsNull = innerchecker.TypeFlagsNull
|
|
33
|
+
TypeFlagsVoid = innerchecker.TypeFlagsVoid
|
|
34
|
+
TypeFlagsNever = innerchecker.TypeFlagsNever
|
|
35
|
+
TypeFlagsObject = innerchecker.TypeFlagsObject
|
|
36
|
+
TypeFlagsTemplateLiteral = innerchecker.TypeFlagsTemplateLiteral
|
|
37
|
+
TypeFlagsStringMapping = innerchecker.TypeFlagsStringMapping
|
|
38
|
+
TypeFlagsUnion = innerchecker.TypeFlagsUnion
|
|
39
|
+
TypeFlagsIntersection = innerchecker.TypeFlagsIntersection
|
|
40
|
+
TypeFlagsLiteral = innerchecker.TypeFlagsLiteral
|
|
41
|
+
TypeFlagsStringLiteral = innerchecker.TypeFlagsStringLiteral
|
|
42
|
+
TypeFlagsNumberLiteral = innerchecker.TypeFlagsNumberLiteral
|
|
43
|
+
TypeFlagsBigIntLiteral = innerchecker.TypeFlagsBigIntLiteral
|
|
44
|
+
TypeFlagsBooleanLiteral = innerchecker.TypeFlagsBooleanLiteral
|
|
45
|
+
TypeFlagsStringLike = innerchecker.TypeFlagsStringLike
|
|
46
|
+
TypeFlagsNumberLike = innerchecker.TypeFlagsNumberLike
|
|
47
|
+
TypeFlagsBigIntLike = innerchecker.TypeFlagsBigIntLike
|
|
48
|
+
TypeFlagsBooleanLike = innerchecker.TypeFlagsBooleanLike
|
|
49
|
+
|
|
50
|
+
ObjectFlagsReference = innerchecker.ObjectFlagsReference
|
|
51
|
+
ObjectFlagsClass = innerchecker.ObjectFlagsClass
|
|
52
|
+
ObjectFlagsInterface = innerchecker.ObjectFlagsInterface
|
|
53
|
+
ObjectFlagsClassOrInterface = innerchecker.ObjectFlagsClassOrInterface
|
|
54
|
+
|
|
55
|
+
ElementFlagsNone = innerchecker.ElementFlagsNone
|
|
56
|
+
ElementFlagsRequired = innerchecker.ElementFlagsRequired
|
|
57
|
+
ElementFlagsOptional = innerchecker.ElementFlagsOptional
|
|
58
|
+
ElementFlagsRest = innerchecker.ElementFlagsRest
|
|
59
|
+
ElementFlagsVariadic = innerchecker.ElementFlagsVariadic
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
func IsTupleType(t *innerchecker.Type) bool {
|
|
63
|
+
return innerchecker.IsTupleType(t)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
func Checker_getIndexInfosOfType(recv *innerchecker.Checker, t *innerchecker.Type) []*innerchecker.IndexInfo {
|
|
67
|
+
return recv.GetIndexInfosOfType(t)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
func Checker_getPropertiesOfType(recv *innerchecker.Checker, t *innerchecker.Type) []*innerast.Symbol {
|
|
71
|
+
return recv.GetPropertiesOfType(t)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
func Checker_getApparentProperties(recv *innerchecker.Checker, t *innerchecker.Type) []*innerast.Symbol {
|
|
75
|
+
return recv.GetApparentProperties(t)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
func Checker_getTypeArguments(recv *innerchecker.Checker, t *innerchecker.Type) []*innerchecker.Type {
|
|
79
|
+
return recv.GetTypeArguments(t)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
func Checker_getTypeOfSymbol(recv *innerchecker.Checker, symbol *innerast.Symbol) *innerchecker.Type {
|
|
83
|
+
return recv.GetTypeOfSymbol(symbol)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
func Checker_getTypeOfSymbolAtLocation(recv *innerchecker.Checker, symbol *innerast.Symbol, node *innerast.Node) *innerchecker.Type {
|
|
87
|
+
return recv.GetTypeOfSymbolAtLocation(symbol, node)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
func Checker_getTypeOfPropertyOfType(recv *innerchecker.Checker, t *innerchecker.Type, name string) *innerchecker.Type {
|
|
91
|
+
return recv.GetTypeOfPropertyOfType(t, name)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
//go:linkname checkerGetAliasSymbolForTypeNode github.com/microsoft/typescript-go/internal/checker.(*Checker).getAliasSymbolForTypeNode
|
|
95
|
+
func checkerGetAliasSymbolForTypeNode(recv *innerchecker.Checker, node *innerast.Node) *innerast.Symbol
|
|
96
|
+
|
|
97
|
+
func Checker_getAliasSymbolForTypeNode(recv *innerchecker.Checker, node *innerast.Node) *innerast.Symbol {
|
|
98
|
+
return checkerGetAliasSymbolForTypeNode(recv, node)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
//go:linkname checkerGetDeclarationOfAliasSymbol github.com/microsoft/typescript-go/internal/checker.(*Checker).getDeclarationOfAliasSymbol
|
|
102
|
+
func checkerGetDeclarationOfAliasSymbol(recv *innerchecker.Checker, symbol *innerast.Symbol) *innerast.Node
|
|
103
|
+
|
|
104
|
+
func Checker_getDeclarationOfAliasSymbol(recv *innerchecker.Checker, symbol *innerast.Symbol) *innerast.Node {
|
|
105
|
+
return checkerGetDeclarationOfAliasSymbol(recv, symbol)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
//go:linkname checkerGetTargetOfImportSpecifier github.com/microsoft/typescript-go/internal/checker.(*Checker).getTargetOfImportSpecifier
|
|
109
|
+
func checkerGetTargetOfImportSpecifier(recv *innerchecker.Checker, node *innerast.Node) *innerast.Symbol
|
|
110
|
+
|
|
111
|
+
func Checker_getTargetOfImportSpecifier(recv *innerchecker.Checker, node *innerast.Node) *innerast.Symbol {
|
|
112
|
+
if recv == nil || node == nil {
|
|
113
|
+
return nil
|
|
114
|
+
}
|
|
115
|
+
return checkerGetTargetOfImportSpecifier(recv, node)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
func Checker_getAliasedSymbol(recv *innerchecker.Checker, symbol *innerast.Symbol) *innerast.Symbol {
|
|
119
|
+
if recv == nil || symbol == nil {
|
|
120
|
+
return nil
|
|
121
|
+
}
|
|
122
|
+
return recv.GetAliasedSymbol(symbol)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
//go:linkname checkerResolveEntityName github.com/microsoft/typescript-go/internal/checker.(*Checker).resolveEntityName
|
|
126
|
+
func checkerResolveEntityName(
|
|
127
|
+
recv *innerchecker.Checker,
|
|
128
|
+
name *innerast.Node,
|
|
129
|
+
meaning innerast.SymbolFlags,
|
|
130
|
+
ignoreErrors bool,
|
|
131
|
+
dontResolveAlias bool,
|
|
132
|
+
location *innerast.Node,
|
|
133
|
+
) *innerast.Symbol
|
|
134
|
+
|
|
135
|
+
func Checker_resolveEntityName(
|
|
136
|
+
recv *innerchecker.Checker,
|
|
137
|
+
name *innerast.Node,
|
|
138
|
+
meaning innerast.SymbolFlags,
|
|
139
|
+
ignoreErrors bool,
|
|
140
|
+
dontResolveAlias bool,
|
|
141
|
+
location *innerast.Node,
|
|
142
|
+
) *innerast.Symbol {
|
|
143
|
+
if recv == nil || name == nil {
|
|
144
|
+
return nil
|
|
145
|
+
}
|
|
146
|
+
return checkerResolveEntityName(recv, name, meaning, ignoreErrors, dontResolveAlias, location)
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
//go:linkname checkerGetTypeNameSymbol github.com/microsoft/typescript-go/internal/checker.getTypeNameSymbol
|
|
150
|
+
func checkerGetTypeNameSymbol(t *innerchecker.Type) *innerast.Symbol
|
|
151
|
+
|
|
152
|
+
func Type_getTypeNameSymbol(t *innerchecker.Type) *innerast.Symbol {
|
|
153
|
+
if t == nil {
|
|
154
|
+
return nil
|
|
155
|
+
}
|
|
156
|
+
return checkerGetTypeNameSymbol(t)
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
//go:linkname checkerIsArrayType github.com/microsoft/typescript-go/internal/checker.(*Checker).isArrayType
|
|
160
|
+
func checkerIsArrayType(recv *innerchecker.Checker, t *innerchecker.Type) bool
|
|
161
|
+
|
|
162
|
+
func Checker_isArrayType(recv *innerchecker.Checker, t *innerchecker.Type) bool {
|
|
163
|
+
return checkerIsArrayType(recv, t)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
//go:linkname checkerGetBaseTypes github.com/microsoft/typescript-go/internal/checker.(*Checker).getBaseTypes
|
|
167
|
+
func checkerGetBaseTypes(recv *innerchecker.Checker, t *innerchecker.Type) []*innerchecker.Type
|
|
168
|
+
|
|
169
|
+
func Checker_getBaseTypes(recv *innerchecker.Checker, t *innerchecker.Type) []*innerchecker.Type {
|
|
170
|
+
if recv == nil || t == nil {
|
|
171
|
+
return nil
|
|
172
|
+
}
|
|
173
|
+
return checkerGetBaseTypes(recv, t)
|
|
174
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// Code generated by packages/ttsc/tools/gen_shims. DO NOT EDIT.
|
|
2
|
+
|
|
3
|
+
package compiler
|
|
4
|
+
|
|
5
|
+
import "context"
|
|
6
|
+
import "github.com/microsoft/typescript-go/internal/ast"
|
|
7
|
+
import "github.com/microsoft/typescript-go/internal/compiler"
|
|
8
|
+
import "github.com/microsoft/typescript-go/internal/core"
|
|
9
|
+
import "github.com/microsoft/typescript-go/internal/diagnostics"
|
|
10
|
+
import "github.com/microsoft/typescript-go/internal/tsoptions"
|
|
11
|
+
import "github.com/microsoft/typescript-go/internal/vfs"
|
|
12
|
+
import _ "unsafe"
|
|
13
|
+
|
|
14
|
+
type CheckerPool = compiler.CheckerPool
|
|
15
|
+
|
|
16
|
+
//go:linkname CombineEmitResults github.com/microsoft/typescript-go/internal/compiler.CombineEmitResults
|
|
17
|
+
func CombineEmitResults(results []*compiler.EmitResult) *compiler.EmitResult
|
|
18
|
+
|
|
19
|
+
type CompilerHost = compiler.CompilerHost
|
|
20
|
+
type DuplicateSourceFile = compiler.DuplicateSourceFile
|
|
21
|
+
|
|
22
|
+
const EmitAll = compiler.EmitAll
|
|
23
|
+
|
|
24
|
+
type EmitHost = compiler.EmitHost
|
|
25
|
+
type EmitOnly = compiler.EmitOnly
|
|
26
|
+
|
|
27
|
+
const EmitOnlyDts = compiler.EmitOnlyDts
|
|
28
|
+
const EmitOnlyForcedDts = compiler.EmitOnlyForcedDts
|
|
29
|
+
const EmitOnlyJs = compiler.EmitOnlyJs
|
|
30
|
+
|
|
31
|
+
type EmitOptions = compiler.EmitOptions
|
|
32
|
+
type EmitResult = compiler.EmitResult
|
|
33
|
+
type FileIncludeReason = compiler.FileIncludeReason
|
|
34
|
+
|
|
35
|
+
//go:linkname FilterNoEmitSemanticDiagnostics github.com/microsoft/typescript-go/internal/compiler.FilterNoEmitSemanticDiagnostics
|
|
36
|
+
func FilterNoEmitSemanticDiagnostics(diagnostics []*ast.Diagnostic, options *core.CompilerOptions) []*ast.Diagnostic
|
|
37
|
+
|
|
38
|
+
//go:linkname GetDiagnosticsOfAnyProgram github.com/microsoft/typescript-go/internal/compiler.GetDiagnosticsOfAnyProgram
|
|
39
|
+
func GetDiagnosticsOfAnyProgram(ctx context.Context, program compiler.ProgramLike, file *ast.SourceFile, skipNoEmitCheckForDtsDiagnostics bool, getBindDiagnostics func(context.Context, *ast.SourceFile) []*ast.Diagnostic, getSemanticDiagnostics func(context.Context, *ast.SourceFile) []*ast.Diagnostic) []*ast.Diagnostic
|
|
40
|
+
|
|
41
|
+
//go:linkname HandleNoEmitOnError github.com/microsoft/typescript-go/internal/compiler.HandleNoEmitOnError
|
|
42
|
+
func HandleNoEmitOnError(ctx context.Context, program compiler.ProgramLike, file *ast.SourceFile) *compiler.EmitResult
|
|
43
|
+
|
|
44
|
+
type LibFile = compiler.LibFile
|
|
45
|
+
|
|
46
|
+
//go:linkname NewCachedFSCompilerHost github.com/microsoft/typescript-go/internal/compiler.NewCachedFSCompilerHost
|
|
47
|
+
func NewCachedFSCompilerHost(currentDirectory string, fs vfs.FS, defaultLibraryPath string, extendedConfigCache tsoptions.ExtendedConfigCache, trace func(msg *diagnostics.Message, args ...any)) compiler.CompilerHost
|
|
48
|
+
|
|
49
|
+
//go:linkname NewCompilerHost github.com/microsoft/typescript-go/internal/compiler.NewCompilerHost
|
|
50
|
+
func NewCompilerHost(currentDirectory string, fs vfs.FS, defaultLibraryPath string, extendedConfigCache tsoptions.ExtendedConfigCache, trace func(msg *diagnostics.Message, args ...any)) compiler.CompilerHost
|
|
51
|
+
|
|
52
|
+
//go:linkname NewProgram github.com/microsoft/typescript-go/internal/compiler.NewProgram
|
|
53
|
+
func NewProgram(opts compiler.ProgramOptions) *compiler.Program
|
|
54
|
+
|
|
55
|
+
type Program = compiler.Program
|
|
56
|
+
type ProgramLike = compiler.ProgramLike
|
|
57
|
+
type ProgramOptions = compiler.ProgramOptions
|
|
58
|
+
|
|
59
|
+
//go:linkname SortAndDeduplicateDiagnostics github.com/microsoft/typescript-go/internal/compiler.SortAndDeduplicateDiagnostics
|
|
60
|
+
func SortAndDeduplicateDiagnostics(diagnostics []*ast.Diagnostic) []*ast.Diagnostic
|
|
61
|
+
|
|
62
|
+
type SourceFileMayBeEmittedHost = compiler.SourceFileMayBeEmittedHost
|
|
63
|
+
type SourceMapEmitResult = compiler.SourceMapEmitResult
|
|
64
|
+
type WriteFile = compiler.WriteFile
|
|
65
|
+
type WriteFileData = compiler.WriteFileData
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
package core
|
|
2
|
+
|
|
3
|
+
import innercore "github.com/microsoft/typescript-go/internal/core"
|
|
4
|
+
|
|
5
|
+
type CompilerOptions = innercore.CompilerOptions
|
|
6
|
+
type Tristate = innercore.Tristate
|
|
7
|
+
type TextPos = innercore.TextPos
|
|
8
|
+
type TextRange = innercore.TextRange
|
|
9
|
+
type ScriptKind = innercore.ScriptKind
|
|
10
|
+
|
|
11
|
+
const (
|
|
12
|
+
TSFalse = innercore.TSFalse
|
|
13
|
+
TSTrue = innercore.TSTrue
|
|
14
|
+
|
|
15
|
+
ScriptKindUnknown = innercore.ScriptKindUnknown
|
|
16
|
+
ScriptKindJS = innercore.ScriptKindJS
|
|
17
|
+
ScriptKindJSX = innercore.ScriptKindJSX
|
|
18
|
+
ScriptKindTS = innercore.ScriptKindTS
|
|
19
|
+
ScriptKindTSX = innercore.ScriptKindTSX
|
|
20
|
+
ScriptKindExternal = innercore.ScriptKindExternal
|
|
21
|
+
ScriptKindJSON = innercore.ScriptKindJSON
|
|
22
|
+
ScriptKindDeferred = innercore.ScriptKindDeferred
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
// NewTextRange constructs a closed/open [pos, end) text range.
|
|
26
|
+
func NewTextRange(pos, end int) TextRange { return innercore.NewTextRange(pos, end) }
|
|
27
|
+
|
|
28
|
+
// UndefinedTextRange marks synthesized AST nodes that do not map to source.
|
|
29
|
+
func UndefinedTextRange() TextRange { return innercore.UndefinedTextRange() }
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
// Lint diagnostic helpers.
|
|
2
|
+
//
|
|
3
|
+
// Plugins that participate in `ttsc check` / `ttsc build` (e.g. `@ttsc/lint`)
|
|
4
|
+
// need to emit findings that ride the same color/context renderer as tsgo's
|
|
5
|
+
// own typecheck diagnostics. The plumbing has to live next to the existing
|
|
6
|
+
// shim so the renderer keeps its single owner of `internal/diagnosticwriter`
|
|
7
|
+
// and `internal/diagnostics`.
|
|
8
|
+
//
|
|
9
|
+
// Consumers construct a `LintDiagnostic` from `(file, pos, end, code,
|
|
10
|
+
// category, message)` and pass it to `FormatMixedDiagnostics` together with
|
|
11
|
+
// any raw tsgo diagnostics. The renderer treats both the same way.
|
|
12
|
+
package diagnosticwriter
|
|
13
|
+
|
|
14
|
+
import (
|
|
15
|
+
"io"
|
|
16
|
+
|
|
17
|
+
"github.com/microsoft/typescript-go/internal/ast"
|
|
18
|
+
"github.com/microsoft/typescript-go/internal/diagnostics"
|
|
19
|
+
inner "github.com/microsoft/typescript-go/internal/diagnosticwriter"
|
|
20
|
+
"github.com/microsoft/typescript-go/internal/locale"
|
|
21
|
+
"github.com/microsoft/typescript-go/internal/tspath"
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
// LintCategory selects warning vs error rendering. Warnings render yellow,
|
|
25
|
+
// errors render red — the exit-code decision lives in the caller.
|
|
26
|
+
type LintCategory int
|
|
27
|
+
|
|
28
|
+
const (
|
|
29
|
+
LintCategoryWarning LintCategory = iota
|
|
30
|
+
LintCategoryError
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
// LintDiagnostic is a public, plugin-emittable diagnostic shaped like the
|
|
34
|
+
// `internal/diagnosticwriter.Diagnostic` interface. The internal type is
|
|
35
|
+
// unexported, so this is the only way to mix lint output with tsgo's own
|
|
36
|
+
// diagnostics in a single render pass.
|
|
37
|
+
type LintDiagnostic struct {
|
|
38
|
+
file *ast.SourceFile
|
|
39
|
+
pos int
|
|
40
|
+
end int
|
|
41
|
+
code int32
|
|
42
|
+
category LintCategory
|
|
43
|
+
message string
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// NewLintDiagnostic builds a lint diagnostic anchored at [pos, end) in the
|
|
47
|
+
// supplied source file. `code` shows up in the rendered banner — the
|
|
48
|
+
// convention is to give each rule its own stable integer.
|
|
49
|
+
func NewLintDiagnostic(file *ast.SourceFile, pos, end int, code int32, category LintCategory, message string) *LintDiagnostic {
|
|
50
|
+
if end <= pos {
|
|
51
|
+
end = pos + 1
|
|
52
|
+
}
|
|
53
|
+
return &LintDiagnostic{
|
|
54
|
+
file: file,
|
|
55
|
+
pos: pos,
|
|
56
|
+
end: end,
|
|
57
|
+
code: code,
|
|
58
|
+
category: category,
|
|
59
|
+
message: message,
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
func (d *LintDiagnostic) File() inner.FileLike {
|
|
64
|
+
if d == nil || d.file == nil {
|
|
65
|
+
return nil
|
|
66
|
+
}
|
|
67
|
+
return d.file
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
func (d *LintDiagnostic) Pos() int { return d.pos }
|
|
71
|
+
func (d *LintDiagnostic) End() int { return d.end }
|
|
72
|
+
func (d *LintDiagnostic) Len() int { return d.end - d.pos }
|
|
73
|
+
func (d *LintDiagnostic) Code() int32 { return d.code }
|
|
74
|
+
|
|
75
|
+
func (d *LintDiagnostic) Category() diagnostics.Category {
|
|
76
|
+
if d.category == LintCategoryError {
|
|
77
|
+
return diagnostics.CategoryError
|
|
78
|
+
}
|
|
79
|
+
return diagnostics.CategoryWarning
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
func (d *LintDiagnostic) Localize(_ locale.Locale) string { return d.message }
|
|
83
|
+
func (d *LintDiagnostic) MessageChain() []inner.Diagnostic { return nil }
|
|
84
|
+
func (d *LintDiagnostic) RelatedInformation() []inner.Diagnostic { return nil }
|
|
85
|
+
|
|
86
|
+
// Message returns the already-localized lint message.
|
|
87
|
+
func (d *LintDiagnostic) Message() string {
|
|
88
|
+
if d == nil {
|
|
89
|
+
return ""
|
|
90
|
+
}
|
|
91
|
+
return d.message
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// IsError reports whether the diagnostic should fail the build. Lint plugins
|
|
95
|
+
// use this to compute their exit code separately from the renderer.
|
|
96
|
+
func (d *LintDiagnostic) IsError() bool { return d.category == LintCategoryError }
|
|
97
|
+
|
|
98
|
+
// FormatMixedDiagnostics renders raw tsgo diagnostics and lint diagnostics
|
|
99
|
+
// together with TypeScript-style colors and source context, followed by the
|
|
100
|
+
// `Found N errors` summary. Returns the count of error-level diagnostics so
|
|
101
|
+
// callers can decide on an exit code.
|
|
102
|
+
func FormatMixedDiagnostics(
|
|
103
|
+
output io.Writer,
|
|
104
|
+
astDiags []*ast.Diagnostic,
|
|
105
|
+
lintDiags []*LintDiagnostic,
|
|
106
|
+
currentDirectory string,
|
|
107
|
+
) int {
|
|
108
|
+
if len(astDiags) == 0 && len(lintDiags) == 0 {
|
|
109
|
+
return 0
|
|
110
|
+
}
|
|
111
|
+
all := make([]inner.Diagnostic, 0, len(astDiags)+len(lintDiags))
|
|
112
|
+
errors := 0
|
|
113
|
+
for _, d := range astDiags {
|
|
114
|
+
if d == nil {
|
|
115
|
+
continue
|
|
116
|
+
}
|
|
117
|
+
all = append(all, inner.WrapASTDiagnostic(d))
|
|
118
|
+
if d.Category() == diagnostics.CategoryError {
|
|
119
|
+
errors++
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
for _, d := range lintDiags {
|
|
123
|
+
if d == nil {
|
|
124
|
+
continue
|
|
125
|
+
}
|
|
126
|
+
all = append(all, d)
|
|
127
|
+
if d.IsError() {
|
|
128
|
+
errors++
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if len(all) == 0 {
|
|
132
|
+
return 0
|
|
133
|
+
}
|
|
134
|
+
options := &inner.FormattingOptions{
|
|
135
|
+
Locale: locale.Default,
|
|
136
|
+
ComparePathsOptions: tspath.ComparePathsOptions{
|
|
137
|
+
CurrentDirectory: currentDirectory,
|
|
138
|
+
UseCaseSensitiveFileNames: true,
|
|
139
|
+
},
|
|
140
|
+
NewLine: "\n",
|
|
141
|
+
}
|
|
142
|
+
inner.FormatDiagnosticsWithColorAndContext(output, all, options)
|
|
143
|
+
inner.WriteErrorSummaryText(output, all, options)
|
|
144
|
+
return errors
|
|
145
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
package diagnosticwriter
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"io"
|
|
5
|
+
|
|
6
|
+
"github.com/microsoft/typescript-go/internal/ast"
|
|
7
|
+
inner "github.com/microsoft/typescript-go/internal/diagnosticwriter"
|
|
8
|
+
"github.com/microsoft/typescript-go/internal/locale"
|
|
9
|
+
"github.com/microsoft/typescript-go/internal/tspath"
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
// FormatASTDiagnosticsWithColorAndContext writes TypeScript-style pretty
|
|
13
|
+
// diagnostics using the same internal formatter as typescript-go.
|
|
14
|
+
func FormatASTDiagnosticsWithColorAndContext(output io.Writer, diagnostics []*ast.Diagnostic, currentDirectory string) {
|
|
15
|
+
if len(diagnostics) == 0 {
|
|
16
|
+
return
|
|
17
|
+
}
|
|
18
|
+
formatted := inner.FromASTDiagnostics(diagnostics)
|
|
19
|
+
options := &inner.FormattingOptions{
|
|
20
|
+
Locale: locale.Default,
|
|
21
|
+
ComparePathsOptions: tspath.ComparePathsOptions{
|
|
22
|
+
CurrentDirectory: currentDirectory,
|
|
23
|
+
UseCaseSensitiveFileNames: true,
|
|
24
|
+
},
|
|
25
|
+
NewLine: "\n",
|
|
26
|
+
}
|
|
27
|
+
inner.FormatDiagnosticsWithColorAndContext(output, formatted, options)
|
|
28
|
+
inner.WriteErrorSummaryText(output, formatted, options)
|
|
29
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module github.com/microsoft/typescript-go/shim/lsp
|
|
2
|
+
|
|
3
|
+
go 1.26
|
|
4
|
+
|
|
5
|
+
require github.com/microsoft/typescript-go v0.0.0-20260429010842-56ab4af42157
|
|
6
|
+
|
|
7
|
+
require (
|
|
8
|
+
github.com/Microsoft/go-winio v0.6.2 // indirect
|
|
9
|
+
github.com/go-json-experiment/json v0.0.0-20260214004413-d219187c3433 // indirect
|
|
10
|
+
github.com/klauspost/cpuid/v2 v2.2.10 // indirect
|
|
11
|
+
github.com/mackerelio/go-osstat v0.2.7 // indirect
|
|
12
|
+
github.com/zeebo/xxh3 v1.1.0 // indirect
|
|
13
|
+
golang.org/x/sync v0.20.0 // indirect
|
|
14
|
+
golang.org/x/sys v0.43.0 // indirect
|
|
15
|
+
golang.org/x/text v0.36.0 // indirect
|
|
16
|
+
)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
|
|
2
|
+
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
|
|
3
|
+
github.com/go-json-experiment/json v0.0.0-20260214004413-d219187c3433 h1:vymEbVwYFP/L05h5TKQxvkXoKxNvTpjxYKdF1Nlwuao=
|
|
4
|
+
github.com/go-json-experiment/json v0.0.0-20260214004413-d219187c3433/go.mod h1:tphK2c80bpPhMOI4v6bIc2xWywPfbqi1Z06+RcrMkDg=
|
|
5
|
+
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
|
6
|
+
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
|
7
|
+
github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE=
|
|
8
|
+
github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
|
|
9
|
+
github.com/mackerelio/go-osstat v0.2.7 h1:TCavZi10wF49bT6iQZ9eT2keGZQpC69MTDfdJej5e94=
|
|
10
|
+
github.com/mackerelio/go-osstat v0.2.7/go.mod h1:dwpYh5pIPmvk+IEwBKNIWRFMB92mrC08CmXOhDC7nQk=
|
|
11
|
+
github.com/microsoft/typescript-go v0.0.0-20260429010842-56ab4af42157 h1:llOMPhKDiQ+UEJiAaQuuWaJOTg5V7tNNTEf9JPWoYSY=
|
|
12
|
+
github.com/microsoft/typescript-go v0.0.0-20260429010842-56ab4af42157/go.mod h1:m8YA0PMC7ti0GW0RI05D6fEcjQeu98XVS+FWF+VDW2k=
|
|
13
|
+
github.com/peter-evans/patience v0.3.0 h1:rX0JdJeepqdQl1Sk9c9uvorjYYzL2TfgLX1adqYm9cA=
|
|
14
|
+
github.com/peter-evans/patience v0.3.0/go.mod h1:Kmxu5sY1NmBLFSStvXjX1wS9mIv7wMcP/ubucyMOAu0=
|
|
15
|
+
github.com/zeebo/assert v1.3.0 h1:g7C04CbJuIDKNPFHmsk4hwZDO5O+kntRxzaUoNXj+IQ=
|
|
16
|
+
github.com/zeebo/assert v1.3.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0=
|
|
17
|
+
github.com/zeebo/xxh3 v1.1.0 h1:s7DLGDK45Dyfg7++yxI0khrfwq9661w9EN78eP/UZVs=
|
|
18
|
+
github.com/zeebo/xxh3 v1.1.0/go.mod h1:IisAie1LELR4xhVinxWS5+zf1lA4p0MW4T+w+W07F5s=
|
|
19
|
+
golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=
|
|
20
|
+
golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
|
21
|
+
golang.org/x/sys v0.43.0 h1:Rlag2XtaFTxp19wS8MXlJwTvoh8ArU6ezoyFsMyCTNI=
|
|
22
|
+
golang.org/x/sys v0.43.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
|
23
|
+
golang.org/x/text v0.36.0 h1:JfKh3XmcRPqZPKevfXVpI1wXPTqbkE5f7JA92a55Yxg=
|
|
24
|
+
golang.org/x/text v0.36.0/go.mod h1:NIdBknypM8iqVmPiuco0Dh6P5Jcdk8lJL0CUebqK164=
|
|
25
|
+
gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q=
|
|
26
|
+
gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA=
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// gen_shims:hand-maintained
|
|
2
|
+
//
|
|
3
|
+
// Minimal shim of tsgo's internal/lsp package. Hand-written instead of
|
|
4
|
+
// generated so the surface stays narrow: ttscserver embeds the tsgo LSP
|
|
5
|
+
// server unmodified and intercepts traffic at the byte level, so the only
|
|
6
|
+
// types it touches are the opaque Server, its options struct, and the
|
|
7
|
+
// Reader/Writer interfaces that ToReader/ToWriter return. The marker on
|
|
8
|
+
// the first line tells gen_shims to skip this file.
|
|
9
|
+
package lsp
|
|
10
|
+
|
|
11
|
+
import (
|
|
12
|
+
"io"
|
|
13
|
+
_ "unsafe"
|
|
14
|
+
|
|
15
|
+
innerlsp "github.com/microsoft/typescript-go/internal/lsp"
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
// Server is the opaque LSP server type from tsgo. ttscserver does not poke
|
|
19
|
+
// its internals; it only calls Run and (via wrapped Writer) observes the
|
|
20
|
+
// traffic the server emits.
|
|
21
|
+
type Server = innerlsp.Server
|
|
22
|
+
|
|
23
|
+
// ServerOptions mirrors the upstream construction parameters. Fields with
|
|
24
|
+
// internal-package types (e.g. ParseCache *project.ParseCache) are left
|
|
25
|
+
// unset by ttscserver, which is safe because every such field is an
|
|
26
|
+
// optional pointer the upstream constructor accepts as nil.
|
|
27
|
+
type ServerOptions = innerlsp.ServerOptions
|
|
28
|
+
|
|
29
|
+
// Reader / Writer carry framed lsproto.Message values. ttscserver feeds
|
|
30
|
+
// the server through io.Pipe shims of these so it can splice its own
|
|
31
|
+
// JSON-RPC traffic into the same stream the editor speaks.
|
|
32
|
+
type Reader = innerlsp.Reader
|
|
33
|
+
type Writer = innerlsp.Writer
|
|
34
|
+
|
|
35
|
+
//go:linkname NewServer github.com/microsoft/typescript-go/internal/lsp.NewServer
|
|
36
|
+
func NewServer(opts *ServerOptions) *Server
|
|
37
|
+
|
|
38
|
+
//go:linkname ToReader github.com/microsoft/typescript-go/internal/lsp.ToReader
|
|
39
|
+
func ToReader(r io.Reader) Reader
|
|
40
|
+
|
|
41
|
+
//go:linkname ToWriter github.com/microsoft/typescript-go/internal/lsp.ToWriter
|
|
42
|
+
func ToWriter(w io.Writer) Writer
|