ttsc 0.15.0 → 0.15.1
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/driver/emit_plugin.go +36 -2
- package/package.json +8 -8
package/driver/emit_plugin.go
CHANGED
|
@@ -25,8 +25,8 @@ func (h *pluginEmitHost) SourceFiles() []*shimast.SourceFile { return h.program.
|
|
|
25
25
|
func (h *pluginEmitHost) UseCaseSensitiveFileNames() bool {
|
|
26
26
|
return h.program.UseCaseSensitiveFileNames()
|
|
27
27
|
}
|
|
28
|
-
func (h *pluginEmitHost) GetCurrentDirectory() string
|
|
29
|
-
func (h *pluginEmitHost) CommonSourceDirectory() string
|
|
28
|
+
func (h *pluginEmitHost) GetCurrentDirectory() string { return h.program.GetCurrentDirectory() }
|
|
29
|
+
func (h *pluginEmitHost) CommonSourceDirectory() string { return h.program.CommonSourceDirectory() }
|
|
30
30
|
func (h *pluginEmitHost) IsEmitBlocked(file string) bool { return h.program.IsEmitBlocked(file) }
|
|
31
31
|
func (h *pluginEmitHost) WriteFile(fileName string, text string) error {
|
|
32
32
|
return h.program.Host().FS().WriteFile(fileName, text)
|
|
@@ -92,6 +92,39 @@ func (p *Program) EmitLinkedTransforms(writeFile shimcompiler.WriteFile) ([]Diag
|
|
|
92
92
|
return p.EmitWithPluginTransformers(transforms, writeFile)
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
// restoreOriginalDeclarationSymbols copies the binder symbol from each original
|
|
96
|
+
// parse-tree node onto the synthetic node a plugin transform recreated in its
|
|
97
|
+
// place. A plugin that rewrites a node nested inside a class/interface/enum (for
|
|
98
|
+
// example a decorator call on a controller method) forces the visitor to rebuild
|
|
99
|
+
// every ancestor container to hold the changed child; those rebuilt containers
|
|
100
|
+
// carry an `original` link (set by the emit context) but NOT the binder symbol,
|
|
101
|
+
// because the emit context's update hook only records the original, it does not
|
|
102
|
+
// copy `DeclarationBase.Symbol`.
|
|
103
|
+
//
|
|
104
|
+
// tsgo's emit resolver then walks the transformed tree in
|
|
105
|
+
// MarkLinkedReferencesRecursively and, when it resolves an identifier whose
|
|
106
|
+
// scope chain passes through one of those rebuilt containers, calls
|
|
107
|
+
// getSymbolOfDeclaration(container) — which reads container.Symbol() and nil-
|
|
108
|
+
// panics on a rebuilt class/interface/enum. Restoring the symbol from the
|
|
109
|
+
// original (the symbol object is shared and node-independent for lookup) lets
|
|
110
|
+
// the resolver mark references the same way it would on the parse tree.
|
|
111
|
+
func restoreOriginalDeclarationSymbols(ec *shimprinter.EmitContext, node *shimast.Node) {
|
|
112
|
+
if node == nil {
|
|
113
|
+
return
|
|
114
|
+
}
|
|
115
|
+
if data := node.DeclarationData(); data != nil && data.Symbol == nil {
|
|
116
|
+
if original := ec.MostOriginal(node); original != nil {
|
|
117
|
+
if originalData := original.DeclarationData(); originalData != nil {
|
|
118
|
+
data.Symbol = originalData.Symbol
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
node.ForEachChild(func(child *shimast.Node) bool {
|
|
123
|
+
restoreOriginalDeclarationSymbols(ec, child)
|
|
124
|
+
return false
|
|
125
|
+
})
|
|
126
|
+
}
|
|
127
|
+
|
|
95
128
|
// EmitWithPluginTransformers emits every source file by assembling tsgo's emit
|
|
96
129
|
// pipeline from shim parts and running the plugin transformers FIRST (in order)
|
|
97
130
|
// in the same EmitContext as the builtin chain (type-erase, import-elision,
|
|
@@ -116,6 +149,7 @@ func (p *Program) EmitWithPluginTransformers(transforms []PluginTransform, write
|
|
|
116
149
|
}
|
|
117
150
|
}
|
|
118
151
|
shimast.SetParentInChildrenUnset(out.AsNode())
|
|
152
|
+
restoreOriginalDeclarationSymbols(ec, out.AsNode())
|
|
119
153
|
for _, tr := range shimcompiler.GetScriptTransformers(ec, host, out) {
|
|
120
154
|
out = tr.TransformSourceFile(out)
|
|
121
155
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ttsc",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.1",
|
|
4
4
|
"description": "General-purpose TypeScript-Go compiler, runtime, plugin host, and LSP host.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -32,13 +32,13 @@
|
|
|
32
32
|
"rimraf": "^6.1.2"
|
|
33
33
|
},
|
|
34
34
|
"optionalDependencies": {
|
|
35
|
-
"@ttsc/linux-arm64": "0.15.
|
|
36
|
-
"@ttsc/linux-
|
|
37
|
-
"@ttsc/
|
|
38
|
-
"@ttsc/
|
|
39
|
-
"@ttsc/
|
|
40
|
-
"@ttsc/
|
|
41
|
-
"@ttsc/win32-x64": "0.15.
|
|
35
|
+
"@ttsc/linux-arm64": "0.15.1",
|
|
36
|
+
"@ttsc/linux-arm": "0.15.1",
|
|
37
|
+
"@ttsc/darwin-x64": "0.15.1",
|
|
38
|
+
"@ttsc/linux-x64": "0.15.1",
|
|
39
|
+
"@ttsc/win32-arm64": "0.15.1",
|
|
40
|
+
"@ttsc/darwin-arm64": "0.15.1",
|
|
41
|
+
"@ttsc/win32-x64": "0.15.1"
|
|
42
42
|
},
|
|
43
43
|
"sideEffects": false,
|
|
44
44
|
"files": [
|