@ttsc/wasm 0.26.2 → 0.28.0

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.
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "schema": 1,
3
- "identity": "d2aaebc4a3fb711653c25dd4bd96266235c1765720f25de03366130d14fe1d2e",
3
+ "identity": "8e448ff45b7e1fd1f9f1b6d1d5ee3dc0fcf4de96a5d93f1faf71df266043ca9b",
4
4
  "artifacts": [
5
5
  {
6
6
  "path": "/home/runner/work/ttsc/ttsc/packages/wasm/dist/ttsc.wasm",
7
7
  "type": "file",
8
- "sha256": "29bafd930043ecd531782f8565448fb18ea8c5ae703b78dd1dca1c183e06ba83"
8
+ "sha256": "a75af10a10f8d6e1c951414460c63e7ab398d0f5c283d3fbedcd44d2fada506d"
9
9
  },
10
10
  {
11
11
  "path": "/home/runner/work/ttsc/ttsc/packages/wasm/dist/wasm_exec.js",
@@ -43,7 +43,7 @@
43
43
  },
44
44
  {
45
45
  "path": "ast/parent.go",
46
- "sha256": "261de982952f6c855e6c303d7c1a3adea2aaa125bb7103063a55f1741ff525db"
46
+ "sha256": "8ec407ee63e9a172cd1bcbd717c2b326ce2d3bbbc7301b3544c67f6b046bf597"
47
47
  },
48
48
  {
49
49
  "path": "ast/safe_text.go",
@@ -103,7 +103,7 @@
103
103
  },
104
104
  {
105
105
  "path": "checker/enums_gen.go",
106
- "sha256": "196f4a8b77ee0fa4e1a65a801472ffaa13871865e23c5b02eb5ef7ed371f39a8"
106
+ "sha256": "5c2abe63676104fdeb78cd8e7064cd87bd79585b29e73a07b445db7b14725875"
107
107
  },
108
108
  {
109
109
  "path": "checker/extra-shim.json",
@@ -111,11 +111,15 @@
111
111
  },
112
112
  {
113
113
  "path": "checker/go.mod",
114
- "sha256": "d191ae8d581a2d548e02221e27cdde3ad54611abd62ac7ba3c647da7435f67e6"
114
+ "sha256": "94e107d6628d4693f2da8a342e49ff326ad28d5d0c31bec30ad3a42a98aad4cf"
115
+ },
116
+ {
117
+ "path": "checker/go.sum",
118
+ "sha256": "a94c806630860a27e74df1db99b2abf86fada0e699937a813b42fe190021a16d"
115
119
  },
116
120
  {
117
121
  "path": "checker/shim.go",
118
- "sha256": "cd45126b5cc0fbbe1213343dd561c51c4d0673135ff62d6542bd1ea6e3426eab"
122
+ "sha256": "e4b4251860e180532a2eef5965e61d0843a6078cebefdd388c98119ebf451dc1"
119
123
  },
120
124
  {
121
125
  "path": "compiler/emit_sourcemap.go",
@@ -127,7 +131,7 @@
127
131
  },
128
132
  {
129
133
  "path": "compiler/emithook.go",
130
- "sha256": "a639371d663dc56005e9490b3f7d5ba2d3b8d1c56dfd862c721f0f9f9adddce9"
134
+ "sha256": "1539525a78d9369c5c692c9a62514395b3ac8e905e4e923e215855dcb7191d00"
131
135
  },
132
136
  {
133
137
  "path": "compiler/extra-shim.json",
@@ -143,7 +147,7 @@
143
147
  },
144
148
  {
145
149
  "path": "compiler/incremental.go",
146
- "sha256": "8020631b8bc293f7cc860afbd4f40b1f4a304459b28d1111ecf366826f7e88ab"
150
+ "sha256": "3c873bed3659cfe1969a97caea105d230dad510e66d8da6e4ca2c4dc6617a04c"
147
151
  },
148
152
  {
149
153
  "path": "compiler/shim.go",
package/dist/ttsc.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttsc/wasm",
3
- "version": "0.26.2",
3
+ "version": "0.28.0",
4
4
  "description": "Build in-browser ttsc playgrounds. Compose ttsc + typescript-go with your own plugins via the Go host helper.",
5
5
  "main": "lib/src/index.js",
6
6
  "types": "lib/src/index.d.ts",
@@ -6,9 +6,17 @@ import innerast "github.com/microsoft/typescript-go/internal/ast"
6
6
  // its containing node.
7
7
  //
8
8
  // A transform that splices freshly built (synthetic) nodes onto a SourceFile
9
- // must call this before emit: passes that walk parents e.g. the emit
10
- // resolver's reference marking (MarkLinkedReferencesRecursively) dereference
11
- // Parent and would hit nil on a synthetic node otherwise.
9
+ // must call this before emit, because the passes that then walk the spliced tree
10
+ // dereference Parent and would hit nil on a synthetic node. The printer is the
11
+ // example that holds up: getContainingNodeArray reads node.Parent unguarded for
12
+ // a parameter, template span, decorator, and heritage clause.
13
+ //
14
+ // Two earlier examples were dropped rather than the rule. The emit resolver's
15
+ // reference marking no longer walks the spliced tree at all in ttsc's plugin
16
+ // emit lane, which builds the builtin chain from the parse tree (see
17
+ // driver.EmitWithPluginTransformers). The module transform's own Parent reads
18
+ // carry upstream //nolint:customlint notes saying they deliberately inspect
19
+ // parse-tree parents.
12
20
  func SetParentInChildren(node *Node) {
13
21
  innerast.SetParentInChildren(node)
14
22
  }
@@ -20,6 +28,11 @@ func SetParentInChildren(node *Node) {
20
28
  // kept verbatim while sibling statements were rewritten) makes tsgo's
21
29
  // runtime-syntax/printer mis-resolve the declaration and drop it from emit.
22
30
  // Only freshly built (synthetic) nodes need a parent wired, and those start nil.
31
+ //
32
+ // This is the form ttsc's plugin emit lane calls. How much it currently carries
33
+ // is unproven: stubbing the call out leaves the whole driver suite green, which
34
+ // measures the suite's coverage of parent-dependent emit rather than the hazard.
35
+ // Keep it for the reason above, not on the strength of a failing test.
23
36
  func SetParentInChildrenUnset(node *Node) {
24
37
  node.ForEachChild(func(child *Node) bool {
25
38
  if child.Parent == nil {
@@ -77,6 +77,17 @@ const (
77
77
  ObjectFlagsSingleSignatureType = innerchecker.ObjectFlagsSingleSignatureType
78
78
  ObjectFlagsTuple = innerchecker.ObjectFlagsTuple
79
79
  ObjectFlagsUnresolvedMembers = innerchecker.ObjectFlagsUnresolvedMembers
80
+ SignatureFlagsCallChainFlags = innerchecker.SignatureFlagsCallChainFlags
81
+ SignatureFlagsConstruct = innerchecker.SignatureFlagsConstruct
82
+ SignatureFlagsHasLiteralTypes = innerchecker.SignatureFlagsHasLiteralTypes
83
+ SignatureFlagsHasRestParameter = innerchecker.SignatureFlagsHasRestParameter
84
+ SignatureFlagsIsInnerCallChain = innerchecker.SignatureFlagsIsInnerCallChain
85
+ SignatureFlagsIsNonInferrable = innerchecker.SignatureFlagsIsNonInferrable
86
+ SignatureFlagsIsOuterCallChain = innerchecker.SignatureFlagsIsOuterCallChain
87
+ SignatureFlagsIsSignatureCandidateForOverloadFailure = innerchecker.SignatureFlagsIsSignatureCandidateForOverloadFailure
88
+ SignatureFlagsIsUntypedSignatureInJSFile = innerchecker.SignatureFlagsIsUntypedSignatureInJSFile
89
+ SignatureFlagsNone = innerchecker.SignatureFlagsNone
90
+ SignatureFlagsPropagatingFlags = innerchecker.SignatureFlagsPropagatingFlags
80
91
  SignatureKindConstruct = innerchecker.SignatureKindConstruct
81
92
  TypeFlagsAnyOrUnknown = innerchecker.TypeFlagsAnyOrUnknown
82
93
  TypeFlagsBigInt = innerchecker.TypeFlagsBigInt
@@ -3,3 +3,12 @@ module github.com/microsoft/typescript-go/shim/checker
3
3
  go 1.26
4
4
 
5
5
  require github.com/microsoft/typescript-go v0.0.0-20260429010842-56ab4af42157
6
+
7
+ require (
8
+ github.com/go-json-experiment/json v0.0.0-20260214004413-d219187c3433 // indirect
9
+ github.com/klauspost/cpuid/v2 v2.2.10 // indirect
10
+ github.com/zeebo/xxh3 v1.1.0 // indirect
11
+ golang.org/x/sync v0.20.0 // indirect
12
+ golang.org/x/sys v0.43.0 // indirect
13
+ golang.org/x/text v0.36.0 // indirect
14
+ )
@@ -0,0 +1,22 @@
1
+ github.com/go-json-experiment/json v0.0.0-20260214004413-d219187c3433 h1:vymEbVwYFP/L05h5TKQxvkXoKxNvTpjxYKdF1Nlwuao=
2
+ github.com/go-json-experiment/json v0.0.0-20260214004413-d219187c3433/go.mod h1:tphK2c80bpPhMOI4v6bIc2xWywPfbqi1Z06+RcrMkDg=
3
+ github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
4
+ github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
5
+ github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE=
6
+ github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
7
+ github.com/microsoft/typescript-go v0.0.0-20260429010842-56ab4af42157 h1:llOMPhKDiQ+UEJiAaQuuWaJOTg5V7tNNTEf9JPWoYSY=
8
+ github.com/microsoft/typescript-go v0.0.0-20260429010842-56ab4af42157/go.mod h1:m8YA0PMC7ti0GW0RI05D6fEcjQeu98XVS+FWF+VDW2k=
9
+ github.com/peter-evans/patience v0.3.0 h1:rX0JdJeepqdQl1Sk9c9uvorjYYzL2TfgLX1adqYm9cA=
10
+ github.com/peter-evans/patience v0.3.0/go.mod h1:Kmxu5sY1NmBLFSStvXjX1wS9mIv7wMcP/ubucyMOAu0=
11
+ github.com/zeebo/assert v1.3.0 h1:g7C04CbJuIDKNPFHmsk4hwZDO5O+kntRxzaUoNXj+IQ=
12
+ github.com/zeebo/assert v1.3.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0=
13
+ github.com/zeebo/xxh3 v1.1.0 h1:s7DLGDK45Dyfg7++yxI0khrfwq9661w9EN78eP/UZVs=
14
+ github.com/zeebo/xxh3 v1.1.0/go.mod h1:IisAie1LELR4xhVinxWS5+zf1lA4p0MW4T+w+W07F5s=
15
+ golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=
16
+ golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
17
+ golang.org/x/sys v0.43.0 h1:Rlag2XtaFTxp19wS8MXlJwTvoh8ArU6ezoyFsMyCTNI=
18
+ golang.org/x/sys v0.43.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
19
+ golang.org/x/text v0.36.0 h1:JfKh3XmcRPqZPKevfXVpI1wXPTqbkE5f7JA92a55Yxg=
20
+ golang.org/x/text v0.36.0/go.mod h1:NIdBknypM8iqVmPiuco0Dh6P5Jcdk8lJL0CUebqK164=
21
+ gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q=
22
+ gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA=
@@ -20,8 +20,11 @@ import (
20
20
  type Checker = innerchecker.Checker
21
21
  type IndexInfo = innerchecker.IndexInfo
22
22
  type Signature = innerchecker.Signature
23
+ type SignatureFlags = innerchecker.SignatureFlags
23
24
  type SignatureKind = innerchecker.SignatureKind
24
25
  type Type = innerchecker.Type
26
+ type TypeMapper = innerchecker.TypeMapper
27
+ type TypeMapperKind = innerchecker.TypeMapperKind
25
28
  type TypeFlags = innerchecker.TypeFlags
26
29
  type ObjectFlags = innerchecker.ObjectFlags
27
30
  type ElementFlags = innerchecker.ElementFlags
@@ -214,8 +217,15 @@ func Checker_isSymbolAccessibleAsValue(recv *innerchecker.Checker, symbol *inner
214
217
  }
215
218
 
216
219
  const (
220
+ SignatureFlagsAbstract = innerchecker.SignatureFlagsAbstract
221
+
217
222
  SignatureKindCall = innerchecker.SignatureKindCall
218
223
 
224
+ TypeMapperKindUnknown = innerchecker.TypeMapperKindUnknown
225
+ TypeMapperKindSimple = innerchecker.TypeMapperKindSimple
226
+ TypeMapperKindArray = innerchecker.TypeMapperKindArray
227
+ TypeMapperKindMerged = innerchecker.TypeMapperKindMerged
228
+
219
229
  TypeFlagsAny = innerchecker.TypeFlagsAny
220
230
  TypeFlagsUnknown = innerchecker.TypeFlagsUnknown
221
231
  TypeFlagsUndefined = innerchecker.TypeFlagsUndefined
@@ -597,3 +607,71 @@ func Checker_getRestTypeOfSignature(recv *innerchecker.Checker, signature *inner
597
607
  }
598
608
  return recv.GetRestTypeOfSignature(signature)
599
609
  }
610
+
611
+ //go:linkname checkerInstantiateType github.com/microsoft/typescript-go/internal/checker.(*Checker).instantiateType
612
+ func checkerInstantiateType(recv *innerchecker.Checker, t *innerchecker.Type, m *innerchecker.TypeMapper) *innerchecker.Type
613
+
614
+ //go:linkname checkerNewSimpleTypeMapper github.com/microsoft/typescript-go/internal/checker.newSimpleTypeMapper
615
+ func checkerNewSimpleTypeMapper(source *innerchecker.Type, target *innerchecker.Type) *innerchecker.TypeMapper
616
+
617
+ //go:linkname checkerNewTypeMapper github.com/microsoft/typescript-go/internal/checker.newTypeMapper
618
+ func checkerNewTypeMapper(sources []*innerchecker.Type, targets []*innerchecker.Type) *innerchecker.TypeMapper
619
+
620
+ // Checker_instantiateType substitutes the type parameters of `t` with the
621
+ // concrete types in `mapper`, returning the instantiated type. A type-transform
622
+ // plugin uses it to instantiate a generic class's constructor type with the
623
+ // reference's type arguments, so a type parameter nested inside a container
624
+ // (`A[]`, `[A, B]`) is substituted for free. Returns nil if recv or t is nil.
625
+ func Checker_instantiateType(recv *innerchecker.Checker, t *innerchecker.Type, mapper *innerchecker.TypeMapper) *innerchecker.Type {
626
+ if recv == nil || t == nil {
627
+ return nil
628
+ }
629
+ return checkerInstantiateType(recv, t, mapper)
630
+ }
631
+
632
+ // Checker_newSimpleTypeMapper builds a single-pair type mapper that substitutes
633
+ // `source` with `target`. It is the building block for instantiating a generic
634
+ // class's constructor type with its reference type arguments. Returns nil if
635
+ // source or target is nil.
636
+ func Checker_newSimpleTypeMapper(source *innerchecker.Type, target *innerchecker.Type) *innerchecker.TypeMapper {
637
+ if source == nil || target == nil {
638
+ return nil
639
+ }
640
+ return checkerNewSimpleTypeMapper(source, target)
641
+ }
642
+
643
+ // Checker_newTypeMapper builds a parallel type mapper from corresponding
644
+ // source and target slices. Unlike Checker_combineTypeMappers, it does not feed
645
+ // one substitution's target through later substitutions, so a mapping such as
646
+ // `[A, B] -> [B, A]` preserves both target identities. Returns nil when the
647
+ // slices are empty, differ in length, or contain nil types.
648
+ func Checker_newTypeMapper(sources []*innerchecker.Type, targets []*innerchecker.Type) *innerchecker.TypeMapper {
649
+ if len(sources) == 0 || len(sources) != len(targets) {
650
+ return nil
651
+ }
652
+ for i := range sources {
653
+ if sources[i] == nil || targets[i] == nil {
654
+ return nil
655
+ }
656
+ }
657
+ return checkerNewTypeMapper(sources, targets)
658
+ }
659
+
660
+ //go:linkname checkerCombineTypeMappers github.com/microsoft/typescript-go/internal/checker.(*Checker).combineTypeMappers
661
+ func checkerCombineTypeMappers(recv *innerchecker.Checker, m1 *innerchecker.TypeMapper, m2 *innerchecker.TypeMapper) *innerchecker.TypeMapper
662
+
663
+ // Checker_combineTypeMappers composes two mapper stages. The first mapper's
664
+ // substituted target is instantiated through the second mapper, so use
665
+ // Checker_newTypeMapper instead when source and target slices are parallel
666
+ // declaration-parameter mappings. Returns m2 when m1 is nil, including when
667
+ // recv is nil. Returns nil when m1 is non-nil and recv or m2 is nil, because
668
+ // both are required to build a usable composite mapper.
669
+ func Checker_combineTypeMappers(recv *innerchecker.Checker, m1 *innerchecker.TypeMapper, m2 *innerchecker.TypeMapper) *innerchecker.TypeMapper {
670
+ if m1 == nil {
671
+ return m2
672
+ }
673
+ if recv == nil || m2 == nil {
674
+ return nil
675
+ }
676
+ return checkerCombineTypeMappers(recv, m1, m2)
677
+ }
@@ -18,5 +18,15 @@ import (
18
18
  // (type-erase, import-elision, runtime-syntax, module-transform, ...) for one
19
19
  // source file, linked from the internal package via go:linkname.
20
20
  //
21
+ // `sourceFile` is the marking target, not the file that gets transformed.
22
+ // Upstream reads it for two per-file constants (in-JS-file, JSX language
23
+ // variant) and then hands it to emitResolver.MarkLinkedReferencesRecursively,
24
+ // whose marks the import-elision transformer later reads back through
25
+ // EmitContext.ParseNode. A caller that runs a plugin pass first must therefore
26
+ // pass the PARSE tree here and the transformed tree to TransformSourceFile;
27
+ // upstream's own emitter passes one file to both only because it has nothing in
28
+ // between. Re-check this when the pin moves: a new use of the parameter inside
29
+ // getScriptTransformers could make the two roles diverge further.
30
+ //
21
31
  //go:linkname GetScriptTransformers github.com/microsoft/typescript-go/internal/compiler.getScriptTransformers
22
32
  func GetScriptTransformers(emitContext *innerprinter.EmitContext, host innerprinter.EmitHost, sourceFile *innerast.SourceFile) []*innertransformers.Transformer
@@ -1,13 +1,20 @@
1
1
  // gen_shims:hand-maintained
2
2
  //
3
- // Reference-graph parts of tsgo's own incremental engine (`tsc --incremental`
4
- // semantics), linked from internal/execute/incremental so ttsc's transform
5
- // envelopes can carry the same language-semantic input bound the compiler
6
- // itself uses for invalidation: per-file direct resolved references and the
7
- // files that contribute to the global scope.
3
+ // Parts of tsgo's own incremental engine (`tsc --incremental` semantics),
4
+ // exposed from internal/execute/incremental for the two things a ttsc host
5
+ // needs from it:
6
+ //
7
+ // - the reference graph, so transform envelopes can carry the same
8
+ // language-semantic input bound the compiler itself uses for invalidation:
9
+ // per-file direct resolved references and the files that contribute to the
10
+ // global scope;
11
+ // - the build-information emit, so a host that constructs its Program
12
+ // in-process still writes the `.tsbuildinfo` an `incremental` or
13
+ // `composite` project asked for.
8
14
  package compiler
9
15
 
10
16
  import (
17
+ "context"
11
18
  _ "unsafe"
12
19
 
13
20
  innerast "github.com/microsoft/typescript-go/internal/ast"
@@ -15,11 +22,41 @@ import (
15
22
  innercompiler "github.com/microsoft/typescript-go/internal/compiler"
16
23
  "github.com/microsoft/typescript-go/internal/tspath"
17
24
 
18
- // The linknamed symbols below live in the incremental package; the blank
19
- // import compiles it into every shim consumer so the references resolve.
20
- _ "github.com/microsoft/typescript-go/internal/execute/incremental"
25
+ // Imported for EmitFreshWithBuildInfo below, and for the linknamed symbols
26
+ // further down: compiling the package into every shim consumer is what makes
27
+ // those references resolve.
28
+ "github.com/microsoft/typescript-go/internal/execute/incremental"
21
29
  )
22
30
 
31
+ // EmitFreshWithBuildInfo runs a full emit through tsgo's own incremental
32
+ // program, so an `incremental` or `composite` project gets the `.tsbuildinfo`
33
+ // tsgo would have written, in the exact format and location
34
+ // `outputpaths.GetBuildInfoFileName` resolves from the compiler options.
35
+ //
36
+ // This is the emit half of `tsc.go::performIncrementalCompilation`, which the
37
+ // tsgo CLI takes whenever `CompilerOptions.IsIncremental()`. A host that builds
38
+ // its Program in-process (ttsc's driver, and therefore every plugin sidecar
39
+ // emitting through it) never reaches that CLI path, so without this the build
40
+ // information is silently dropped even though the options parsed cleanly.
41
+ //
42
+ // "Fresh" is the load-bearing word: no previous snapshot is supplied, so
43
+ // `programToSnapshot` marks every file changed and this emits the whole program
44
+ // exactly as `Program.Emit` does, then writes the build info. A ttsc plugin's
45
+ // output is not a pure function of the source text a build info records — it
46
+ // also depends on the plugin binary, its config file, and its contributors —
47
+ // so reusing a previous snapshot to skip a file would serve stale transformed
48
+ // output. Producing the record is sound; consuming it needs plugin identity in
49
+ // the invalidation key first.
50
+ func EmitFreshWithBuildInfo(ctx context.Context, program *Program, options EmitOptions) *EmitResult {
51
+ incrementalProgram := incremental.NewProgram(
52
+ program,
53
+ nil,
54
+ incremental.CreateHost(program.Host()),
55
+ false,
56
+ )
57
+ return incrementalProgram.Emit(ctx, options)
58
+ }
59
+
23
60
  //go:linkname incrementalGetReferencedFiles github.com/microsoft/typescript-go/internal/execute/incremental.getReferencedFiles
24
61
  func incrementalGetReferencedFiles(program *innercompiler.Program, file *innerast.SourceFile) *collections.Set[tspath.Path]
25
62