ttsc 0.12.3 → 0.13.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.
- package/cmd/platform/main.go +9 -0
- package/cmd/ttsc/api_compile.go +122 -101
- package/cmd/ttsc/api_compile_branches_test.go +55 -57
- package/cmd/ttsc/api_transform.go +67 -49
- package/cmd/ttsc/api_transform_branches_test.go +30 -32
- package/cmd/ttsc/build.go +141 -108
- package/cmd/ttsc/build_branches_test.go +95 -97
- package/cmd/ttsc/filter.go +70 -0
- package/cmd/ttsc/filter_strips_unknown_forwarded_flag_test.go +61 -0
- package/cmd/ttsc/flags_gen.go +30 -0
- package/cmd/ttsc/helpers_test.go +39 -28
- package/cmd/ttsc/main.go +111 -104
- package/cmd/ttsc/main_alias_branches_test.go +21 -23
- package/cmd/ttscserver/main.go +96 -90
- package/cmd/ttscserver/run_lsp_prefers_tsgo_flag_test.go +22 -22
- package/cmd/ttscserver/run_lsp_reports_server_error_test.go +22 -22
- package/cmd/ttscserver/run_lsp_uses_tsgo_environment_test.go +23 -23
- package/cmd/utility-host/main.go +30 -23
- package/driver/lsp.go +53 -7
- package/driver/plugins.go +88 -72
- package/driver/program.go +464 -340
- package/driver/rewrite.go +477 -380
- package/internal/lspserver/lsp_envelope.go +64 -64
- package/internal/lspserver/lsp_frame.go +60 -60
- package/internal/lspserver/lsp_plugin.go +57 -57
- package/internal/lspserver/lsp_proxy.go +265 -251
- package/internal/lspserver/lsp_server.go +155 -144
- package/lib/TtscCompiler.d.ts +7 -0
- package/lib/TtscCompiler.js +7 -0
- package/lib/TtscCompiler.js.map +1 -1
- package/lib/compiler/internal/buildNativeCompiler.d.ts +11 -1
- package/lib/compiler/internal/buildNativeCompiler.js +23 -3
- package/lib/compiler/internal/buildNativeCompiler.js.map +1 -1
- package/lib/compiler/internal/compileProjectInMemory.d.ts +9 -0
- package/lib/compiler/internal/compileProjectInMemory.js +36 -21
- package/lib/compiler/internal/compileProjectInMemory.js.map +1 -1
- package/lib/compiler/internal/paths.d.ts +27 -0
- package/lib/compiler/internal/paths.js +70 -0
- package/lib/compiler/internal/paths.js.map +1 -0
- package/lib/compiler/internal/project/readProjectConfig.d.ts +9 -1
- package/lib/compiler/internal/project/readProjectConfig.js +80 -1
- package/lib/compiler/internal/project/readProjectConfig.js.map +1 -1
- package/lib/compiler/internal/project/resolveProjectConfig.d.ts +13 -1
- package/lib/compiler/internal/project/resolveProjectConfig.js +42 -1
- package/lib/compiler/internal/project/resolveProjectConfig.js.map +1 -1
- package/lib/compiler/internal/resolveBinary.d.ts +9 -1
- package/lib/compiler/internal/resolveBinary.js +17 -1
- package/lib/compiler/internal/resolveBinary.js.map +1 -1
- package/lib/compiler/internal/resolveEmittedJavaScript.d.ts +16 -1
- package/lib/compiler/internal/resolveEmittedJavaScript.js +42 -10
- package/lib/compiler/internal/resolveEmittedJavaScript.js.map +1 -1
- package/lib/compiler/internal/resolveTsgo.d.ts +21 -1
- package/lib/compiler/internal/resolveTsgo.js +23 -1
- package/lib/compiler/internal/resolveTsgo.js.map +1 -1
- package/lib/compiler/internal/runBuild.d.ts +24 -4
- package/lib/compiler/internal/runBuild.js +355 -93
- package/lib/compiler/internal/runBuild.js.map +1 -1
- package/lib/compiler/internal/runSingleFileEmit.d.ts +10 -1
- package/lib/compiler/internal/runSingleFileEmit.js +14 -1
- package/lib/compiler/internal/runSingleFileEmit.js.map +1 -1
- package/lib/compiler/internal/sharedHostHelpers.d.ts +5 -0
- package/lib/compiler/internal/sharedHostHelpers.js +6 -2
- package/lib/compiler/internal/sharedHostHelpers.js.map +1 -1
- package/lib/compiler/internal/spawnNative.d.ts +21 -0
- package/lib/compiler/internal/spawnNative.js +59 -0
- package/lib/compiler/internal/spawnNative.js.map +1 -0
- package/lib/compiler/internal/transformProjectInMemory.d.ts +15 -1
- package/lib/compiler/internal/transformProjectInMemory.js +57 -61
- package/lib/compiler/internal/transformProjectInMemory.js.map +1 -1
- package/lib/flags/parser.d.ts +63 -0
- package/lib/flags/parser.js +254 -0
- package/lib/flags/parser.js.map +1 -0
- package/lib/flags/schema.d.ts +147 -0
- package/lib/flags/schema.js +405 -0
- package/lib/flags/schema.js.map +1 -0
- package/lib/launcher/internal/getCompilerVersionText.js +7 -0
- package/lib/launcher/internal/getCompilerVersionText.js.map +1 -1
- package/lib/launcher/internal/prepareExecution.js +35 -0
- package/lib/launcher/internal/prepareExecution.js.map +1 -1
- package/lib/launcher/internal/resolveCacheDir.d.ts +9 -0
- package/lib/launcher/internal/resolveCacheDir.js +22 -0
- package/lib/launcher/internal/resolveCacheDir.js.map +1 -0
- package/lib/launcher/internal/resolveTtscserverBinary.js +2 -0
- package/lib/launcher/internal/resolveTtscserverBinary.js.map +1 -1
- package/lib/launcher/internal/runTtsc.d.ts +10 -0
- package/lib/launcher/internal/runTtsc.js +90 -153
- package/lib/launcher/internal/runTtsc.js.map +1 -1
- package/lib/launcher/internal/runTtscserver.js +10 -35
- package/lib/launcher/internal/runTtscserver.js.map +1 -1
- package/lib/launcher/internal/runTtsx.d.ts +8 -0
- package/lib/launcher/internal/runTtsx.js +137 -79
- package/lib/launcher/internal/runTtsx.js.map +1 -1
- package/lib/plugin/internal/buildSourcePlugin.d.ts +38 -0
- package/lib/plugin/internal/buildSourcePlugin.js +40 -17
- package/lib/plugin/internal/buildSourcePlugin.js.map +1 -1
- package/lib/plugin/internal/loadProjectPlugins.d.ts +26 -0
- package/lib/plugin/internal/loadProjectPlugins.js +90 -41
- package/lib/plugin/internal/loadProjectPlugins.js.map +1 -1
- package/lib/structures/ITtscCompilerTransformation.d.ts +15 -2
- package/lib/structures/ITtscPlugin.d.ts +24 -0
- package/lib/structures/ITtscPluginCapabilities.d.ts +29 -0
- package/lib/structures/ITtscPluginCapabilities.js +3 -0
- package/lib/structures/ITtscPluginCapabilities.js.map +1 -0
- package/lib/structures/index.d.ts +1 -0
- package/lib/structures/index.js +1 -0
- package/lib/structures/index.js.map +1 -1
- package/lib/structures/internal/ITtscLoadedNativePlugin.d.ts +5 -0
- package/lib/structures/internal/TtscCommonOptions.d.ts +19 -0
- package/lib/structures/internal/TtscSingleFileEmitOptions.d.ts +0 -2
- package/package.json +9 -9
- package/shim/ast/shim.go +24 -0
- package/shim/checker/shim.go +35 -0
- package/shim/core/shim.go +17 -0
- package/shim/diagnosticwriter/shim.go +4 -0
- package/shim/lsp/shim.go +3 -3
- package/shim/printer/shim.go +20 -0
- package/src/TtscCompiler.ts +7 -0
- package/src/compiler/internal/buildNativeCompiler.ts +23 -3
- package/src/compiler/internal/compileProjectInMemory.ts +34 -25
- package/src/compiler/internal/paths.ts +68 -0
- package/src/compiler/internal/project/readProjectConfig.ts +86 -1
- package/src/compiler/internal/project/resolveProjectConfig.ts +44 -1
- package/src/compiler/internal/resolveBinary.ts +17 -1
- package/src/compiler/internal/resolveEmittedJavaScript.ts +43 -12
- package/src/compiler/internal/resolveTsgo.ts +29 -1
- package/src/compiler/internal/runBuild.ts +398 -112
- package/src/compiler/internal/runSingleFileEmit.ts +14 -1
- package/src/compiler/internal/sharedHostHelpers.ts +7 -7
- package/src/compiler/internal/spawnNative.ts +64 -0
- package/src/compiler/internal/transformProjectInMemory.ts +47 -67
- package/src/flags/parser.ts +367 -0
- package/src/flags/schema.ts +570 -0
- package/src/launcher/internal/getCompilerVersionText.ts +7 -0
- package/src/launcher/internal/prepareExecution.ts +35 -0
- package/src/launcher/internal/resolveCacheDir.ts +19 -0
- package/src/launcher/internal/resolveTtscserverBinary.ts +2 -0
- package/src/launcher/internal/runTtsc.ts +97 -143
- package/src/launcher/internal/runTtscserver.ts +9 -1
- package/src/launcher/internal/runTtsx.ts +149 -82
- package/src/plugin/internal/buildSourcePlugin.ts +40 -14
- package/src/plugin/internal/loadProjectPlugins.ts +116 -45
- package/src/structures/ITtscCompilerTransformation.ts +15 -2
- package/src/structures/ITtscPlugin.ts +26 -1
- package/src/structures/ITtscPluginCapabilities.ts +29 -0
- package/src/structures/index.ts +1 -0
- package/src/structures/internal/ITtscLoadedNativePlugin.ts +5 -0
- package/src/structures/internal/TtscCommonOptions.ts +19 -0
- package/src/structures/internal/TtscSingleFileEmitOptions.ts +0 -2
- package/tools/gen_shims/main.go +43 -8
- package/utility/flags_gen.go +30 -0
- package/utility/host.go +304 -245
|
@@ -22,7 +22,14 @@ export namespace ITtscCompilerTransformation {
|
|
|
22
22
|
/** Non-fatal diagnostics reported during transformation. */
|
|
23
23
|
diagnostics?: ITtscCompilerDiagnostic[];
|
|
24
24
|
|
|
25
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* Transformed TypeScript source text keyed by project-relative file path.
|
|
27
|
+
*
|
|
28
|
+
* Values are TypeScript source text, never JavaScript, declaration files,
|
|
29
|
+
* or source maps. When no transform sidecar is configured, this map
|
|
30
|
+
* contains the unmodified TypeScript files loaded by the TypeScript-Go
|
|
31
|
+
* Program.
|
|
32
|
+
*/
|
|
26
33
|
typescript: Record<string, string>;
|
|
27
34
|
}
|
|
28
35
|
|
|
@@ -31,7 +38,13 @@ export namespace ITtscCompilerTransformation {
|
|
|
31
38
|
/** Indicates that transformation completed with diagnostics. */
|
|
32
39
|
type: "failure";
|
|
33
40
|
|
|
34
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* Transformed or partially transformed TypeScript source text keyed by
|
|
43
|
+
* project-relative file path.
|
|
44
|
+
*
|
|
45
|
+
* May be empty or partial when diagnostics prevented the transform sidecar
|
|
46
|
+
* from completing its pass.
|
|
47
|
+
*/
|
|
35
48
|
typescript: Record<string, string>;
|
|
36
49
|
|
|
37
50
|
/** Diagnostics reported during transformation. */
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ITtscPluginCapabilities } from "./ITtscPluginCapabilities";
|
|
1
2
|
import type { ITtscPluginContributor } from "./ITtscPluginContributor";
|
|
2
3
|
import type { TtscPluginStage } from "./TtscPluginStage";
|
|
3
4
|
|
|
@@ -64,6 +65,31 @@ export interface ITtscPlugin {
|
|
|
64
65
|
*/
|
|
65
66
|
stage?: TtscPluginStage;
|
|
66
67
|
|
|
68
|
+
/**
|
|
69
|
+
* Optional capability flags declared by the sidecar.
|
|
70
|
+
*
|
|
71
|
+
* ttsc carries a few cross-cutting flags (`--singleThreaded`, `--checkers`,
|
|
72
|
+
* …) the lint sidecar parses but a typical third-party transform host
|
|
73
|
+
* does not. Capability flags let the plugin author opt into those flags
|
|
74
|
+
* explicitly, instead of ttsc keeping a hard-coded allow-list keyed by
|
|
75
|
+
* plugin name. Every capability defaults to `false`.
|
|
76
|
+
*
|
|
77
|
+
* @see ITtscPluginCapabilities
|
|
78
|
+
*/
|
|
79
|
+
capabilities?: ITtscPluginCapabilities;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Whether a check-stage sidecar reports the normal TypeScript diagnostics for
|
|
83
|
+
* the project as part of its `check` subcommand.
|
|
84
|
+
*
|
|
85
|
+
* Leave this unset for ordinary check plugins that only report their own
|
|
86
|
+
* diagnostics; ttsc will keep running a separate `tsgo --noEmit` guard so
|
|
87
|
+
* TypeScript errors are not suppressed. Set it only when the sidecar builds
|
|
88
|
+
* the project Program and emits the same TypeScript diagnostics the guard
|
|
89
|
+
* would have produced.
|
|
90
|
+
*/
|
|
91
|
+
reportsTypeScriptDiagnostics?: boolean;
|
|
92
|
+
|
|
67
93
|
/**
|
|
68
94
|
* Additional Go source packages to statically link into this plugin's binary
|
|
69
95
|
* at build time ("plugin-within-plugin" composition).
|
|
@@ -96,5 +122,4 @@ export interface ITtscPlugin {
|
|
|
96
122
|
* unique within a single plugin build.
|
|
97
123
|
*/
|
|
98
124
|
contributors?: ITtscPluginContributor[];
|
|
99
|
-
|
|
100
125
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optional capability flags declared by a native ttsc plugin descriptor.
|
|
3
|
+
*
|
|
4
|
+
* ttsc owns a small set of cross-cutting flags (`--singleThreaded`,
|
|
5
|
+
* `--checkers`, …) that the lint sidecar accepts but a typical third-party
|
|
6
|
+
* transform host (built with bare `flag.FlagSet`) would reject with exit 2.
|
|
7
|
+
* Capabilities let the plugin author tell ttsc up front which of those flags
|
|
8
|
+
* the sidecar understands, instead of ttsc hard-checking the plugin name and
|
|
9
|
+
* silently dropping the flag for anything else.
|
|
10
|
+
*
|
|
11
|
+
* Every field is optional and defaults to `false`. Plugin authors opt in by
|
|
12
|
+
* setting only the capabilities their sidecar actually implements; ttsc
|
|
13
|
+
* keeps the conservative default for everything else.
|
|
14
|
+
*/
|
|
15
|
+
export interface ITtscPluginCapabilities {
|
|
16
|
+
/**
|
|
17
|
+
* Whether the sidecar accepts `--singleThreaded` and `--checkers` on its
|
|
18
|
+
* command line. The lint sidecar parses both flags via
|
|
19
|
+
* `parseSubcommandFlags` and threads them into `loadProgram` (parse phase)
|
|
20
|
+
* and `engine.SetSerial` (rule walk); other check-stage hosts may not.
|
|
21
|
+
*
|
|
22
|
+
* When `false` (the default), ttsc strips both flags from the sidecar's
|
|
23
|
+
* arg list — the conservative behavior that ad3443a restored after
|
|
24
|
+
* `#113` over-forwarded them to typia/nestia hosts.
|
|
25
|
+
*
|
|
26
|
+
* @default false
|
|
27
|
+
*/
|
|
28
|
+
threadingArgs?: boolean;
|
|
29
|
+
}
|
package/src/structures/index.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from "./ITtscCompilerDiagnostic";
|
|
|
3
3
|
export * from "./ITtscCompilerResult";
|
|
4
4
|
export * from "./ITtscCompilerTransformation";
|
|
5
5
|
export * from "./ITtscPlugin";
|
|
6
|
+
export * from "./ITtscPluginCapabilities";
|
|
6
7
|
export * from "./ITtscPluginContributor";
|
|
7
8
|
export * from "./ITtscPluginFactoryContext";
|
|
8
9
|
export * from "./ITtscProjectPluginConfig";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ITtscPluginCapabilities } from "../ITtscPluginCapabilities";
|
|
1
2
|
import type { ITtscPluginContributor } from "../ITtscPluginContributor";
|
|
2
3
|
import type { ITtscProjectPluginConfig } from "../ITtscProjectPluginConfig";
|
|
3
4
|
import type { TtscPluginStage } from "../TtscPluginStage";
|
|
@@ -6,6 +7,8 @@ import type { TtscPluginStage } from "../TtscPluginStage";
|
|
|
6
7
|
export interface ITtscLoadedNativePlugin {
|
|
7
8
|
/** Executable produced by the lazy Go source build cache. */
|
|
8
9
|
binary: string;
|
|
10
|
+
/** Capability flags declared by the descriptor (see `ITtscPluginCapabilities`). */
|
|
11
|
+
capabilities?: ITtscPluginCapabilities;
|
|
9
12
|
/** Original tsconfig plugin entry passed unchanged to the sidecar. */
|
|
10
13
|
config: ITtscProjectPluginConfig;
|
|
11
14
|
/** Contributor Go sources statically linked into the binary, if any. */
|
|
@@ -14,6 +17,8 @@ export interface ITtscLoadedNativePlugin {
|
|
|
14
17
|
kind: "executable" | "linked";
|
|
15
18
|
/** Optional human label used in diagnostics and native manifests. */
|
|
16
19
|
name?: string;
|
|
20
|
+
/** Whether a check-stage plugin already emits TypeScript diagnostics. */
|
|
21
|
+
reportsTypeScriptDiagnostics?: boolean;
|
|
17
22
|
/** Go source directory selected by the plugin descriptor. */
|
|
18
23
|
source: string;
|
|
19
24
|
/** Pipeline stage where the sidecar participates. */
|
|
@@ -22,6 +22,25 @@ export interface TtscCommonOptions {
|
|
|
22
22
|
cacheDir?: string;
|
|
23
23
|
/** Normalize compiler output so diagnostics can be parsed structurally. */
|
|
24
24
|
structuredDiagnostics?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Run TypeScript-Go single-threaded — one checker, serial parse/check/emit.
|
|
27
|
+
* Mirrors `tsgo --singleThreaded`. Useful for deterministic debugging and CI
|
|
28
|
+
* repro.
|
|
29
|
+
*/
|
|
30
|
+
singleThreaded?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Type-checker pool size, mirroring `tsgo --checkers`. `undefined` leaves
|
|
33
|
+
* TypeScript-Go's default; ignored when `singleThreaded` is set.
|
|
34
|
+
*/
|
|
35
|
+
checkers?: number;
|
|
36
|
+
/**
|
|
37
|
+
* CLI tokens ttsc did not recognize as its own, forwarded verbatim to the
|
|
38
|
+
* underlying `tsgo` invocation. This is how a tsgo flag ttsc has no first-
|
|
39
|
+
* class option for (`--strict`, `--target es2020`, `--listFiles`, …) still
|
|
40
|
+
* reaches the compiler: ttsc owns its own flags and lets tsgo — which has the
|
|
41
|
+
* complete, arity-aware option parser — handle the rest.
|
|
42
|
+
*/
|
|
43
|
+
passthrough?: readonly string[];
|
|
25
44
|
/**
|
|
26
45
|
* Override project plugin loading for this invocation.
|
|
27
46
|
*
|
|
@@ -10,6 +10,4 @@ export interface TtscSingleFileEmitOptions extends TtscCommonOptions {
|
|
|
10
10
|
out?: string;
|
|
11
11
|
/** Suppress summary banners from ttsc/native sidecars. Defaults to `true`. */
|
|
12
12
|
quiet?: boolean;
|
|
13
|
-
/** Normalize compiler output so diagnostics can be parsed structurally. */
|
|
14
|
-
structuredDiagnostics?: boolean;
|
|
15
13
|
}
|
package/tools/gen_shims/main.go
CHANGED
|
@@ -56,13 +56,28 @@ var packagesToShim = []string{
|
|
|
56
56
|
"vfs/osvfs",
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
// ExtraShim is the schema for the per-shim-directory `extra-shim.json` file.
|
|
60
|
+
// It lets maintainers extend the generated output beyond what gen_shims can
|
|
61
|
+
// derive automatically from the public API surface.
|
|
59
62
|
type ExtraShim struct {
|
|
60
|
-
ExtraFunctions
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
// ExtraFunctions lists unexported function names that should be shimmed via
|
|
64
|
+
// go:linkname in addition to the exported ones gen_shims discovers itself.
|
|
65
|
+
ExtraFunctions []string
|
|
66
|
+
// ExtraMethods maps type name → method names for unexported or
|
|
67
|
+
// otherwise-unlinkable methods that should be forwarded.
|
|
68
|
+
ExtraMethods map[string][]string
|
|
69
|
+
// ExtraFields maps type name → field names whose values should be exposed
|
|
70
|
+
// through unsafe pointer casts (used when go:linkname cannot reach them).
|
|
71
|
+
ExtraFields map[string][]string
|
|
72
|
+
// IgnoreFunctions lists exported function names that gen_shims should skip
|
|
73
|
+
// entirely, typically because the caller supplies a hand-written alternative.
|
|
63
74
|
IgnoreFunctions []string
|
|
64
75
|
}
|
|
65
76
|
|
|
77
|
+
// signatureHasUnexportedType reports whether any parameter of the function
|
|
78
|
+
// signature refers to an unexported named type (optionally through a pointer).
|
|
79
|
+
// Such functions cannot be linked safely because the shim package cannot
|
|
80
|
+
// reference the unexported type by name.
|
|
66
81
|
func signatureHasUnexportedType(t types.Signature) bool {
|
|
67
82
|
if params := t.Params(); params != nil {
|
|
68
83
|
for v := range params.Variables() {
|
|
@@ -128,6 +143,9 @@ func main() {
|
|
|
128
143
|
extraShim.IgnoreFunctions = []string{}
|
|
129
144
|
}
|
|
130
145
|
|
|
146
|
+
// importedPackages tracks every package import the generated file needs.
|
|
147
|
+
// true = referenced by name (needs a named import).
|
|
148
|
+
// false = only needed for its side-effects (blank import "_").
|
|
131
149
|
importedPackages := map[string]bool{}
|
|
132
150
|
importPackage := func(path string, directly bool) {
|
|
133
151
|
if directly {
|
|
@@ -137,12 +155,21 @@ func main() {
|
|
|
137
155
|
}
|
|
138
156
|
}
|
|
139
157
|
|
|
158
|
+
// qualifierOnlyPackageName records a direct import for every package the
|
|
159
|
+
// type-string references and returns just the package short name, producing
|
|
160
|
+
// output like `ast.Node` instead of a full path.
|
|
140
161
|
var qualifierOnlyPackageName types.Qualifier = func(p *types.Package) string {
|
|
141
162
|
importPackage(p.Path(), true)
|
|
142
163
|
return p.Name()
|
|
143
164
|
}
|
|
165
|
+
// qualifierEmptyPackageName omits the package qualifier entirely; used when
|
|
166
|
+
// writing the receiver type inside a go:linkname directive where the package
|
|
167
|
+
// prefix must not appear.
|
|
144
168
|
var qualifierEmptyPackageName types.Qualifier = func(p *types.Package) string { return "" }
|
|
145
169
|
|
|
170
|
+
// emitGoLinknameDirective appends a `//go:linkname localName pkg.Func`
|
|
171
|
+
// pragma line to shimBuilder, registering unsafe and the source package as
|
|
172
|
+
// blank imports so the linker can resolve the symbol.
|
|
146
173
|
emitGoLinknameDirective := func(localName string, fn *types.Func) {
|
|
147
174
|
importPackage("unsafe", false)
|
|
148
175
|
importPackage(pkg.Types.Path(), false)
|
|
@@ -161,6 +188,9 @@ func main() {
|
|
|
161
188
|
shimBuilder.WriteByte('\n')
|
|
162
189
|
}
|
|
163
190
|
|
|
191
|
+
// emitLinkedFunction emits a go:linkname directive and a matching func
|
|
192
|
+
// declaration for fn. Generic functions (TypeParams != nil) and functions
|
|
193
|
+
// with unexported parameter types are skipped (returns false).
|
|
164
194
|
emitLinkedFunction := func(fn *types.Func) bool {
|
|
165
195
|
if fn.Signature().TypeParams() != nil {
|
|
166
196
|
return false
|
|
@@ -221,10 +251,9 @@ func main() {
|
|
|
221
251
|
shimBuilder.WriteString("\n")
|
|
222
252
|
}
|
|
223
253
|
|
|
224
|
-
switch object.(type) {
|
|
254
|
+
switch typedObj := object.(type) {
|
|
225
255
|
case *types.TypeName:
|
|
226
|
-
|
|
227
|
-
t := typeName.Type()
|
|
256
|
+
t := typedObj.Type()
|
|
228
257
|
named, isNamed := t.(*types.Named)
|
|
229
258
|
if isNamed {
|
|
230
259
|
_, nameWithTypeParams, _ := strings.Cut(types.TypeString(named, qualifierOnlyPackageName), ".")
|
|
@@ -297,6 +326,10 @@ func main() {
|
|
|
297
326
|
matchedExtraFields[name] = true
|
|
298
327
|
mirrorStructName := "extra_" + name
|
|
299
328
|
|
|
329
|
+
// emitExtraStruct emits a mirror struct (`extra_<Name>`) whose field
|
|
330
|
+
// layout matches the unexported original so that unsafe.Pointer casts
|
|
331
|
+
// in the generated accessor functions are safe. Unexported pointer
|
|
332
|
+
// fields whose element type is also unexported are recursively mirrored.
|
|
300
333
|
var emitExtraStruct func(name string, s *types.Struct)
|
|
301
334
|
emitExtraStruct = func(name string, s *types.Struct) {
|
|
302
335
|
shimBuilder.WriteString("type extra_")
|
|
@@ -384,12 +417,14 @@ func main() {
|
|
|
384
417
|
printReexport("var")
|
|
385
418
|
case *types.Func:
|
|
386
419
|
if !slices.Contains(extraShim.IgnoreFunctions, name) {
|
|
387
|
-
|
|
388
|
-
emitLinkedFunction(funcType)
|
|
420
|
+
emitLinkedFunction(typedObj)
|
|
389
421
|
}
|
|
390
422
|
}
|
|
391
423
|
}
|
|
392
424
|
|
|
425
|
+
// Verify that every extra function/method requested in extra-shim.json was
|
|
426
|
+
// actually found in the package. A missing symbol means the json file is
|
|
427
|
+
// stale relative to the upstream typescript-go API.
|
|
393
428
|
exit := false
|
|
394
429
|
for fnName, found := range matchedExtraFunctions {
|
|
395
430
|
if found {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Code generated by packages/ttsc/scripts/gen-flags.mts. DO NOT EDIT.
|
|
2
|
+
//
|
|
3
|
+
// Source of truth: packages/ttsc/src/flags/schema.ts.
|
|
4
|
+
// Regenerate with: pnpm format
|
|
5
|
+
// Verify in CI with: node packages/ttsc/scripts/check-flags.cjs
|
|
6
|
+
|
|
7
|
+
package utility
|
|
8
|
+
|
|
9
|
+
// HostFlagAllowList is the allow-list of CLI flags this Go layer accepts. The map's
|
|
10
|
+
// value is true when the flag carries a separate value token (--flag VALUE
|
|
11
|
+
// or --flag=VALUE) and false when the flag is boolean (--flag).
|
|
12
|
+
//
|
|
13
|
+
// Generated from packages/ttsc/src/flags/schema.ts. Edit the schema, not
|
|
14
|
+
// this file.
|
|
15
|
+
var HostFlagAllowList = map[string]bool{
|
|
16
|
+
"checkers": true,
|
|
17
|
+
"cwd": true,
|
|
18
|
+
"emit": false,
|
|
19
|
+
"manifest": true,
|
|
20
|
+
"noEmit": false,
|
|
21
|
+
"outDir": true,
|
|
22
|
+
"p": true,
|
|
23
|
+
"plugins-json": true,
|
|
24
|
+
"project": true,
|
|
25
|
+
"quiet": false,
|
|
26
|
+
"singleThreaded": false,
|
|
27
|
+
"tsconfig": true,
|
|
28
|
+
"tsgo-args": true,
|
|
29
|
+
"verbose": false,
|
|
30
|
+
}
|