@ttsc/wasm 0.19.1 → 0.19.3

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/dist/ttsc.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttsc/wasm",
3
- "version": "0.19.1",
3
+ "version": "0.19.3",
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",
@@ -49,6 +49,19 @@ func Checker_getRegularTypeOfLiteralType(recv *innerchecker.Checker, t *innerche
49
49
  return checkerGetRegularTypeOfLiteralType(recv, t)
50
50
  }
51
51
 
52
+ // ValueToString renders a literal type's value in TypeScript source form: a
53
+ // string as a double-quoted, escaped literal, a number, boolean, or bigint as
54
+ // the way it is written. It is the checker's own renderer, so a consumer
55
+ // enumerating a literal union reports the values the way the compiler prints
56
+ // them, including numeric formatting and string escaping it should not re-derive.
57
+ //
58
+ // It panics on a value it does not handle — notably the nil a computed enum
59
+ // member carries — so a caller holding a `LiteralType.Value()` must reject nil
60
+ // before calling this.
61
+ func ValueToString(value any) string {
62
+ return innerchecker.ValueToString(value)
63
+ }
64
+
52
65
  // Checker_typeToStringFullyQualified formats a type with the same stable,
53
66
  // alias-aware flags TypeScript uses in diagnostics that name union members.
54
67
  // Keeping the flag bundle inside the shim avoids leaking checker-internal enum
@@ -0,0 +1,58 @@
1
+ // gen_shims:hand-maintained
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.
8
+ package compiler
9
+
10
+ import (
11
+ _ "unsafe"
12
+
13
+ innerast "github.com/microsoft/typescript-go/internal/ast"
14
+ "github.com/microsoft/typescript-go/internal/collections"
15
+ innercompiler "github.com/microsoft/typescript-go/internal/compiler"
16
+ "github.com/microsoft/typescript-go/internal/tspath"
17
+
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"
21
+ )
22
+
23
+ //go:linkname incrementalGetReferencedFiles github.com/microsoft/typescript-go/internal/execute/incremental.getReferencedFiles
24
+ func incrementalGetReferencedFiles(program *innercompiler.Program, file *innerast.SourceFile) *collections.Set[tspath.Path]
25
+
26
+ //go:linkname incrementalFileAffectsGlobalScope github.com/microsoft/typescript-go/internal/execute/incremental.fileAffectsGlobalScope
27
+ func incrementalFileAffectsGlobalScope(file *innerast.SourceFile) bool
28
+
29
+ // GetReferencedFilePaths returns the canonical paths of every file that `file`
30
+ // directly references in `program`: resolved imports and re-exports (type-only
31
+ // included), `/// <reference>` targets, resolved type reference directives,
32
+ // module augmentations, and ambient-module declaration files. This is exactly
33
+ // the per-file `referencedMap` entry tsgo's incremental engine stores in
34
+ // `tsbuildinfo`, so the result is the sound language-semantic upper bound on
35
+ // which program files a symbol in `file` can resolve through.
36
+ //
37
+ // The returned strings are tspath.Path values (case-canonicalized on
38
+ // case-insensitive filesystems); map them back to real file names through
39
+ // Program.GetSourceFileByPath when the original spelling matters.
40
+ func GetReferencedFilePaths(program *Program, file *innerast.SourceFile) []string {
41
+ set := incrementalGetReferencedFiles(program, file)
42
+ if set == nil {
43
+ return nil
44
+ }
45
+ out := make([]string, 0, set.Len())
46
+ for path := range set.Keys() {
47
+ out = append(out, string(path))
48
+ }
49
+ return out
50
+ }
51
+
52
+ // FileAffectsGlobalScope reports whether editing `file` can change the global
53
+ // scope: global-scope module augmentations, ambient declaration files, and
54
+ // script (non-module) files. Mirrors the predicate tsgo's incremental engine
55
+ // uses to decide that a change must invalidate every file in the program.
56
+ func FileAffectsGlobalScope(file *innerast.SourceFile) bool {
57
+ return incrementalFileAffectsGlobalScope(file)
58
+ }
@@ -50,6 +50,11 @@ const (
50
50
  JsxEmitReactJSXDev = innercore.JsxEmitReactJSXDev
51
51
  )
52
52
 
53
+ // Version reports the TypeScript compiler version typescript-go implements, in
54
+ // the same form `tsc --version` prints. A graph snapshot publishes it so a
55
+ // consumer can tell which checker resolved the facts it is reading.
56
+ func Version() string { return innercore.Version() }
57
+
53
58
  // NewTextRange constructs a closed/open [pos, end) text range.
54
59
  func NewTextRange(pos, end int) TextRange { return innercore.NewTextRange(pos, end) }
55
60