@ttsc/wasm 0.30.4 → 0.31.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.
Files changed (174) hide show
  1. package/README.md +3 -3
  2. package/build/build-wasm.cjs +5 -4
  3. package/build/go-build-cache.cjs +347 -0
  4. package/build/pack-prepare.cjs +3 -2
  5. package/cmd/ttsc-wasm/main.go +22 -10
  6. package/cmd/ttsc-wasm/main_wasm.go +2 -2
  7. package/dist/.ttsc-wasm-build.json +138 -58
  8. package/dist/go.mod +7 -5
  9. package/dist/ttsc.wasm +2 -2
  10. package/go.mod +7 -5
  11. package/go.sum +10 -10
  12. package/host/api.go +34 -41
  13. package/host/doc.go +7 -6
  14. package/host/expose.go +42 -0
  15. package/host/fountain.go +192 -22
  16. package/host/host.go +10 -25
  17. package/host/host_native.go +3 -5
  18. package/host/invoke.go +133 -0
  19. package/host/plugin.go +37 -72
  20. package/host/result.go +108 -0
  21. package/lib/src/BootTtscWorkerTerminationError.d.ts +20 -0
  22. package/lib/src/BootTtscWorkerTerminationError.js +20 -0
  23. package/lib/src/BootTtscWorkerTerminationError.js.map +1 -1
  24. package/lib/src/MemFSError.d.ts +21 -2
  25. package/lib/src/MemFSError.js +25 -2
  26. package/lib/src/MemFSError.js.map +1 -1
  27. package/lib/src/bootTtsc.d.ts +49 -2
  28. package/lib/src/bootTtsc.js +89 -23
  29. package/lib/src/bootTtsc.js.map +1 -1
  30. package/lib/src/createMemFS.d.ts +45 -0
  31. package/lib/src/createMemFS.js +269 -66
  32. package/lib/src/createMemFS.js.map +1 -1
  33. package/lib/src/parseResult.d.ts +19 -0
  34. package/lib/src/parseResult.js +19 -0
  35. package/lib/src/parseResult.js.map +1 -1
  36. package/lib/src/structures/IBootResult.d.ts +20 -2
  37. package/lib/src/structures/IBootTtscOptions.d.ts +28 -6
  38. package/lib/src/structures/IFileStats.d.ts +51 -0
  39. package/lib/src/structures/IMemFSHost.d.ts +89 -0
  40. package/lib/src/structures/ITtscApi.d.ts +154 -9
  41. package/lib/src/structures/ITtscBuildOpts.d.ts +18 -1
  42. package/lib/src/structures/ITtscCompileResult.d.ts +20 -2
  43. package/lib/src/structures/ITtscDiagnostic.d.ts +25 -1
  44. package/lib/src/structures/ITtscFileQuery.d.ts +19 -1
  45. package/lib/src/structures/ITtscFountainDiagnosticsResult.d.ts +20 -1
  46. package/lib/src/structures/ITtscNodeAtPositionResult.d.ts +18 -1
  47. package/lib/src/structures/ITtscNodeInfo.d.ts +23 -2
  48. package/lib/src/structures/ITtscPluginOpts.d.ts +24 -3
  49. package/lib/src/structures/ITtscPositionQuery.d.ts +21 -4
  50. package/lib/src/structures/ITtscReleaseSnapshotResult.d.ts +22 -2
  51. package/lib/src/structures/ITtscResult.d.ts +31 -5
  52. package/lib/src/structures/ITtscSnapshotHandle.d.ts +19 -1
  53. package/lib/src/structures/ITtscSnapshotResult.d.ts +22 -1
  54. package/lib/src/structures/ITtscSnapshotsResult.d.ts +19 -1
  55. package/lib/src/structures/ITtscSourceFileTextResult.d.ts +19 -1
  56. package/lib/src/structures/ITtscSourceFilesResult.d.ts +23 -2
  57. package/lib/src/structures/ITtscSymbolAtPositionResult.d.ts +18 -1
  58. package/lib/src/structures/ITtscSymbolDeclaration.d.ts +25 -2
  59. package/lib/src/structures/ITtscSymbolInfo.d.ts +19 -1
  60. package/lib/src/structures/ITtscTransformResult.d.ts +21 -3
  61. package/lib/src/structures/ITtscTypeAtPositionResult.d.ts +18 -1
  62. package/lib/src/structures/ITtscTypeInfo.d.ts +19 -1
  63. package/lib/src/structures/ITtscVersion.d.ts +28 -1
  64. package/lib/src/structures/IWasmExecFS.d.ts +310 -0
  65. package/package.json +4 -2
  66. package/shim-vendor/shim/ast/enums_gen.go +4 -2
  67. package/shim-vendor/shim/ast/go.mod +5 -5
  68. package/shim-vendor/shim/ast/go.sum +10 -10
  69. package/shim-vendor/shim/ast/lint.go +1088 -20
  70. package/shim-vendor/shim/ast/parent.go +38 -22
  71. package/shim-vendor/shim/ast/safe_text.go +48 -26
  72. package/shim-vendor/shim/ast/shim.go +1307 -20
  73. package/shim-vendor/shim/ast/test/next_jsdoc_comment_location_reaches_variable_statement_test.go +51 -0
  74. package/shim-vendor/shim/ast/test/node_text_joins_multi_hop_qualified_name_test.go +24 -9
  75. package/shim-vendor/shim/ast/test/node_text_joins_one_hop_qualified_name_test.go +9 -5
  76. package/shim-vendor/shim/ast/test/node_text_returns_empty_for_nil_test.go +13 -5
  77. package/shim-vendor/shim/ast/test/node_text_returns_identifier_text_test.go +12 -5
  78. package/shim-vendor/shim/ast/test/node_text_skips_empty_qualified_left_test.go +35 -5
  79. package/shim-vendor/shim/astnav/go.mod +5 -5
  80. package/shim-vendor/shim/astnav/go.sum +12 -10
  81. package/shim-vendor/shim/astnav/shim.go +9 -0
  82. package/shim-vendor/shim/bundled/go.mod +7 -1
  83. package/shim-vendor/shim/bundled/go.sum +12 -0
  84. package/shim-vendor/shim/checker/enums_gen.go +4 -2
  85. package/shim-vendor/shim/checker/extra-shim.json +6 -0
  86. package/shim-vendor/shim/checker/go.mod +5 -5
  87. package/shim-vendor/shim/checker/go.sum +10 -10
  88. package/shim-vendor/shim/checker/node_builder_fields_gen.go +19 -0
  89. package/shim-vendor/shim/checker/shim.go +827 -114
  90. package/shim-vendor/shim/compiler/emit_sourcemap.go +68 -29
  91. package/shim-vendor/shim/compiler/emitassemble.go +36 -2
  92. package/shim-vendor/shim/compiler/emithook.go +13 -3
  93. package/shim-vendor/shim/compiler/go.mod +5 -5
  94. package/shim-vendor/shim/compiler/go.sum +10 -10
  95. package/shim-vendor/shim/compiler/incremental.go +56 -20
  96. package/shim-vendor/shim/compiler/resolution.go +92 -9
  97. package/shim-vendor/shim/core/enums_gen.go +2 -2
  98. package/shim-vendor/shim/core/go.mod +6 -1
  99. package/shim-vendor/shim/core/go.sum +10 -0
  100. package/shim-vendor/shim/core/modulekind.go +9 -0
  101. package/shim-vendor/shim/core/shim.go +157 -6
  102. package/shim-vendor/shim/diagnosticwriter/go.mod +10 -1
  103. package/shim-vendor/shim/diagnosticwriter/go.sum +20 -0
  104. package/shim-vendor/shim/diagnosticwriter/lint.go +188 -10
  105. package/shim-vendor/shim/diagnosticwriter/shim.go +14 -0
  106. package/shim-vendor/shim/lsp/go.mod +5 -5
  107. package/shim-vendor/shim/lsp/go.sum +10 -10
  108. package/shim-vendor/shim/lsp/shim.go +78 -2
  109. package/shim-vendor/shim/parser/go.mod +10 -1
  110. package/shim-vendor/shim/parser/go.sum +22 -0
  111. package/shim-vendor/shim/printer/emithost.go +46 -1
  112. package/shim-vendor/shim/printer/go.mod +5 -5
  113. package/shim-vendor/shim/printer/go.sum +10 -10
  114. package/shim-vendor/shim/printer/shim.go +114 -7
  115. package/shim-vendor/shim/printer/sourcemap.go +55 -0
  116. package/shim-vendor/shim/scanner/go.mod +10 -1
  117. package/shim-vendor/shim/scanner/go.sum +20 -0
  118. package/shim-vendor/shim/scanner/regexp.go +19 -4
  119. package/shim-vendor/shim/scanner/shim.go +3 -0
  120. package/shim-vendor/shim/stringutil/extra-shim.json +1 -0
  121. package/shim-vendor/shim/stringutil/go.mod +5 -0
  122. package/shim-vendor/shim/stringutil/go.sum +2 -0
  123. package/shim-vendor/shim/stringutil/shim.go +119 -0
  124. package/shim-vendor/shim/transformers/go.mod +5 -5
  125. package/shim-vendor/shim/transformers/go.sum +12 -10
  126. package/shim-vendor/shim/transformers/shim.go +12 -3
  127. package/shim-vendor/shim/tsoptions/command_line_raw.go +44 -0
  128. package/shim-vendor/shim/tsoptions/go.mod +10 -1
  129. package/shim-vendor/shim/tsoptions/go.sum +22 -0
  130. package/shim-vendor/shim/tsoptions/shim.go +1 -1
  131. package/shim-vendor/shim/tspath/go.mod +1 -1
  132. package/shim-vendor/shim/tspath/go.sum +6 -0
  133. package/shim-vendor/shim/vfs/cachedvfs/go.mod +3 -1
  134. package/shim-vendor/shim/vfs/cachedvfs/go.sum +12 -0
  135. package/shim-vendor/shim/vfs/decode.go +26 -0
  136. package/shim-vendor/shim/vfs/decode_test.go +42 -0
  137. package/shim-vendor/shim/vfs/go.mod +7 -1
  138. package/shim-vendor/shim/vfs/go.sum +12 -0
  139. package/shim-vendor/shim/vfs/osvfs/go.mod +7 -1
  140. package/shim-vendor/shim/vfs/osvfs/go.sum +12 -0
  141. package/src/BootTtscWorkerTerminationError.ts +22 -0
  142. package/src/MemFSError.ts +29 -2
  143. package/src/bootTtsc.ts +104 -28
  144. package/src/createMemFS.ts +291 -64
  145. package/src/parseResult.ts +19 -0
  146. package/src/structures/IBootResult.ts +21 -2
  147. package/src/structures/IBootTtscOptions.ts +32 -6
  148. package/src/structures/IFileStats.ts +65 -0
  149. package/src/structures/IMemFSHost.ts +97 -0
  150. package/src/structures/ITtscApi.ts +154 -9
  151. package/src/structures/ITtscBuildOpts.ts +19 -1
  152. package/src/structures/ITtscCompileResult.ts +21 -2
  153. package/src/structures/ITtscDiagnostic.ts +32 -1
  154. package/src/structures/ITtscFileQuery.ts +19 -1
  155. package/src/structures/ITtscFountainDiagnosticsResult.ts +20 -1
  156. package/src/structures/ITtscNodeAtPositionResult.ts +18 -1
  157. package/src/structures/ITtscNodeInfo.ts +27 -2
  158. package/src/structures/ITtscPluginOpts.ts +28 -3
  159. package/src/structures/ITtscPositionQuery.ts +21 -4
  160. package/src/structures/ITtscReleaseSnapshotResult.ts +22 -2
  161. package/src/structures/ITtscResult.ts +34 -5
  162. package/src/structures/ITtscSnapshotHandle.ts +19 -1
  163. package/src/structures/ITtscSnapshotResult.ts +22 -1
  164. package/src/structures/ITtscSnapshotsResult.ts +19 -1
  165. package/src/structures/ITtscSourceFileTextResult.ts +19 -1
  166. package/src/structures/ITtscSourceFilesResult.ts +23 -2
  167. package/src/structures/ITtscSymbolAtPositionResult.ts +18 -1
  168. package/src/structures/ITtscSymbolDeclaration.ts +27 -2
  169. package/src/structures/ITtscSymbolInfo.ts +23 -1
  170. package/src/structures/ITtscTransformResult.ts +22 -3
  171. package/src/structures/ITtscTypeAtPositionResult.ts +18 -1
  172. package/src/structures/ITtscTypeInfo.ts +20 -1
  173. package/src/structures/ITtscVersion.ts +33 -1
  174. package/src/structures/IWasmExecFS.ts +336 -0
@@ -13,22 +13,294 @@ import (
13
13
 
14
14
  innerast "github.com/microsoft/typescript-go/internal/ast"
15
15
  innerchecker "github.com/microsoft/typescript-go/internal/checker"
16
+ innernodebuilder "github.com/microsoft/typescript-go/internal/nodebuilder"
16
17
  innerprinter "github.com/microsoft/typescript-go/internal/printer"
17
18
  _ "unsafe"
18
19
  )
19
20
 
21
+ // Checker owns the type graph and semantic queries for one compiler program.
22
+ // Access shared instances under the mutex returned by NewChecker.
23
+ //
24
+ // @evidence contracts/common.md#principled-implementation The exact alias preserves compiler-owned type identity and query state; graph objects must stay associated with the checker that produced them.
25
+ // @evidence contracts/common.md#clear-and-simple-design One upstream checker is the semantic authority, avoiding an independently maintained type graph at the shim boundary.
26
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts The alias exposes supported compiler objects without replacing query methods or synthesizing fixture semantics.
27
+ // @evidence contracts/common.md#meaningful-documentation Native prose states program ownership and caller synchronization instead of implying immutable or thread-safe checker state.
28
+ // @evidenceExclude contracts/performance.md#bound-retention-and-release-resources A type declaration acquires and holds no runtime resource.
29
+ // @evidenceExclude contracts/performance.md#efficient-algorithms A type declaration chooses no processing strategy.
30
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work A type declaration computes nothing, so there is no work to share.
31
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation This type declaration describes a data shape only; it opens no file, builds no path and branches on no platform.
20
32
  type Checker = innerchecker.Checker
33
+
34
+ // IndexInfo describes a compiler index signature, including its key and value types.
35
+ //
36
+ // @evidence contracts/common.md#principled-implementation The alias retains the compiler's key/value type identities and readonly/declaration facts for index-signature semantics.
37
+ // @evidence contracts/common.md#clear-and-simple-design One existing record carries index-signature facts without a lossy shim projection.
38
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts No index key or value is fabricated from consumer conventions.
39
+ // @evidence contracts/common.md#meaningful-documentation Native prose identifies the semantic role and key/value distinction.
40
+ // @evidenceExclude contracts/performance.md#bound-retention-and-release-resources A type declaration acquires and holds no runtime resource.
41
+ // @evidenceExclude contracts/performance.md#efficient-algorithms A type declaration chooses no processing strategy.
42
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work A type declaration computes nothing, so there is no work to share.
43
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation This type declaration describes a data shape only; it opens no file, builds no path and branches on no platform.
21
44
  type IndexInfo = innerchecker.IndexInfo
45
+
46
+ // Signature represents one checked call or construct signature and its parameters.
47
+ // Signature objects belong to their producing Checker.
48
+ //
49
+ // @evidence contracts/common.md#principled-implementation Exact upstream identity preserves instantiated parameters, return and type-parameter relationships needed by checker queries.
50
+ // @evidence contracts/common.md#clear-and-simple-design The compiler's signature object is shared rather than copied into a second overload model.
51
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts The alias preserves semantic signatures rather than inferring them from printed syntax.
52
+ // @evidence contracts/common.md#meaningful-documentation Native prose distinguishes call/construct signatures and states checker ownership.
53
+ // @evidenceExclude contracts/performance.md#bound-retention-and-release-resources A type declaration acquires and holds no runtime resource.
54
+ // @evidenceExclude contracts/performance.md#efficient-algorithms A type declaration chooses no processing strategy.
55
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work A type declaration computes nothing, so there is no work to share.
56
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation This type declaration describes a data shape only; it opens no file, builds no path and branches on no platform.
22
57
  type Signature = innerchecker.Signature
58
+
59
+ // SignatureFlags is the compiler bitmask for signature properties such as rest parameters.
60
+ //
61
+ // @evidence contracts/common.md#principled-implementation The upstream bitmask preserves combinable signature distinctions expected by compiler predicates.
62
+ // @evidence contracts/common.md#clear-and-simple-design One compiler flag representation serves signature queries without shim-specific translation.
63
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts Upstream flag meanings remain unchanged rather than hardcoded from selected examples.
64
+ // @evidence contracts/common.md#meaningful-documentation Native prose identifies bitmask composition and a meaningful signature distinction.
65
+ // @evidenceExclude contracts/performance.md#bound-retention-and-release-resources A type declaration acquires and holds no runtime resource.
66
+ // @evidenceExclude contracts/performance.md#efficient-algorithms A type declaration chooses no processing strategy.
67
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work A type declaration computes nothing, so there is no work to share.
68
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation This type declaration describes a data shape only; it opens no file, builds no path and branches on no platform.
23
69
  type SignatureFlags = innerchecker.SignatureFlags
70
+
71
+ // SignatureKind selects call signatures or construct signatures in checker queries.
72
+ //
73
+ // @evidence contracts/common.md#principled-implementation The enum preserves the two upstream signature populations rather than conflating invocation and construction.
74
+ // @evidence contracts/common.md#clear-and-simple-design One discriminant selects the intended query population.
75
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts The enum expresses language invocation categories without consumer exceptions.
76
+ // @evidence contracts/common.md#meaningful-documentation Native prose names both selectable signature categories.
77
+ // @evidenceExclude contracts/performance.md#bound-retention-and-release-resources A type declaration acquires and holds no runtime resource.
78
+ // @evidenceExclude contracts/performance.md#efficient-algorithms A type declaration chooses no processing strategy.
79
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work A type declaration computes nothing, so there is no work to share.
80
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation This type declaration describes a data shape only; it opens no file, builds no path and branches on no platform.
24
81
  type SignatureKind = innerchecker.SignatureKind
82
+
83
+ // Type is a compiler semantic type, including instantiated and composite types.
84
+ // It belongs to its producing Checker and is not a serialized AST node.
85
+ //
86
+ // @evidence contracts/common.md#principled-implementation Exact type identity retains compiler links among unions, intersections, references and instantiations; its discriminants govern which payload is valid.
87
+ // @evidence contracts/common.md#clear-and-simple-design The alias keeps semantic representation with the compiler instead of building a parallel shim type system.
88
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts No semantic type is reconstructed from consumer names or printed text.
89
+ // @evidence contracts/common.md#meaningful-documentation Native prose states semantic versus syntax identity and producing-checker ownership.
90
+ // @evidenceExclude contracts/performance.md#bound-retention-and-release-resources A type declaration acquires and holds no runtime resource.
91
+ // @evidenceExclude contracts/performance.md#efficient-algorithms A type declaration chooses no processing strategy.
92
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work A type declaration computes nothing, so there is no work to share.
93
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation This type declaration describes a data shape only; it opens no file, builds no path and branches on no platform.
25
94
  type Type = innerchecker.Type
95
+
96
+ // TypeAlias retains a semantic type alias's symbol and instantiated arguments.
97
+ // Obtain it from Type.Alias; its read-only accessors accept a nil alias.
98
+ //
99
+ // @evidence contracts/common.md#principled-implementation Exact alias identity preserves compiler-owned symbol and type-argument provenance exposed by Type.Alias.
100
+ // @evidence contracts/common.md#clear-and-simple-design One upstream record exposes existing semantic metadata without duplicating checker state.
101
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts Alias metadata comes from a checked Type rather than reconstructed declaration names.
102
+ // @evidence contracts/common.md#meaningful-documentation Native prose identifies metadata, its producer and nil-safe accessor behavior.
103
+ // @evidenceExclude contracts/performance.md#bound-retention-and-release-resources A type declaration acquires and holds no runtime resource.
104
+ // @evidenceExclude contracts/performance.md#efficient-algorithms A type declaration chooses no processing strategy.
105
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work A type declaration computes nothing, so there is no work to share.
106
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation This type declaration describes a data shape only; it opens no file, builds no path and branches on no platform.
107
+ type TypeAlias = innerchecker.TypeAlias
108
+
109
+ // NodeBuilderImpl serializes checked types within an active builder context.
110
+ // Obtain it only inside WithNodeBuilderContext and do not retain it afterward.
111
+ //
112
+ // @evidence contracts/common.md#principled-implementation Exact upstream identity preserves the checker, emit factory and active serialization context required by TypeAlias.ToTypeReferenceNode.
113
+ // @evidence contracts/common.md#clear-and-simple-design A borrowed compiler implementation serves the existing metadata conversion without another semantic serializer.
114
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts The implementation comes from the upstream builder with a real entered context; a nil-context constructor is not presented as usable state.
115
+ // @evidence contracts/common.md#meaningful-documentation Native prose states the callback producer and forbids retaining the context-bound value beyond its lifetime.
116
+ // @evidenceExclude contracts/performance.md#bound-retention-and-release-resources A type declaration acquires and holds no runtime resource.
117
+ // @evidenceExclude contracts/performance.md#efficient-algorithms A type declaration chooses no processing strategy.
118
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work A type declaration computes nothing, so there is no work to share.
119
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation This type declaration describes a data shape only; it opens no file, builds no path and branches on no platform.
120
+ type NodeBuilderImpl = innerchecker.NodeBuilderImpl
121
+
122
+ // WithNodeBuilderContext converts checked metadata in a fresh builder context.
123
+ // Hold the producing checker's mutex, supply this emit round's context, and
124
+ // use an enclosing declaration from that same program (or nil). The callback
125
+ // must not retain the borrowed implementation or use it concurrently.
126
+ // Checker, emit context and callback must be nonnil and valid for this round.
127
+ //
128
+ // The compiler's default serialization flags and tracker apply. Callback
129
+ // errors are returned unchanged; compiler serialization errors return a nil
130
+ // node. After context entry succeeds, restoration runs on success, callback
131
+ // error and panic. Restoring the active context does not release the caller's
132
+ // emit factory or invalidate a returned node; that lifetime remains its owner's.
133
+ //
134
+ // @evidence contracts/common.md#principled-implementation NewNodeBuilder and its real enter/exit operations establish the host, tracker and enclosing-file context before the generated private field accessor supplies the implementation.
135
+ // @evidence contracts/common.md#clear-and-simple-design A scoped callback separates compiler-state acquisition from caller conversion while a fresh builder owns each nested invocation.
136
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts No private layout is handwritten or patched, and no unusable raw getter is published as a producer; official generation derives the one required field access.
137
+ // @evidence contracts/common.md#meaningful-documentation Native prose states synchronization, program and emit identity, default flags, borrowing limits, nil result and error/panic restoration.
138
+ // @evidence contracts/performance.md#bound-retention-and-release-resources Each call acquires a builder/implementation, context stack and semantic bookkeeping maps/slices. Deferred pop restores active context after callback failure or panic; exit restores it on normal completion. Borrowed implementation use ends at that boundary, while returned nodes and emit-factory allocations remain under caller ownership. This helper neither releases that factory's arenas nor bounds retained callback results.
139
+ // @evidence contracts/performance.md#efficient-algorithms A fresh builder isolates nested callback contexts without cloning the semantic graph. Construction creates bookkeeping storage, context entry finds the enclosing source file through parent links, and the callback's conversion can traverse arbitrary supported type/AST graphs; total work is not constant merely because the callback is invoked once. The scoped wrapper avoids a separate serializer and leaves conversion algorithms upstream.
140
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work This helper coordinates a borrowed context lifetime rather than completed or in-flight conversion sharing. Active callback state is isolated per invocation; semantic reuse belongs to the supplied checker, and no independent context-result cache/invalidation policy is installed.
141
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation Works on in-memory compiler nodes only; it accesses no path or filesystem.
142
+ func WithNodeBuilderContext(ch *Checker, emitContext *innerprinter.EmitContext, enclosing *innerast.Node, use func(*NodeBuilderImpl) (*innerast.Node, error)) (*innerast.Node, error) {
143
+ builder := innerchecker.NewNodeBuilder(ch, emitContext)
144
+ nodeBuilderEnterContext(builder, enclosing, innernodebuilder.FlagsNone, innernodebuilder.InternalFlagsNone, nil)
145
+ exited := false
146
+ defer func() {
147
+ if !exited {
148
+ nodeBuilderPopContext(builder)
149
+ }
150
+ }()
151
+ node, err := use(nodeBuilder_impl(builder))
152
+ if err != nil {
153
+ return nil, err
154
+ }
155
+ node = nodeBuilderExitContext(builder, node)
156
+ exited = true
157
+ return node, nil
158
+ }
159
+
160
+ //go:linkname nodeBuilderEnterContext github.com/microsoft/typescript-go/internal/checker.(*NodeBuilder).enterContext
161
+ func nodeBuilderEnterContext(*innerchecker.NodeBuilder, *innerast.Node, innernodebuilder.Flags, innernodebuilder.InternalFlags, innernodebuilder.SymbolTracker)
162
+
163
+ //go:linkname nodeBuilderExitContext github.com/microsoft/typescript-go/internal/checker.(*NodeBuilder).exitContext
164
+ func nodeBuilderExitContext(*innerchecker.NodeBuilder, *innerast.Node) *innerast.Node
165
+
166
+ //go:linkname nodeBuilderPopContext github.com/microsoft/typescript-go/internal/checker.(*NodeBuilder).popContext
167
+ func nodeBuilderPopContext(*innerchecker.NodeBuilder)
168
+
169
+ // IsTypeUsableAsPropertyName reports whether t is a string or number literal
170
+ // or a unique symbol type. t must be a nonnil compiler semantic type.
171
+ //
172
+ // @evidence contracts/common.md#principled-implementation The upstream semantic flag test preserves literal and unique-symbol property-name eligibility.
173
+ // @evidence contracts/common.md#clear-and-simple-design One predicate qualifies inputs to GetPropertyNameFromType without another type classifier.
174
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts Eligibility follows actual type flags rather than printed type spelling.
175
+ // @evidence contracts/common.md#meaningful-documentation Native prose names supported semantic categories and nonnil input.
176
+ // @evidenceExclude contracts/performance.md#bound-retention-and-release-resources IsTypeUsableAsPropertyName acquires no handle, buffer or cache and retains nothing after it returns.
177
+ // @evidenceExclude contracts/performance.md#efficient-algorithms The upstream literal/unique-symbol flag classifier owns eligibility; this shim forwards the type without choosing a second name-decoding or graph-search strategy.
178
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work The predicate reads existing type flags and coordinates no completed or in-flight producer, cache or invalidation across requests.
179
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation IsTypeUsableAsPropertyName computes from its arguments only; it opens no file, builds no path and calls no platform or process API.
180
+ func IsTypeUsableAsPropertyName(t *Type) bool {
181
+ return innerchecker.IsTypeUsableAsPropertyName(t)
182
+ }
183
+
184
+ // GetPropertyNameFromType returns a literal or unique-symbol property's
185
+ // compiler name. t must satisfy IsTypeUsableAsPropertyName; other types panic.
186
+ // The input must be a nonnil compiler type with its matching payload. String
187
+ // and unique-symbol names use existing text; numeric literals use the upstream
188
+ // JavaScript-number spelling, including its special values.
189
+ //
190
+ // @evidence contracts/common.md#principled-implementation Upstream literal-value and unique-symbol decoding preserves semantic property identity and numeric spelling.
191
+ // @evidence contracts/common.md#clear-and-simple-design One decoder consumes the adjacent eligibility predicate's qualified semantic input.
192
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts Property identity is not guessed from source text or converted from unsupported types.
193
+ // @evidence contracts/common.md#meaningful-documentation Native prose states the qualification requirement and unsupported-type panic.
194
+ // @evidence contracts/performance.md#bound-retention-and-release-resources The caller receives existing name storage for string/unique-symbol types or newly formatted numeric text; retaining that string retains its bytes, not a shim-owned history. Upstream numeric formatting owns any temporary serialization bytes. The bridge opens no handle and keeps no independent name registry.
195
+ // @evidenceExclude contracts/performance.md#efficient-algorithms Upstream property-name decoding owns type-flag dispatch and numeric spelling, including integer formatting or JSON number serialization. Existing strings are returned without traversal; numeric conversion/output cost belongs to that formatter rather than a second shim encoding strategy.
196
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work The decoder transfers the type's name or numeric spelling and coordinates no repeated semantic producer, cache or invalidation across requests.
197
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation GetPropertyNameFromType computes from its arguments only; it opens no file, builds no path and calls no platform or process API.
198
+ func GetPropertyNameFromType(t *Type) string {
199
+ return innerchecker.GetPropertyNameFromType(t)
200
+ }
201
+
202
+ // GetSetAccessorValueParameter returns the value parameter of a setter,
203
+ // accounting for an explicit this parameter. accessor must be a setter node.
204
+ // The upstream rule selects the second parameter only when there are exactly
205
+ // two and the first is a this parameter; otherwise it selects the first, or nil
206
+ // for an empty parameter list. It does not validate malformed setter arity.
207
+ //
208
+ // @evidence contracts/common.md#principled-implementation Delegation preserves upstream setter-parameter selection and explicit-this handling.
209
+ // @evidence contracts/common.md#clear-and-simple-design One syntax query exposes the compiler's existing accessor convention.
210
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts Parameter selection follows actual setter syntax rather than a fixed consumer name.
211
+ // @evidence contracts/common.md#meaningful-documentation Native prose identifies the setter premise and explicit-this distinction.
212
+ // @evidence contracts/performance.md#bound-retention-and-release-resources The caller receives an existing parameter node, whose parent links can retain its source AST. The supplied AST owner controls that lifetime; this bridge allocates no parameter copy and keeps no additional node registry or handle.
213
+ // @evidenceExclude contracts/performance.md#efficient-algorithms The upstream syntax helper owns direct list-length inspection and first/second parameter selection without scanning the list. This wrapper forwards the node and does not select a competing parameter-search or validation algorithm.
214
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work The helper projects existing syntax and coordinates no completed or in-flight producer, cache or invalidation across requests.
215
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation GetSetAccessorValueParameter computes from its arguments only; it opens no file, builds no path and calls no platform or process API.
216
+ func GetSetAccessorValueParameter(accessor *innerast.Node) *innerast.Node {
217
+ return innerchecker.GetSetAccessorValueParameter(accessor)
218
+ }
219
+
220
+ // TypeMapper is the compiler's type-parameter substitution mapping.
221
+ //
222
+ // @evidence contracts/common.md#principled-implementation The alias preserves the compiler's simple, array and composite substitution representations and their source/target type identity.
223
+ // @evidence contracts/common.md#clear-and-simple-design Substitution uses the compiler's existing mapper model across construction and instantiation wrappers.
224
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts No ad hoc name-based substitution or foreign instantiator replacement is introduced.
225
+ // @evidence contracts/common.md#meaningful-documentation Native prose identifies semantic type-parameter substitution rather than a generic object map.
226
+ // @evidenceExclude contracts/performance.md#bound-retention-and-release-resources A type declaration acquires and holds no runtime resource.
227
+ // @evidenceExclude contracts/performance.md#efficient-algorithms A type declaration chooses no processing strategy.
228
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work A type declaration computes nothing, so there is no work to share.
229
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation This type declaration describes a data shape only; it opens no file, builds no path and branches on no platform.
26
230
  type TypeMapper = innerchecker.TypeMapper
231
+
232
+ // TypeMapperKind reports the compiler mapper's Simple, Array, Merged or default
233
+ // Unknown classification. It does not uniquely identify every concrete mapper
234
+ // implementation; a Composite mapper inherits the default Unknown kind.
235
+ //
236
+ // @evidence contracts/common.md#principled-implementation The exact enum preserves upstream Kind reporting without treating default Unknown as a unique concrete payload or replacing polymorphic Map dispatch.
237
+ // @evidence contracts/common.md#clear-and-simple-design The same kind representation connects mapper constructors and consumers without a shim discriminator.
238
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts Compiler mapper variants are retained without selecting consumer-specific behavior.
239
+ // @evidence contracts/common.md#meaningful-documentation Native prose lists reported kinds and the nonunique Unknown boundary rather than promising a complete concrete-representation discriminator.
240
+ // @evidenceExclude contracts/performance.md#bound-retention-and-release-resources A type declaration acquires and holds no runtime resource.
241
+ // @evidenceExclude contracts/performance.md#efficient-algorithms A type declaration chooses no processing strategy.
242
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work A type declaration computes nothing, so there is no work to share.
243
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation This type declaration describes a data shape only; it opens no file, builds no path and branches on no platform.
27
244
  type TypeMapperKind = innerchecker.TypeMapperKind
245
+
246
+ // TypeFlags is the compiler bitmask describing semantic type categories.
247
+ //
248
+ // @evidence contracts/common.md#principled-implementation The upstream bitmask preserves semantic category combinations used to interpret type payloads and choose checker operations.
249
+ // @evidence contracts/common.md#clear-and-simple-design One native flag vocabulary connects the compiler and its plugin consumers.
250
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts Flags are not inferred from textual type spelling or rewritten for fixtures.
251
+ // @evidence contracts/common.md#meaningful-documentation Native prose distinguishes semantic categories and bitmask representation.
252
+ // @evidenceExclude contracts/performance.md#bound-retention-and-release-resources A type declaration acquires and holds no runtime resource.
253
+ // @evidenceExclude contracts/performance.md#efficient-algorithms A type declaration chooses no processing strategy.
254
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work A type declaration computes nothing, so there is no work to share.
255
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation This type declaration describes a data shape only; it opens no file, builds no path and branches on no platform.
28
256
  type TypeFlags = innerchecker.TypeFlags
257
+
258
+ // ObjectFlags is the compiler bitmask refining object types, including references and tuples.
259
+ //
260
+ // @evidence contracts/common.md#principled-implementation The alias preserves object-specific flags distinct from general TypeFlags, matching upstream reference and tuple payload interpretation.
261
+ // @evidence contracts/common.md#clear-and-simple-design Object refinement remains in the compiler's established flag layer rather than a new shim taxonomy.
262
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts The representation retains real object-category flags without guessing from declaration names.
263
+ // @evidence contracts/common.md#meaningful-documentation Native prose identifies object refinement and examples relevant to exposed tuple queries.
264
+ // @evidenceExclude contracts/performance.md#bound-retention-and-release-resources A type declaration acquires and holds no runtime resource.
265
+ // @evidenceExclude contracts/performance.md#efficient-algorithms A type declaration chooses no processing strategy.
266
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work A type declaration computes nothing, so there is no work to share.
267
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation This type declaration describes a data shape only; it opens no file, builds no path and branches on no platform.
29
268
  type ObjectFlags = innerchecker.ObjectFlags
269
+
270
+ // ElementFlags is the compiler bitmask for required, optional, rest and variadic tuple elements.
271
+ //
272
+ // @evidence contracts/common.md#principled-implementation Preserving tuple element flags retains positional optionality and variadic distinctions needed by compiler tuple semantics.
273
+ // @evidence contracts/common.md#clear-and-simple-design Existing compiler flags describe tuple elements without separate shim metadata.
274
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts Tuple categories are not reduced to a guessed fixed-length representation.
275
+ // @evidence contracts/common.md#meaningful-documentation Native prose explicitly lists required, optional, rest and variadic meanings.
276
+ // @evidenceExclude contracts/performance.md#bound-retention-and-release-resources A type declaration acquires and holds no runtime resource.
277
+ // @evidenceExclude contracts/performance.md#efficient-algorithms A type declaration chooses no processing strategy.
278
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work A type declaration computes nothing, so there is no work to share.
279
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation This type declaration describes a data shape only; it opens no file, builds no path and branches on no platform.
30
280
  type ElementFlags = innerchecker.ElementFlags
281
+
282
+ // Program is the semantic input interface required to construct an upstream Checker.
283
+ //
284
+ // @evidence contracts/common.md#principled-implementation The exact interface alias retains the source/options and resolution capabilities the checker expects from its program.
285
+ // @evidence contracts/common.md#clear-and-simple-design Checker construction consumes the compiler's existing program boundary without a second adapter contract.
286
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts A caller implements the real compiler interface rather than replacing checker internals.
287
+ // @evidence contracts/common.md#meaningful-documentation Native prose identifies the checker-construction role and interface nature.
288
+ // @evidenceExclude contracts/performance.md#bound-retention-and-release-resources A type declaration acquires and holds no runtime resource.
289
+ // @evidenceExclude contracts/performance.md#efficient-algorithms A type declaration chooses no processing strategy.
290
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work A type declaration computes nothing, so there is no work to share.
291
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation This type declaration describes a data shape only; it opens no file, builds no path and branches on no platform.
31
292
  type Program = innerchecker.Program
293
+
294
+ // Tracer carries the compiler's optional semantic tracing state for a Checker.
295
+ //
296
+ // @evidence contracts/common.md#principled-implementation The exact alias preserves tracing state expected by upstream checker construction without interpreting diagnostic events independently.
297
+ // @evidence contracts/common.md#clear-and-simple-design Optional tracing remains a compiler-owned concern passed through NewChecker.
298
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts The alias introduces no injected expected trace or global tracer replacement.
299
+ // @evidence contracts/common.md#meaningful-documentation Native prose identifies optional tracing and its checker context.
300
+ // @evidenceExclude contracts/performance.md#bound-retention-and-release-resources A type declaration acquires and holds no runtime resource.
301
+ // @evidenceExclude contracts/performance.md#efficient-algorithms A type declaration chooses no processing strategy.
302
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work A type declaration computes nothing, so there is no work to share.
303
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation This type declaration describes a data shape only; it opens no file, builds no path and branches on no platform.
32
304
  type Tracer = innerchecker.Tracer
33
305
 
34
306
  //go:linkname checkerNewAnonymousType github.com/microsoft/typescript-go/internal/checker.(*Checker).newAnonymousType
@@ -55,17 +327,30 @@ func checkerArePropertiesAbstractOrInterface(
55
327
  ) bool
56
328
 
57
329
  // Checker_isPropertyAssignableTo asks the upstream assignability relater about
58
- // exactly one source/target property pair. The anonymous types retain the
330
+ // one source/target property pair admitted by the upstream named value-member
331
+ // filter. Reserved internal members and symbols without value meaning are not
332
+ // supported property inputs. The anonymous types retain the
59
333
  // original property symbols, so propertyRelatedTo still enforces instantiated
60
334
  // generic types, overloads, optionality, and private/protected declaration
61
335
  // origins without an unrelated sibling member participating in the result.
336
+ // The symbols must have the same name and belong to recv's type graph. A
337
+ // shared checker requires caller-owned synchronization.
338
+ //
339
+ // @evidence contracts/common.md#principled-implementation Single-member anonymous types retain the original named value-property symbols so upstream structural assignability applies generic, optional and visibility semantics to that member pair; both symbols must originate in the supplied checker and pass its named-member filter.
340
+ // @evidence contracts/common.md#clear-and-simple-design Two minimal anonymous type views isolate one relation without rewriting the upstream property relater or introducing sibling-dependent results.
341
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts Anonymous types use the compiler's constructor rather than monkey patching its relater; equal names include valid empty-string property symbols rather than treating an empty spelling as a missing-symbol sentinel.
342
+ // @evidence contracts/common.md#meaningful-documentation Native paragraphs explain retained-symbol semantics, same-name/type-graph premises and caller synchronization rather than promising a syntax-only override check.
343
+ // @evidence contracts/performance.md#bound-retention-and-release-resources Each call acquires two one-entry symbol maps and anonymous type views with property slices; the supplied checker owns type allocation and relation state, which can outlive this boolean result. These views retain original symbols instead of copying their graphs; the caller controls the checker's lifetime, and this bridge imposes no independent historical-state bound.
344
+ // @evidence contracts/performance.md#efficient-algorithms Two single-member views isolate the selected pair without cloning or scanning its containing types. Name equality and map keys depend on name bytes; view setup is bounded in member count, but delegated assignability can traverse property types, signatures and declaration origins and use checker relation state. The boolean wrapper does not make that semantic work constant-time.
345
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work Upstream checker relation caches own reuse of semantic comparisons. This bridge supplies fresh single-member views preserving symbol identity and does not coordinate a separate cross-request pair cache or its invalidation.
346
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation This bridge constructs semantic views from the supplied checker graph and delegates its relation; it does not select a filesystem, executable or platform policy independently of that graph's producer.
62
347
  func Checker_isPropertyAssignableTo(
63
348
  recv *innerchecker.Checker,
64
349
  sourceProperty *innerast.Symbol,
65
350
  targetProperty *innerast.Symbol,
66
351
  ) bool {
67
352
  if recv == nil || sourceProperty == nil || targetProperty == nil ||
68
- sourceProperty.Name == "" || sourceProperty.Name != targetProperty.Name {
353
+ sourceProperty.Name != targetProperty.Name {
69
354
  return false
70
355
  }
71
356
  source := checkerNewAnonymousType(
@@ -92,6 +377,22 @@ func Checker_isPropertyAssignableTo(
92
377
  // structural assignability permits more shapes than a class extends clause:
93
378
  // notably a concrete property/accessor cannot be replaced by a method, while a
94
379
  // base method may be replaced by a function-valued property.
380
+ // The symbols must belong to the supplied checker and represent direct class
381
+ // members. This predicate checks member kind, not type assignability.
382
+ // Same target identity returns false because no distinct override pair exists.
383
+ // The result does not perform the full class check: private-member handling,
384
+ // inherited abstract implementation and class-field overwrite diagnostics are
385
+ // outside this selected member-kind rule. A shared checker needs caller-owned
386
+ // synchronization.
387
+ //
388
+ // @evidence contracts/common.md#principled-implementation Resolving target symbols and applying the pinned checkKindsOfPropertyMemberOverrides flags preserves direct-class property/accessor/method constraints; structural assignability is a separate required relation.
389
+ // @evidence contracts/common.md#clear-and-simple-design One direct-pair predicate exposes member-kind legality independently from Checker_isPropertyAssignableTo, so callers can require both without importing internal flag policy.
390
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts Assignment and abstract/interface exceptions are upstream class-member semantics; the mapped-property exception is absent because a direct class base member cannot be mapped.
391
+ // @evidence contracts/common.md#meaningful-documentation Native prose contrasts class inheritance with structural assignment and states direct-member, same-checker and kind-only limits.
392
+ // @evidenceExclude contracts/performance.md#bound-retention-and-release-resources The boolean predicate keeps no symbols, tasks or result collection after return. Instantiated-symbol target links and declaration/modifier metadata belong to the supplied checker and AST; this predicate does not independently acquire or release their graph lifetime.
393
+ // @evidence contracts/performance.md#efficient-algorithms Direct target/flag comparisons isolate this pair without traversing sibling members or running the full class diagnostic pass. Upstream modifier selection may scan accessor declarations and their modifier syntax, and abstract/interface checks short-circuit over base declarations; their declaration and syntax populations, rather than only the wrapper's branch count, determine cost.
394
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work Upstream target links and AST modifier state supply the semantic metadata; this selected kind predicate owns neither a cross-request override producer nor a cache/invalidation policy for a class check.
395
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation This predicate interprets the supplied checker/AST member metadata and introduces no independent filesystem, executable or platform policy.
95
396
  func Checker_isValidClassMemberOverridePair(
96
397
  recv *innerchecker.Checker,
97
398
  derivedProperty *innerast.Symbol,
@@ -131,9 +432,20 @@ func Checker_isValidClassMemberOverridePair(
131
432
  return false
132
433
  }
133
434
 
134
- // NewChecker creates a checker that owns its complete type graph for program.
135
- // The returned mutex is the upstream checker-pool synchronization primitive;
435
+ // NewChecker binds the supplied program and initializes a checker with its
436
+ // source files, global symbols and semantic caches. Later queries can resolve
437
+ // more of its type graph lazily and produce diagnostics.
438
+ // The returned mutex belongs to that newly created upstream checker;
136
439
  // callers that share the checker must serialize access through it.
440
+ //
441
+ // @evidence contracts/common.md#principled-implementation Delegating construction keeps the checker, its program-dependent type graph and returned synchronization primitive paired under the upstream program interface.
442
+ // @evidence contracts/common.md#clear-and-simple-design One constructor returns the semantic object and its lock together without a duplicate graph or locking layer.
443
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts Construction uses the actual supplied program and optional tracer rather than a foreign checker replacement or synthetic semantic result.
444
+ // @evidence contracts/common.md#meaningful-documentation Native prose states binding/initialization, lazy semantic work and caller serialization through the checker's own mutex without claiming an already complete graph or a pool-owned lock.
445
+ // @evidence contracts/performance.md#bound-retention-and-release-resources Construction transfers a checker and its mutex to the caller. The checker retains its program/source ASTs, symbol/type state, caches, diagnostics and optional tracer; later semantic work can grow that population. The caller/program owner controls their lifetime, and this constructor supplies no independent cache eviction or disposal bound.
446
+ // @evidenceExclude contracts/performance.md#efficient-algorithms Upstream construction owns program binding, source-file indexing, global-symbol merging, augmentation and intrinsic/global type initialization. File, declaration and symbol populations drive that work; this shim delegates without selecting a second initialization algorithm or claiming constant cost.
447
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work Program binding and checker semantic caches own upstream reuse. This constructor does not coordinate a separate checker pool, shared producer or cross-program invalidation policy; callers determine whether the transferred checker is shared under its mutex.
448
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation Delegates to the upstream checker constructor; the shim handles no path or file.
137
449
  func NewChecker(program Program, tracer *Tracer) (*Checker, *sync.Mutex) {
138
450
  return innerchecker.NewChecker(program, tracer)
139
451
  }
@@ -145,6 +457,19 @@ func checkerGetRegularTypeOfLiteralType(recv *innerchecker.Checker, t *innerchec
145
457
  // literal type. TypeScript's checker uses this before comparing switch case
146
458
  // types because a source literal's fresh type and a union member's regular type
147
459
  // denote the same runtime value but have different pointers.
460
+ // Unions regularize their constituent types through upstream mapping and cache
461
+ // the result; other type categories pass through. Nonnil types must belong to
462
+ // recv's checker graph when recv is supplied.
463
+ // Nil checker or type leaves the supplied type unchanged.
464
+ //
465
+ // @evidence contracts/common.md#principled-implementation The pinned regular-literal helper canonicalizes fresh literal identity while preserving its semantic value, making pointer-based comparison use the same representation as union members.
466
+ // @evidence contracts/common.md#clear-and-simple-design One guarded bridge exposes compiler canonicalization without duplicating literal interning or conversion rules.
467
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts The nil fallback preserves the input rather than constructing a desired literal; actual canonicalization remains with the producing compiler checker.
468
+ // @evidence contracts/common.md#meaningful-documentation Native prose explains fresh-versus-regular pointer identity, runtime meaning and nil input preservation.
469
+ // @evidence contracts/performance.md#bound-retention-and-release-resources The caller receives an existing type or checker-owned regular type and can retain its semantic graph. Upstream union mapping owns temporary constituent slices and the cached regularType result; this wrapper keeps no independent result, buffer or handle.
470
+ // @evidenceExclude contracts/performance.md#efficient-algorithms The wrapper's nil guards select no canonicalization strategy. Upstream fresh-literal access is direct, but uncached unions map constituent/origin lists recursively and can reconstruct a reduced union; their traversal, allocation and reduction costs belong to that checker implementation.
471
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work Literal regularType references and union regularType caching own canonical reuse upstream. The forwarding wrapper adds no type cache or coordination of repeated canonicalization.
472
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation Type canonicalization uses the supplied checker graph; this wrapper introduces no path, host or platform policy.
148
473
  func Checker_getRegularTypeOfLiteralType(recv *innerchecker.Checker, t *innerchecker.Type) *innerchecker.Type {
149
474
  if recv == nil || t == nil {
150
475
  return t
@@ -158,17 +483,45 @@ func Checker_getRegularTypeOfLiteralType(recv *innerchecker.Checker, t *innerche
158
483
  // enumerating a literal union reports the values the way the compiler prints
159
484
  // them, including numeric formatting and string escaping it should not re-derive.
160
485
  //
161
- // It panics on a value it does not handle — notably the nil a computed enum
162
- // member carries — so a caller holding a `LiteralType.Value()` must reject nil
486
+ // It panics on a value it does not handle, notably the nil a computed enum
487
+ // member carries, so a caller holding a `LiteralType.Value()` must reject nil
163
488
  // before calling this.
489
+ // Accepted runtime values are string, jsnum.Number, bool and jsnum.PseudoBigInt;
490
+ // ordinary Go numeric values and other representations are not accepted.
491
+ // This delegates the compiler's spelling, including nonfinite-number text,
492
+ // rather than preserving the original source token or validating arbitrary data.
493
+ //
494
+ // @evidence contracts/common.md#principled-implementation Delegating supported literal values to the checker's renderer preserves TypeScript escaping and numeric spelling; unsupported runtime values remain outside its domain and panic.
495
+ // @evidence contracts/common.md#clear-and-simple-design One renderer bridge centralizes compiler literal syntax without a separate shim serializer.
496
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts Values are formatted from actual compiler data, with no expected string table or special-case enum member names.
497
+ // @evidence contracts/common.md#meaningful-documentation Native paragraphs state source-form output and the unsupported/nil-value panic boundary with explanatory context.
498
+ // @evidence contracts/performance.md#bound-retention-and-release-resources The caller receives constant boolean/special-value text or formatted string/number/bigint storage. Upstream escaping and numeric serialization own temporary builders/bytes; the bridge retains no output registry or handle. Retaining the result retains its backing text, whose size depends on input and escaping rather than a fixed wrapper branch count.
499
+ // @evidenceExclude contracts/performance.md#efficient-algorithms Upstream value dispatch, JavaScript-string escaping and number/bigint spelling own the algorithms. Escaping scans input bytes and emits expanded text; numeric conversion and bigint sign/suffix construction have their own output costs. This forwarding bridge selects no separate serializer or escaping strategy.
500
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work The renderer transfers a formatted value and coordinates no completed or in-flight producer, output cache or cross-request invalidation policy.
501
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation ValueToString computes from its arguments only; it opens no file, builds no path and calls no platform or process API.
164
502
  func ValueToString(value any) string {
165
503
  return innerchecker.ValueToString(value)
166
504
  }
167
505
 
168
- // Checker_typeToStringFullyQualified formats a type with the same stable,
169
- // alias-aware flags TypeScript uses in diagnostics that name union members.
506
+ // Checker_typeToStringFullyQualified requests unique-symbol, external-alias
507
+ // and fully qualified presentation from the upstream type formatter.
170
508
  // Keeping the flag bundle inside the shim avoids leaking checker-internal enum
171
509
  // types through consumer code.
510
+ // Nil checker or type returns empty text. A nonnil type must belong to recv.
511
+ // The optional enclosing declaration must belong to its program. This remains
512
+ // diagnostic presentation: upstream output can be truncated or return its
513
+ // serialization-depth marker, and is not a unique type-identity certificate.
514
+ // Lazy member resolution can update checker state or produce diagnostics;
515
+ // callers sharing the checker must synchronize access.
516
+ //
517
+ // @evidence contracts/common.md#principled-implementation AllowUniqueESSymbolType, UseAliasDefinedOutsideCurrentScope and UseFullyQualifiedType preserve unique-symbol and externally defined alias naming at the supplied declaration scope; this is a presentation query over the producing checker.
518
+ // @evidence contracts/common.md#clear-and-simple-design One named formatting policy owns its flags, leaving graph consumers independent of internal formatting enums.
519
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts Flags are compiler-defined formatting controls rather than patches to type identity or consumer-specific output strings.
520
+ // @evidence contracts/common.md#meaningful-documentation Native prose explains alias-aware scope, flag ownership, nil output and same-checker requirements.
521
+ // @evidence contracts/performance.md#bound-retention-and-release-resources The caller receives generated text storage; truncating the returned slice is not proof that its backing storage has that size. Upstream formatting acquires a text writer and builder arenas, defers arena release and verbosity restoration, and keeps its builder and semantic-resolution caches under checker ownership. This bridge keeps no separate output history or resource-release policy.
522
+ // @evidenceExclude contracts/performance.md#efficient-algorithms Upstream lazy type/member resolution, node construction and printing own the semantic-graph, generated-node and text-byte costs, including serialization-depth and output-length policy. The shim selects a flag bundle rather than implementing or claiming constant-time type traversal.
523
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work The checker-owned builder and semantic caches coordinate upstream reuse. This wrapper introduces no independent formatted-text cache or shared producer whose validity it would establish across scopes or programs.
524
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation Type presentation follows the supplied program's semantic graph, module authority and compiler options; this bridge chooses no independent filesystem, executable or platform policy.
172
525
  func Checker_typeToStringFullyQualified(recv *innerchecker.Checker, t *innerchecker.Type, enclosingDeclaration *innerast.Node) string {
173
526
  if recv == nil || t == nil {
174
527
  return ""
@@ -186,6 +539,20 @@ func Checker_typeToStringFullyQualified(recv *innerchecker.Checker, t *innerchec
186
539
  // Checker_symbolToValueString formats a symbol as a value-position expression
187
540
  // at enclosingDeclaration. AllowAnyNodeKind lets the checker emit indexed
188
541
  // access for enum members whose names cannot use dot notation.
542
+ // Nil checker or symbol returns empty text. Symbols must belong to recv.
543
+ // An enclosing declaration must belong to its program. This is presentation,
544
+ // not an accessibility or runtime-evaluation certificate. The formatter uses
545
+ // upstream ignore-error node building; callers sharing the checker synchronize
546
+ // access to its builder and semantic state.
547
+ //
548
+ // @evidence contracts/common.md#principled-implementation Value meaning and AllowAnyNodeKind delegate expression spelling to the checker's symbol formatter, allowing indexed access where an identifier-like name is unavailable.
549
+ // @evidence contracts/common.md#clear-and-simple-design One wrapper owns value-position formatting policy without manual namespace concatenation or an AST printer fallback.
550
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts Indexed member spelling comes from the compiler's real symbol representation rather than a consumer-name escape table.
551
+ // @evidence contracts/common.md#meaningful-documentation Native prose explains expression-position output, indexed access and nil/same-checker limits before the tags.
552
+ // @evidence contracts/performance.md#bound-retention-and-release-resources The caller receives generated string storage. Upstream formatting acquires a pooled writer and builder arenas, defers writer return and arena release, and retains the checker-owned builder and semantic caches for their owner lifetime. Returning a writer to its pool is not a bound on retained output bytes or pooled storage; this bridge owns no separate formatting registry.
553
+ // @evidenceExclude contracts/performance.md#efficient-algorithms Upstream chain lookup, recursive expression construction, identifier/name inspection and printing own the algorithm and its symbol-chain, declaration, generated-node and text-byte costs. The bridge selects value meaning and AllowAnyNodeKind but implements no second spelling or traversal algorithm.
554
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work Writer pooling, the checker-owned builder and semantic chain caches own reuse upstream. This bridge coordinates no additional formatting producer or cached string whose validity it would establish across programs.
555
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation Formatting follows the supplied program's symbol, alias and module authority; this bridge adds no independent filesystem, executable or platform selection.
189
556
  func Checker_symbolToValueString(recv *innerchecker.Checker, symbol *innerast.Symbol, enclosingDeclaration *innerast.Node) string {
190
557
  if recv == nil || symbol == nil {
191
558
  return ""
@@ -198,11 +565,26 @@ func Checker_symbolToValueString(recv *innerchecker.Checker, symbol *innerast.Sy
198
565
  )
199
566
  }
200
567
 
201
- // Checker_isSymbolAccessibleAsValue verifies that SymbolToStringEx can name a
202
- // symbol from enclosingDeclaration. Unlike GetAccessibleSymbolChain, the
568
+ // Checker_isSymbolAccessibleAsValue reports upstream value-meaning accessibility
569
+ // from enclosingDeclaration. Unlike GetAccessibleSymbolChain, the
203
570
  // checker also follows containing enum, class, and namespace symbols, so a
204
571
  // qualified member such as Domain.Mode.Done is accepted when its container is
205
572
  // visible.
573
+ // The upstream query also permits its external-module accessibility route;
574
+ // true does not independently certify the text returned by a formatting query.
575
+ // Alias-visibility marking is not requested, but semantic accessibility and
576
+ // declaration-visibility caches can still be populated. Inputs must belong to
577
+ // the supplied checker/program; a shared checker requires synchronization.
578
+ // Nil checker, symbol or enclosing declaration returns false.
579
+ //
580
+ // @evidence contracts/common.md#principled-implementation Upstream IsSymbolAccessible applies value-meaning accessibility in the supplied scope, including containing symbols, so the result answers semantic visibility rather than merely whether a name can be printed.
581
+ // @evidence contracts/common.md#clear-and-simple-design One boolean query separates accessibility from value-string formatting, keeping visibility policy in the compiler.
582
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts The wrapper does not assume a qualified name is accessible because its text is known; actual checker accessibility must succeed.
583
+ // @evidence contracts/common.md#meaningful-documentation Native prose explains containing-symbol visibility and nil refusal, distinguishing this operation from an accessible-chain lookup.
584
+ // @evidence contracts/performance.md#bound-retention-and-release-resources The boolean projection does not retain its temporary accessibility result, but delegated lookup acquires visited-table maps and container/chain storage and can retain accessible-chain and declaration-visibility state in the supplied checker/resolver. Their owner controls the program lifetime; this bridge neither clears those caches nor promises a separate historical-state bound.
585
+ // @evidenceExclude contracts/performance.md#efficient-algorithms Scope-table lookup, recursive containing-symbol accessibility, declaration visibility and failure-name formatting are upstream checker algorithms. Their costs depend on scope depth, symbol tables, containers, declarations and generated text; the bridge only chooses value meaning and projects the result rather than owning those algorithms.
586
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work Upstream accessible-chain cache keys include the symbol, relevant scope, meaning and external-alias policy, and resolver state owns declaration visibility. This bridge does not coordinate an independent visibility producer/cache or its invalidation.
587
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation The query uses the supplied program's symbols, scopes and module authority; it does not independently choose filesystem, process or platform policy.
206
588
  func Checker_isSymbolAccessibleAsValue(recv *innerchecker.Checker, symbol *innerast.Symbol, enclosingDeclaration *innerast.Node) bool {
207
589
  if recv == nil || symbol == nil || enclosingDeclaration == nil {
208
590
  return false
@@ -262,50 +644,149 @@ const (
262
644
  ElementFlagsVariadic = innerchecker.ElementFlagsVariadic
263
645
  )
264
646
 
265
- // IsTupleType reports whether t is a fixed-length tuple type.
647
+ // IsTupleType reports whether t is a tuple reference, including rest and
648
+ // variadic tuples. t must be nonnil.
649
+ //
650
+ // @evidence contracts/common.md#principled-implementation The upstream predicate checks reference and target tuple object flags, covering variadic tuples as well as fixed-length ones under the nonnil type premise.
651
+ // @evidence contracts/common.md#clear-and-simple-design One predicate delegates representation classification without inferring tuples from printed syntax or element count.
652
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts No fixed-size shortcut substitutes for the compiler's tuple identity.
653
+ // @evidence contracts/common.md#meaningful-documentation Native prose states rest/variadic inclusion and the nonnil type requirement.
654
+ // @evidenceExclude contracts/performance.md#bound-retention-and-release-resources IsTupleType acquires no handle, buffer or cache and retains nothing after it returns.
655
+ // @evidenceExclude contracts/performance.md#efficient-algorithms Upstream tuple classification owns reference/target tuple-flag inspection; this forwarding shim chooses no separate element traversal or tuple-recognition strategy.
656
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work The predicate inspects an existing type representation and coordinates no completed or in-flight producer, cache or invalidation across requests.
657
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation IsTupleType computes from its arguments only; it opens no file, builds no path and calls no platform or process API.
266
658
  func IsTupleType(t *innerchecker.Type) bool {
267
659
  return innerchecker.IsTupleType(t)
268
660
  }
269
661
 
270
- // Checker_getIndexInfosOfType returns the index signatures (string/number/symbol
271
- // index infos) declared on t.
662
+ // Checker_getIndexInfosOfType returns semantic index information after reduced
663
+ // apparent-type normalization. Results can include inherited or instantiated
664
+ // index signatures and combined union/intersection information, rather than
665
+ // only signatures directly declared on t.
666
+ // recv and t must be nonnil and belong to the same checker graph.
667
+ //
668
+ // @evidence contracts/common.md#principled-implementation Upstream index-info lookup resolves semantic index signatures of the supplied checker type, preserving key/value identities instead of parsing declaration spelling.
669
+ // @evidence contracts/common.md#clear-and-simple-design One direct semantic query exposes existing index information without a separate index-signature walker.
670
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts Index signatures come from the actual type graph rather than guessed numeric or string property names.
671
+ // @evidence contracts/common.md#meaningful-documentation Native prose distinguishes normalized semantic index information from direct declarations and specifies same-checker nonnil premises.
672
+ // @evidence contracts/performance.md#bound-retention-and-release-resources The returned index-info slice is structured-type state owned by the checker, and its entries reference semantic key/value types. Upstream resolution owns any synthesized members; the caller controls additional retention through the borrowed result, while the wrapper stores no separate cache or handle.
673
+ // @evidenceExclude contracts/performance.md#efficient-algorithms The wrapper selects no resolution strategy. Upstream reduction, apparent-type normalization and structured-member resolution can instantiate signatures, traverse base types or combine union/intersection constituents and index lists; cost follows those graphs and lists rather than fixed wrapper steps.
674
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work ObjectFlagsMembersResolved and structured-type member state coordinate reuse in the producing checker. This forwarding wrapper owns no additional index-query cache or repeated-work policy.
675
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation Type normalization and member resolution remain with the supplied checker/program; this wrapper adds no path, host or platform policy.
272
676
  func Checker_getIndexInfosOfType(recv *innerchecker.Checker, t *innerchecker.Type) []*innerchecker.IndexInfo {
273
677
  return recv.GetIndexInfosOfType(t)
274
678
  }
275
679
 
276
680
  // Checker_getPropertiesOfType returns the named property symbols of t. For
277
- // union and intersection types this is the set of properties visible on every
278
- // member.
681
+ // unions, properties must be available across constituents; intersections
682
+ // combine constituent properties under checker semantics. recv and t must be
683
+ // nonnil and belong to the same checker graph.
684
+ // Reduced apparent-type normalization and member resolution happen upstream;
685
+ // the returned slice shares the checker's resolved property state.
686
+ //
687
+ // @evidence contracts/common.md#principled-implementation Upstream property lookup applies union common-property and intersection combined-property semantics, retaining compiler-generated symbol identities and instantiated property types.
688
+ // @evidence contracts/common.md#clear-and-simple-design One checker query owns composite-type property formation instead of an independent shim intersection or union merger.
689
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts Composite properties are not reduced to a common-member approximation for every type category.
690
+ // @evidence contracts/common.md#meaningful-documentation Native prose distinguishes union from intersection behavior and states graph/nonnil premises.
691
+ // @evidence contracts/performance.md#bound-retention-and-release-resources Resolved object/composite property slices and synthesized symbols belong to the producing checker graph. Upstream composite collection also owns its temporary checked-name set; the caller can retain that graph through the returned slice, while the wrapper stores no independent cache or handle.
692
+ // @evidenceExclude contracts/performance.md#efficient-algorithms The wrapper selects no normalization or collection strategy. Upstream object resolution can traverse/instantiate members and bases; composite collection visits constituent properties, hashes names and resolves each candidate under union/intersection semantics. Their graph/list/name costs belong to that implementation rather than fixed wrapper steps.
693
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work Structured member state and composite resolvedProperties own reuse within the supplied checker. This forwarding wrapper coordinates no additional property cache or repeated-query policy.
694
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation Property normalization and resolution use the supplied checker/program; the wrapper introduces no path, host or platform policy.
279
695
  func Checker_getPropertiesOfType(recv *innerchecker.Checker, t *innerchecker.Type) []*innerast.Symbol {
280
696
  return recv.GetPropertiesOfType(t)
281
697
  }
282
698
 
283
699
  // Checker_getApparentProperties returns the properties visible on t after
284
700
  // resolving primitive wrapper types (e.g. string to String).
701
+ // Callable or constructable types also receive applicable global function
702
+ // properties when the type does not already declare those names.
703
+ // recv and t must be nonnil and belong to the same checker graph.
704
+ //
705
+ // @evidence contracts/common.md#principled-implementation Delegating apparent-property lookup preserves the compiler's apparent-type normalization before collecting visible semantic properties.
706
+ // @evidence contracts/common.md#clear-and-simple-design Apparent lookup remains distinct from direct properties so callers select the actual semantic question without a duplicated normalization layer.
707
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts Primitive properties come from compiler apparent types, not a hardcoded wrapper-member inventory.
708
+ // @evidence contracts/common.md#meaningful-documentation Native prose gives the primitive-wrapper example and nonnil same-graph conditions.
709
+ // @evidence contracts/performance.md#bound-retention-and-release-resources Upstream augmentation creates a temporary name table and returns a symbol slice proportional to collected properties. The caller owns the returned slice lifetime and references into checker-owned semantic state; the wrapper stores no independent result or handle.
710
+ // @evidenceExclude contracts/performance.md#efficient-algorithms The wrapper selects no collection strategy. Upstream apparent-type/property/signature resolution, name hashing and function-member augmentation precede named-member filtering and sorting; their property counts and comparison costs belong to that checker implementation rather than fixed local steps.
711
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work Semantic type/property reuse belongs to the supplied checker; the upstream augmentation builds its own per-query table and slice. The forwarding wrapper owns no additional cache or coordination of repeated queries.
712
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation Apparent-type and global-member interpretation use the supplied checker graph; this wrapper introduces no path, host or platform policy.
285
713
  func Checker_getApparentProperties(recv *innerchecker.Checker, t *innerchecker.Type) []*innerast.Symbol {
286
714
  return recv.GetApparentProperties(t)
287
715
  }
288
716
 
289
- // Checker_getTypeArguments returns the type arguments of a generic reference
290
- // type, or nil when t is not a reference.
717
+ // Checker_getTypeArguments returns resolved type arguments of a generic
718
+ // reference type. t must be a nonnil type reference in recv's checker graph;
719
+ // other type representations do not satisfy the upstream accessor's domain.
720
+ // Resolution can fill or instantiate arguments and populate reference state;
721
+ // circular resolution can return error types and report diagnostics.
722
+ //
723
+ // @evidence contracts/common.md#principled-implementation The upstream reference query supplies resolved type arguments associated with the actual compiler reference rather than syntactic arguments that may omit inferred instantiation.
724
+ // @evidence contracts/common.md#clear-and-simple-design One direct reference query exposes instantiated arguments without another generic type model.
725
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts Type argument identity is retained instead of guessed from type names or printed angle brackets.
726
+ // @evidence contracts/common.md#meaningful-documentation Native prose identifies resolved generic-reference scope and the nonnil type-reference/producing-checker domain instead of promising non-reference nil.
727
+ // @evidence contracts/performance.md#bound-retention-and-release-resources Resolved argument slices and their semantic types belong to checker/reference state; circular resolution can also return a parameter-count-sized error-type slice. The caller controls additional retention through the result, while this wrapper keeps no separate cache or handle.
728
+ // @evidenceExclude contracts/performance.md#efficient-algorithms This wrapper selects no argument-resolution strategy. Upstream uncached work resolves argument nodes, examines/fills parameter defaults and instantiates mapped types; tuple and cycle-result construction also depend on list lengths. Those semantic graph/list costs belong to the checker rather than fixed wrapper steps.
729
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work The upstream reference's populated resolvedTypeArguments and type-resolution state coordinate reuse and cycle handling. The forwarding wrapper adds no argument cache or repeated-query coordination.
730
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation Type-reference argument interpretation uses the supplied checker/program; this wrapper introduces no path, host or platform policy.
291
731
  func Checker_getTypeArguments(recv *innerchecker.Checker, t *innerchecker.Type) []*innerchecker.Type {
292
732
  return recv.GetTypeArguments(t)
293
733
  }
294
734
 
295
- // Checker_getTypeOfSymbol returns the declared type of symbol, resolving
296
- // aliases and following late-bound types.
735
+ // Checker_getTypeOfSymbol resolves symbol's value type under the compiler's
736
+ // symbol-category rules, including deferred/instantiated/mapped types and aliases.
737
+ // For a class this is its constructor/static type; use
738
+ // Checker_getDeclaredTypeOfSymbol for the instance type. Unsupported value
739
+ // categories or recursive alias typing can return the checker's error type;
740
+ // semantic resolution can populate symbol type state and diagnostics.
741
+ // recv and symbol must be nonnil; the symbol must belong to recv.
742
+ //
743
+ // @evidence contracts/common.md#principled-implementation Upstream symbol typing dispatches on compiler symbol/check flags, including instantiated/mapped/deferred types and alias value targets, preserving producing-checker type identity and error-type fallbacks.
744
+ // @evidence contracts/common.md#clear-and-simple-design One symbol-to-type query leaves binding and resolution with the existing checker.
745
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts No type is synthesized from consumer naming or a cached textual annotation.
746
+ // @evidence contracts/common.md#meaningful-documentation Native prose states symbol-category/alias handling, class value versus instance typing, state/error effects and nonnil checker ownership.
747
+ // @evidence contracts/performance.md#bound-retention-and-release-resources Resolved symbol types, constructed class/value types and diagnostics remain checker-owned. The caller can retain the semantic graph through the returned type; this forwarding wrapper stores no independent result, buffer or handle.
748
+ // @evidenceExclude contracts/performance.md#efficient-algorithms The wrapper selects no typing strategy. Upstream flag dispatch delegates deferred, instantiated, mapped, accessor, variable and value-category typing or alias resolution; class/base and alias/instantiation paths can traverse semantic graphs rather than fixed local steps.
749
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work The producing checker owns symbol-type state, including valueSymbolLinks resolvedType caching for instantiated, class/value and alias paths. This wrapper adds no symbol cache or repeated-query coordination.
750
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation Symbol typing and related resolution use the supplied checker/program; this wrapper introduces no path, host or platform policy.
297
751
  func Checker_getTypeOfSymbol(recv *innerchecker.Checker, symbol *innerast.Symbol) *innerchecker.Type {
298
752
  return recv.GetTypeOfSymbol(symbol)
299
753
  }
300
754
 
301
- // Checker_getTypeOfSymbolAtLocation returns the contextual type of symbol as
302
- // observed at the given AST node (useful for narrowed types in control flow).
755
+ // Checker_getTypeOfSymbolAtLocation returns upstream location-sensitive symbol
756
+ // typing after exported-value-symbol normalization. Eligible identifier/private
757
+ // references use the checked expression type when they resolve to that symbol;
758
+ // setter declaration names and write-access contexts can select writable types.
759
+ // Other locations, including nil, fall back to non-missing symbol typing.
760
+ // Checker and symbol must be nonnil; symbol and any supplied node must belong
761
+ // to the same checked program. An arbitrary node does not promise narrowing.
762
+ //
763
+ // @evidence contracts/common.md#principled-implementation Upstream location typing distinguishes a matching checked reference, setter/write contexts and non-missing symbol fallback after exported-symbol normalization, instead of inventing narrowing for arbitrary nodes.
764
+ // @evidence contracts/common.md#clear-and-simple-design This wrapper makes location dependence explicit instead of conflating location-sensitive, contextual and declared-type queries.
765
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts Context comes from a real checked node, not a fixture offset or textual narrowing heuristic.
766
+ // @evidence contracts/common.md#meaningful-documentation Native prose states reference-match, write/setter and non-missing fallback branches, same-program inputs and nil-location limits.
767
+ // @evidence contracts/performance.md#bound-retention-and-release-resources Node/symbol type state, checked-expression results and semantic diagnostics remain checker-owned; the caller can retain that graph through the returned type. This forwarding wrapper keeps no independent result, buffer or handle.
768
+ // @evidenceExclude contracts/performance.md#efficient-algorithms The wrapper selects no location-typing strategy. Upstream syntax eligibility, expression/property-write checking and symbol/accessor typing own AST/control-flow/type graph work before reference matching or fallback, rather than fixed local steps.
769
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work The producing checker owns node/symbol links and checked semantic type state. This wrapper adds no location cache or coordination of repeated flow-sensitive queries.
770
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation Location-sensitive typing uses the supplied checked AST and checker/program; this wrapper introduces no path, host or platform policy.
303
771
  func Checker_getTypeOfSymbolAtLocation(recv *innerchecker.Checker, symbol *innerast.Symbol, node *innerast.Node) *innerchecker.Type {
304
772
  return recv.GetTypeOfSymbolAtLocation(symbol, node)
305
773
  }
306
774
 
307
775
  // Checker_getTypeOfPropertyOfType looks up the type of the named property on t
308
776
  // and returns nil when no such property exists.
777
+ // recv and t must be nonnil and belong to the same checker graph.
778
+ // It uses upstream default property lookup after reduced apparent-type
779
+ // normalization, including inherited/composite and global-member rules, then
780
+ // resolves the selected symbol's type in that checker.
781
+ //
782
+ // @evidence contracts/common.md#principled-implementation Semantic property lookup uses the compiler's instantiated type and member name, returning the property's checked type only when that member exists.
783
+ // @evidence contracts/common.md#clear-and-simple-design One type/name lookup delegates property resolution without separately resolving symbols and reimplementing property typing.
784
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts Missing members remain absent rather than receiving a fabricated fallback type.
785
+ // @evidence contracts/common.md#meaningful-documentation Native prose states missing-property nil and same-checker nonnil requirements.
786
+ // @evidence contracts/performance.md#bound-retention-and-release-resources Property/member/symbol type state remains owned by the producing checker; a returned type can retain its semantic graph through the caller's reference. The forwarding wrapper stores no independent result, buffer or handle.
787
+ // @evidenceExclude contracts/performance.md#efficient-algorithms The wrapper selects no lookup or typing strategy. Upstream reduced-apparent normalization, structured/composite property lookup and symbol-category typing own graph traversal, instantiation and name processing costs rather than fixed local steps.
788
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work The supplied checker owns resolved member/composite property and symbol-type state, including instantiated-symbol result caching. This wrapper adds no name/type cache or repeated-query coordination.
789
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation Property and symbol typing use the supplied checker/program; this wrapper introduces no path, host or platform policy.
309
790
  func Checker_getTypeOfPropertyOfType(recv *innerchecker.Checker, t *innerchecker.Type, name string) *innerchecker.Type {
310
791
  return recv.GetTypeOfPropertyOfType(t, name)
311
792
  }
@@ -316,17 +797,21 @@ func checkerGetPropertyNameForKnownSymbolName(recv *innerchecker.Checker, symbol
316
797
  // Checker_getPropertyNameForKnownSymbolName returns the late-bound property
317
798
  // name the checker uses for a member keyed by the global well-known symbol
318
799
  // `Symbol.<symbolName>` (e.g. "asyncIterator", "asyncDispose", "iterator").
319
- // It resolves the unique-symbol type of that property on the global
320
- // `SymbolConstructor` — including lib-provided and `declare global` augmented
321
- // members — so `(*Checker).GetPropertyOfType(t, name)` with the returned name
322
- // finds exactly the members declared as `[Symbol.<symbolName>]`. This is the
323
- // same resolution the checker itself performs when it validates `for await`
324
- // iterability, which is why a lint rule that mirrors typescript-eslint's
325
- // well-known-symbol protocol checks must go through it instead of matching
326
- // property-name text. When the global `Symbol` constructor lacks the member,
327
- // the checker's internal fallback name (a `\xFE@`-prefixed string no
328
- // source-declared property can late-bind to) is returned, so lookups simply
329
- // find nothing. Returns "" if recv is nil.
800
+ // It queries the global Symbol value's member type, including library and
801
+ // global augmentation. A unique-symbol type supplies its semantic name;
802
+ // upstream also accepts string/number literal member types and returns their
803
+ // property names. Missing or unusable member types return the compiler's
804
+ // internal-prefix fallback key, without proving that a protocol is supported.
805
+ // Returns "" if recv is nil.
806
+ //
807
+ // @evidence contracts/common.md#principled-implementation Upstream global Symbol member typing selects a unique-symbol semantic name or a usable string/number literal name; missing or unusable types preserve the compiler fallback instead of claiming a supported protocol.
808
+ // @evidence contracts/common.md#clear-and-simple-design One bridge owns well-known-symbol key resolution rather than duplicating a textual Symbol-name matcher in lint consumers.
809
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts Missing or unusable global members preserve upstream's internal fallback key rather than using a similarly spelled public property as an invented protocol identity.
810
+ // @evidence contracts/common.md#meaningful-documentation Native prose states all usable type categories, global augmentation, fallback limits and nil receiver behavior.
811
+ // @evidence contracts/performance.md#bound-retention-and-release-resources The returned name is a semantic/literal string or a newly constructed fallback proportional to symbolName bytes; the caller owns its retention. Global symbol and type state remain checker-owned, and the wrapper retains no separate result or handle.
812
+ // @evidenceExclude contracts/performance.md#efficient-algorithms The wrapper only guards a nil checker. Upstream global/member/type resolution owns semantic graph and name-lookup costs; literal number formatting or fallback string construction adds representation work. This forwarding wrapper chooses none of those algorithms.
813
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work The producing checker memoizes global Symbol lookup and owns semantic type/member reuse. This wrapper has no independent key cache or coordination policy, and fallback construction remains per query upstream.
814
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation Global member typing uses the supplied checker/program; this wrapper introduces no path, host or platform policy.
330
815
  func Checker_getPropertyNameForKnownSymbolName(recv *innerchecker.Checker, symbolName string) string {
331
816
  if recv == nil {
332
817
  return ""
@@ -348,8 +833,20 @@ func checkerGetIterationTypeOfIterable(
348
833
  // TypeScript-Go traversal used for synchronous iteration, including inherited
349
834
  // and structural iterables, instantiated iterator returns, intersections, and
350
835
  // primitive strings. A nil result means the checker could not derive a valid
351
- // synchronous iteration type. Diagnostics are intentionally disabled because
352
- // callers use this as a type query after normal TypeScript checking.
836
+ // synchronous iteration type, including the top-level any input case; it is
837
+ // not a proof that a runtime value is non-iterable. Nonnil input must belong to
838
+ // recv's checker graph. The nil error node suppresses this helper's iteration
839
+ // error reporting; underlying semantic queries can still resolve/cache types.
840
+ // Nil recv or inputType returns nil.
841
+ //
842
+ // @evidence contracts/common.md#principled-implementation The pinned helper's Element use and Yield kind obtain synchronous iterator values through actual inherited/instantiated protocol types. Its nil error node suppresses iteration error reporting without promising that underlying semantic resolution is effect-free.
843
+ // @evidence contracts/common.md#clear-and-simple-design One guarded bridge exposes the compiler's iterator semantics without assembling Symbol.iterator and next signatures independently.
844
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts Iterator values are not guessed from property spelling or selected container names; upstream semantics cover structural iterables and strings.
845
+ // @evidence contracts/common.md#meaningful-documentation Native prose states traversal categories, the any/nil-result limit, same-checker inputs and the specific iteration-error suppression boundary.
846
+ // @evidence contracts/performance.md#bound-retention-and-release-resources Upstream iteration/type caches belong to the producing checker; union/protocol/signature queries can also allocate temporary result lists. The caller can retain the semantic graph through a returned yield type, while this wrapper keeps no independent result or handle.
847
+ // @evidenceExclude contracts/performance.md#efficient-algorithms The wrapper guards nil inputs and selects the pinned synchronous Element/Yield operation. Upstream reduction, union traversal, fast-reference recognition, iterator-property/signature filtering and return/iterator-result resolution own the graph/list costs rather than a fixed number of local steps.
848
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work The upstream iterationTypesCache keys results by reduced type identity and iteration-use flags, including no-iteration outcomes for this nil-error-node query. The wrapper owns no additional protocol cache or repeated-query coordination.
849
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation Iterator semantics and related global/member typing use the supplied checker/program; this wrapper adds no path, host or platform policy.
353
850
  func Checker_getSynchronousIterationYieldType(recv *innerchecker.Checker, inputType *innerchecker.Type) *innerchecker.Type {
354
851
  if recv == nil || inputType == nil {
355
852
  return nil
@@ -366,8 +863,19 @@ func Checker_getSynchronousIterationYieldType(recv *innerchecker.Checker, inputT
366
863
  //go:linkname checkerGetAliasSymbolForTypeNode github.com/microsoft/typescript-go/internal/checker.(*Checker).getAliasSymbolForTypeNode
367
864
  func checkerGetAliasSymbolForTypeNode(recv *innerchecker.Checker, node *innerast.Node) *innerast.Symbol
368
865
 
369
- // Checker_getAliasSymbolForTypeNode returns the alias symbol that a type node
370
- // refers to when the node is itself a type alias reference (e.g. `type Foo = ...`).
866
+ // Checker_getAliasSymbolForTypeNode returns the symbol of a type alias
867
+ // declaration enclosing node through parenthesized or readonly type wrappers.
868
+ // It returns nil when that enclosing declaration is not a type alias; this
869
+ // does not resolve the target of a referenced alias. Inputs must be nonnil.
870
+ //
871
+ // @evidence contracts/common.md#principled-implementation The pinned helper walks node parents through parenthesized and readonly type operators, then obtains the enclosing type-alias declaration's symbol rather than resolving a type-reference target.
872
+ // @evidence contracts/common.md#clear-and-simple-design One specifically documented enclosure query exposes compiler alias provenance without conflating it with alias-target resolution.
873
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts No alias is inferred from printed type text or a named consumer; the actual AST parent chain defines the result.
874
+ // @evidence contracts/common.md#meaningful-documentation Native prose states wrapper traversal, non-alias nil, nonnil inputs and the enclosing-declaration distinction.
875
+ // @evidence contracts/performance.md#bound-retention-and-release-resources A returned symbol remains checker-owned and can reference its declarations and semantic graph; the caller controls retention of that reference, while this forwarding wrapper stores no independent result, buffer or handle.
876
+ // @evidenceExclude contracts/performance.md#efficient-algorithms The wrapper selects no traversal strategy: the pinned helper walks H enclosing parenthesized/readonly wrappers, then delegates declaration-symbol normalization to the checker. That upstream traversal and symbol state own the cost, not a fixed-step local algorithm.
877
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work Declaration symbols and merged-symbol reuse belong to the upstream checker; this forwarding wrapper owns no query cache or coordination of repeated enclosure walks.
878
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation Checker_getAliasSymbolForTypeNode computes from its arguments only; it opens no file, builds no path and calls no platform or process API.
371
879
  func Checker_getAliasSymbolForTypeNode(recv *innerchecker.Checker, node *innerast.Node) *innerast.Symbol {
372
880
  return checkerGetAliasSymbolForTypeNode(recv, node)
373
881
  }
@@ -375,8 +883,18 @@ func Checker_getAliasSymbolForTypeNode(recv *innerchecker.Checker, node *inneras
375
883
  //go:linkname checkerGetDeclarationOfAliasSymbol github.com/microsoft/typescript-go/internal/checker.(*Checker).getDeclarationOfAliasSymbol
376
884
  func checkerGetDeclarationOfAliasSymbol(recv *innerchecker.Checker, symbol *innerast.Symbol) *innerast.Node
377
885
 
378
- // Checker_getDeclarationOfAliasSymbol resolves an import/export alias symbol to
379
- // its original declaration node.
886
+ // Checker_getDeclarationOfAliasSymbol returns the last alias declaration in
887
+ // symbol's declarations, or nil when none exists. It does not follow the alias
888
+ // to its target declaration. Inputs must be nonnil.
889
+ //
890
+ // @evidence contracts/common.md#principled-implementation Upstream FindLast with IsAliasSymbolDeclaration selects the alias's own declaration under compiler declaration ordering rather than dereferencing its final target.
891
+ // @evidence contracts/common.md#clear-and-simple-design Declaration provenance is queried separately from Checker_getAliasedSymbol target resolution, retaining the difference in the public API's native explanation.
892
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts The declaration is selected from the actual symbol's compiler declarations without a guessed import/export source.
893
+ // @evidence contracts/common.md#meaningful-documentation Native prose distinguishes alias declaration from target, specifies last-match ordering and absent/nonnil conditions.
894
+ // @evidence contracts/performance.md#bound-retention-and-release-resources The result is an existing declaration node that can reach its compiler tree through parents and metadata; the caller controls retention of that reference. The forwarding wrapper creates no collection and stores no independent result or handle.
895
+ // @evidenceExclude contracts/performance.md#efficient-algorithms The wrapper chooses no search strategy. Upstream FindLast scans up to D symbol declarations in reverse order, with IsAliasSymbolDeclaration's syntax-dependent predicate work, and stops at the first match.
896
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work The producing compiler owns the symbol's declaration sequence and alias classification; this forwarding wrapper owns no declaration-query cache or coordination of repeated searches.
897
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation Checker_getDeclarationOfAliasSymbol computes from its arguments only; it opens no file, builds no path and calls no platform or process API.
380
898
  func Checker_getDeclarationOfAliasSymbol(recv *innerchecker.Checker, symbol *innerast.Symbol) *innerast.Node {
381
899
  return checkerGetDeclarationOfAliasSymbol(recv, symbol)
382
900
  }
@@ -386,6 +904,19 @@ func checkerGetTargetOfImportSpecifier(recv *innerchecker.Checker, node *inneras
386
904
 
387
905
  // Checker_getTargetOfImportSpecifier resolves an import specifier node to the
388
906
  // exported symbol it binds. Returns nil if recv or node is nil.
907
+ // A nonnil node must be an import specifier in recv's checked program.
908
+ // Upstream import/default/module-member rules can preserve an alias rather
909
+ // than its final target, report resolution diagnostics, and mark type-only
910
+ // alias metadata. A missing resolved member can also yield nil.
911
+ //
912
+ // @evidence contracts/common.md#principled-implementation The linked helper uses the import specifier's actual binding context to resolve its exported target, retaining checker alias semantics rather than matching module text.
913
+ // @evidence contracts/common.md#clear-and-simple-design One guarded import-specific query exposes the existing semantic operation without duplicating module export lookup.
914
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts Missing inputs remain nil and targets are not guessed from specifier names.
915
+ // @evidence contracts/common.md#meaningful-documentation Native prose states target meaning, nil behavior and the import-specifier/same-program premise.
916
+ // @evidence contracts/performance.md#bound-retention-and-release-resources Resolution symbols, module/export state, type-only alias metadata and diagnostics remain checker-owned; a returned symbol can retain that semantic graph through the caller's reference. The wrapper stores no separate result or handle.
917
+ // @evidenceExclude contracts/performance.md#efficient-algorithms The wrapper guards nil inputs and selects no resolution strategy. Upstream import/default/module-member resolution owns module, property and export queries, name processing and possible symbol combination; costs follow those semantic graphs rather than fixed wrapper steps.
918
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work The producing checker/program owns module, export, symbol and alias-state reuse. This forwarding wrapper adds no import-target cache or repeated-query coordination.
919
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation Import target and external-module interpretation use the supplied checker/program authority; this wrapper adds no path, host or platform policy and does not replace that resolution.
389
920
  func Checker_getTargetOfImportSpecifier(recv *innerchecker.Checker, node *innerast.Node) *innerast.Symbol {
390
921
  if recv == nil || node == nil {
391
922
  return nil
@@ -395,6 +926,18 @@ func Checker_getTargetOfImportSpecifier(recv *innerchecker.Checker, node *innera
395
926
 
396
927
  // Checker_getAliasedSymbol follows an alias chain to its final target symbol.
397
928
  // Returns nil if recv or symbol is nil.
929
+ // A nonnil symbol must carry the compiler's Alias flag and belong to recv.
930
+ // Unresolved or circular aliases can return the checker's unknown symbol;
931
+ // the operation can populate checker alias links and diagnostics.
932
+ //
933
+ // @evidence contracts/common.md#principled-implementation The compiler follows an actual alias symbol's chain to its semantic target under the Alias-flag and producing-checker premises.
934
+ // @evidence contracts/common.md#clear-and-simple-design Target resolution remains separate from declaration lookup and import-node-specific resolution.
935
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts The target is not reconstructed by reopening textual module paths or accepting a similarly named symbol.
936
+ // @evidence contracts/common.md#meaningful-documentation Native prose states final-target meaning, nil handling and the alias-symbol domain.
937
+ // @evidence contracts/performance.md#bound-retention-and-release-resources Upstream alias links and diagnostics belong to recv's checker lifetime; the returned target or unknown symbol can retain semantic state through the caller's reference. The wrapper stores no separate result or resource.
938
+ // @evidenceExclude contracts/performance.md#efficient-algorithms The wrapper only guards nil inputs and forwards. The upstream checker owns declaration searches, recursive alias resolution, cycle handling and module-target queries; uncached work depends on that semantic graph rather than a fixed number of wrapper steps.
939
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work The upstream aliasSymbolLinks cache stores resolved targets, including the unknown-symbol result. This wrapper owns no separate alias cache or coordination policy.
940
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation Alias and module-target interpretation remain with the supplied checker and program; the wrapper adds no path, host or platform policy and does not bypass that authority.
398
941
  func Checker_getAliasedSymbol(recv *innerchecker.Checker, symbol *innerast.Symbol) *innerast.Symbol {
399
942
  if recv == nil || symbol == nil {
400
943
  return nil
@@ -405,6 +948,18 @@ func Checker_getAliasedSymbol(recv *innerchecker.Checker, symbol *innerast.Symbo
405
948
  // Checker_getExportsOfModule returns the exported symbols of a source-file or
406
949
  // namespace module symbol, resolving export-star aggregation the same way the
407
950
  // checker does for emit and services.
951
+ // Nil checker or symbol returns nil; a nonnil symbol must be a module in recv.
952
+ // The returned slice excludes reserved internal names. Aggregation can cache
953
+ // resolved exports and report export-star name collisions in the checker.
954
+ //
955
+ // @evidence contracts/common.md#principled-implementation Upstream module exports include export-star aggregation and compiler alias identities for the supplied semantic module, rather than only syntactically listed export declarations.
956
+ // @evidence contracts/common.md#clear-and-simple-design One module query centralizes aggregation in the checker instead of a separate shim re-export walker.
957
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts Export targets follow actual compiler bindings without hardcoded barrel paths or consumer exceptions.
958
+ // @evidence contracts/common.md#meaningful-documentation Native prose names source-file/namespace modules, export-star handling and nil/same-checker constraints.
959
+ // @evidence contracts/performance.md#bound-retention-and-release-resources Upstream aggregation owns temporary visited-symbol/name/collision tables and checker-lifetime resolved-export state. The caller owns the returned symbol slice lifetime and can retain the checker graph through its elements; the wrapper stores no independent result or handle.
960
+ // @evidenceExclude contracts/performance.md#efficient-algorithms The wrapper only guards nil inputs and forwards. Uncached upstream work recursively visits export-star modules, checks visited symbols, clones/merges name tables and reports collisions; each result conversion also scans exports to filter reserved names. Graph size and name/predicate costs belong to that implementation.
961
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work The producing checker caches resolvedExports and type-only export-star metadata, while symbolsToArray creates the per-query result slice. This wrapper owns no additional export cache or repeated-query coordination.
962
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation Export and external-module target resolution use the supplied checker/program authority; this wrapper adds no path, host or platform policy.
408
963
  func Checker_getExportsOfModule(recv *innerchecker.Checker, symbol *innerast.Symbol) []*innerast.Symbol {
409
964
  if recv == nil || symbol == nil {
410
965
  return nil
@@ -423,10 +978,25 @@ func checkerResolveEntityName(
423
978
  ) *innerast.Symbol
424
979
 
425
980
  // Checker_resolveEntityName resolves a dotted entity name (identifier or
426
- // qualified name) to the symbol it denotes, filtered by meaning flags.
427
- // When ignoreErrors is true, resolution failures are silent. When
428
- // dontResolveAlias is true, the returned symbol may still be an alias.
429
- // Returns nil if recv or name is nil.
981
+ // qualified name, or the upstream property-access form) under meaning flags.
982
+ // Unsupported nonmissing node kinds panic upstream. ignoreErrors suppresses
983
+ // the resolver's own missing-name/member diagnostics; it does not certify that
984
+ // alias resolution or the CommonJS external-module route produces no diagnostic.
985
+ // dontResolveAlias suppresses the final alias walk, not namespace resolution
986
+ // for a qualified name's left side. The result can be an alias or unknown symbol.
987
+ // Returns nil if recv or name is nil, or the resolver finds no symbol.
988
+ // Name and optional location must belong to recv's checked program.
989
+ // Alias/type-only metadata and semantic caches may change; callers sharing the
990
+ // checker must synchronize access.
991
+ //
992
+ // @evidence contracts/common.md#principled-implementation The pinned entity-name resolver applies meaning flags, scope, alias-resolution and diagnostic controls to the actual AST name, preserving type/value/namespace distinctions.
993
+ // @evidence contracts/common.md#clear-and-simple-design One bridge exposes the resolver's relevant controls explicitly rather than duplicating separate dotted-name lookup implementations.
994
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts The semantic name is resolved by compiler scope rules, not string concatenation or a consumer-specific namespace table.
995
+ // @evidence contracts/common.md#meaningful-documentation Native prose states supported node forms, diagnostic and alias-control limits, unknown/nil outcomes and producing-program ownership rather than promising silent resolution of every delegated operation.
996
+ // @evidence contracts/performance.md#bound-retention-and-release-resources The returned symbol can retain its checker/program graph. Upstream resolution owns alias targets, type-only metadata, export/module state and possible diagnostics; the caller owns the checker lifetime and returned reference. This bridge keeps no independent lookup registry or release policy for that state.
997
+ // @evidenceExclude contracts/performance.md#efficient-algorithms Upstream scope/name resolution, recursive qualified lookup, alias walks, export resolution and diagnostic suggestions own the algorithms and their scope, name-byte, declaration and symbol-graph costs. The shim only forwards explicit controls after nil guards, without selecting a second lookup algorithm.
998
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work The supplied checker owns alias/export/module caches and metadata that establish semantic reuse. This bridge coordinates no additional name-resolution producer or cross-program cache/invalidation policy.
999
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation Resolution uses the supplied checked program's scope and module authority, including its CommonJS route; this bridge chooses no independent host paths, executable or platform policy.
430
1000
  func Checker_resolveEntityName(
431
1001
  recv *innerchecker.Checker,
432
1002
  name *innerast.Node,
@@ -444,9 +1014,21 @@ func Checker_resolveEntityName(
444
1014
  //go:linkname checkerGetTypeNameSymbol github.com/microsoft/typescript-go/internal/checker.getTypeNameSymbol
445
1015
  func checkerGetTypeNameSymbol(t *innerchecker.Type) *innerast.Symbol
446
1016
 
447
- // Type_getTypeNameSymbol returns the symbol attached to t's type name field,
448
- // or nil when t has no name symbol or t is nil. Linked via go:linkname because
1017
+ // Type_getTypeNameSymbol returns t's alias symbol when alias metadata exists;
1018
+ // otherwise it returns t's symbol for type parameters, string-mapping types,
1019
+ // classes/interfaces and references, or nil for other categories or nil input.
1020
+ // It does not format the type or establish a unique name for every type.
1021
+ // Linked via go:linkname because
449
1022
  // getTypeNameSymbol is a package-level unexported function in the checker.
1023
+ //
1024
+ // @evidence contracts/common.md#principled-implementation The compiler's name-symbol helper preserves semantic type naming rules, while nil input remains absent without dereferencing a type payload.
1025
+ // @evidence contracts/common.md#clear-and-simple-design One query exposes name provenance independently of type formatting or general symbol resolution.
1026
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts No name symbol is guessed from printed text or declaration identifiers.
1027
+ // @evidence contracts/common.md#meaningful-documentation Native prose states optional name/nil results and why explicit internal linkage is used.
1028
+ // @evidence contracts/performance.md#bound-retention-and-release-resources The caller receives an existing alias/type symbol and can retain its declaration and semantic graph. The source type/checker owner controls that lifetime; the bridge allocates no name copy and keeps no separate symbol history or handle.
1029
+ // @evidenceExclude contracts/performance.md#efficient-algorithms Upstream alias-first flag/symbol projection owns the selection rule. This shim only guards nil and chooses no separate name resolution, graph traversal or formatting algorithm.
1030
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work The helper projects existing type metadata and coordinates no completed or in-flight producer, name cache or invalidation across requests.
1031
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation Type_getTypeNameSymbol computes from its arguments only; it opens no file, builds no path and calls no platform or process API.
450
1032
  func Type_getTypeNameSymbol(t *innerchecker.Type) *innerast.Symbol {
451
1033
  if t == nil {
452
1034
  return nil
@@ -457,7 +1039,18 @@ func Type_getTypeNameSymbol(t *innerchecker.Type) *innerast.Symbol {
457
1039
  //go:linkname checkerIsArrayType github.com/microsoft/typescript-go/internal/checker.(*Checker).isArrayType
458
1040
  func checkerIsArrayType(recv *innerchecker.Checker, t *innerchecker.Type) bool
459
1041
 
460
- // Checker_isArrayType reports whether t is the built-in Array<T> reference type.
1042
+ // Checker_isArrayType reports whether t is a built-in Array<T> or
1043
+ // ReadonlyArray<T> reference type.
1044
+ // recv and t must be nonnil and belong to the same checker graph.
1045
+ //
1046
+ // @evidence contracts/common.md#principled-implementation The linked predicate uses the producing checker's global Array and ReadonlyArray target identities, distinguishing both built-in references from unrelated array-like objects.
1047
+ // @evidence contracts/common.md#clear-and-simple-design One compiler identity predicate avoids a separate structural-array classifier.
1048
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts Built-in arrays are not identified by a consumer's type name or numeric-property heuristic.
1049
+ // @evidence contracts/common.md#meaningful-documentation Native prose states built-in reference scope and nonnil same-checker inputs.
1050
+ // @evidenceExclude contracts/performance.md#bound-retention-and-release-resources Checker_isArrayType acquires no handle, buffer or cache and retains nothing after it returns.
1051
+ // @evidenceExclude contracts/performance.md#efficient-algorithms The wrapper selects no classification strategy: the pinned checker tests the reference flag and compares its target with the two existing global array targets, without traversing members or type arguments.
1052
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work The producing checker owns the existing global Array/ReadonlyArray identities. This forwarding boolean predicate owns no array-type discovery, cache or coordination of repeated semantic queries.
1053
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation Checker_isArrayType computes from its arguments only; it opens no file, builds no path and calls no platform or process API.
461
1054
  func Checker_isArrayType(recv *innerchecker.Checker, t *innerchecker.Type) bool {
462
1055
  return checkerIsArrayType(recv, t)
463
1056
  }
@@ -467,6 +1060,18 @@ func checkerGetBaseTypes(recv *innerchecker.Checker, t *innerchecker.Type) []*in
467
1060
 
468
1061
  // Checker_getBaseTypes returns the list of base types (from `extends` clauses)
469
1062
  // for a class or interface type. Returns nil if recv or t is nil.
1063
+ // A nonnil t must be a declared class/interface type, not its generic reference.
1064
+ // The result shares the checker's resolved-base slice; resolving it can update
1065
+ // type-resolution state and report invalid or circular heritage diagnostics.
1066
+ //
1067
+ // @evidence contracts/common.md#principled-implementation The upstream base-type helper resolves a declared class/interface's heritage in its producing checker; generic references must first use their declared class/interface representation.
1068
+ // @evidence contracts/common.md#clear-and-simple-design One inheritance query leaves heritage resolution with the compiler and states its narrower input domain explicitly.
1069
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts No base is inferred from a textual extends clause or guessed class name.
1070
+ // @evidence contracts/common.md#meaningful-documentation Native prose describes heritage output, nil absence and the declared-type versus generic-reference distinction.
1071
+ // @evidence contracts/performance.md#bound-retention-and-release-resources Resolved-base slices, resolution flags and diagnostics remain checker-owned; the returned slice references that type graph and the caller controls its additional retention. The wrapper stores no separate result or handle.
1072
+ // @evidenceExclude contracts/performance.md#efficient-algorithms This wrapper only guards nil inputs and forwards. Upstream class/interface heritage resolution owns declaration and extends-element walks, type/signature processing and recursive base checks; uncached cost follows that graph rather than fixed wrapper steps.
1073
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work The upstream baseTypesResolved flag and resolvedBaseTypes slice own reuse within the producing checker. The forwarding wrapper introduces no additional cache or coordination policy.
1074
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation Heritage interpretation remains with the supplied checker/program; this wrapper adds no path, host or platform policy.
470
1075
  func Checker_getBaseTypes(recv *innerchecker.Checker, t *innerchecker.Type) []*innerchecker.Type {
471
1076
  if recv == nil || t == nil {
472
1077
  return nil
@@ -477,14 +1082,22 @@ func Checker_getBaseTypes(recv *innerchecker.Checker, t *innerchecker.Type) []*i
477
1082
  //go:linkname checkerGetDeclaredTypeOfSymbol github.com/microsoft/typescript-go/internal/checker.(*Checker).getDeclaredTypeOfSymbol
478
1083
  func checkerGetDeclaredTypeOfSymbol(recv *innerchecker.Checker, symbol *innerast.Symbol) *innerchecker.Type
479
1084
 
480
- // Checker_getDeclaredTypeOfSymbol returns the declared (instance) type of a
481
- // class or interface symbol. Unlike Checker_getTypeOfSymbol, which yields the
482
- // constructor (static) type of a class symbol, the result IS a
483
- // ClassOrInterface type and is therefore safe to feed back into
484
- // Checker_getBaseTypes. This lets a consumer resolve a generic base's symbol to
485
- // its declared type and keep walking the base chain past the generic boundary
486
- // where getBaseTypes would otherwise dead-end (a Reference/Anonymous type has a
487
- // nil AsInterfaceType()). Returns nil if recv or symbol is nil.
1085
+ // Checker_getDeclaredTypeOfSymbol returns the compiler's declared type for a
1086
+ // symbol from recv's checker graph. For a class/interface symbol this is its
1087
+ // declared instance representation, suitable for Checker_getBaseTypes, rather
1088
+ // than a class value's constructor type or an instantiated reference.
1089
+ // Other symbol categories follow upstream declared-type dispatch and do not
1090
+ // promise a class/interface result; absence of a declared type yields the
1091
+ // checker's error type. Returns nil if recv or symbol is nil.
1092
+ //
1093
+ // @evidence contracts/common.md#principled-implementation For class/interface symbols, compiler declared-type lookup distinguishes the instance-side representation from a class value's constructor type and supports base-type traversal. Other symbol categories retain upstream dispatch and error-type fallback.
1094
+ // @evidence contracts/common.md#clear-and-simple-design The wrapper exposes instance declaration typing separately from ordinary symbol value typing instead of making consumers coerce type representations.
1095
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts Generic heritage traversal uses actual declared compiler types rather than a compensating name-based base lookup.
1096
+ // @evidence contracts/common.md#meaningful-documentation Native prose scopes the class/interface result, states upstream dispatch/error-type behavior for other symbols, and specifies same-checker and nil conditions.
1097
+ // @evidence contracts/performance.md#bound-retention-and-release-resources Declared-type links and any class/interface type, this-type or instantiation table remain checker-owned; the caller can retain that graph through the returned type. This forwarding wrapper keeps no separate cache, result or handle.
1098
+ // @evidenceExclude contracts/performance.md#efficient-algorithms The wrapper guards nil inputs and delegates symbol-category dispatch. Upstream uncached class/interface construction includes outer/local parameter collection and recursive interface heritage checks, while other categories own their semantic resolution costs; this is not a fixed-step local strategy.
1099
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work The supplied checker owns declaredTypeLinks and type instantiation reuse. The forwarding wrapper does not coordinate or cache repeated declared-type queries.
1100
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation Symbol typing and related resolution use the supplied checker/program; the wrapper introduces no path, host or platform policy.
488
1101
  func Checker_getDeclaredTypeOfSymbol(recv *innerchecker.Checker, symbol *innerast.Symbol) *innerchecker.Type {
489
1102
  if recv == nil || symbol == nil {
490
1103
  return nil
@@ -496,10 +1109,21 @@ func Checker_getDeclaredTypeOfSymbol(recv *innerchecker.Checker, symbol *inneras
496
1109
  func checkerGetMinArgumentCount(recv *innerchecker.Checker, signature *innerchecker.Signature) int
497
1110
 
498
1111
  // Checker_getMinArgumentCount returns the minimum number of required arguments
499
- // a call/construct signature accepts (parameters before the first optional or
500
- // rest parameter). A type-transform plugin uses this to gate the single-
501
- // required-parameter constructor strategy (`new C(x)`) and single-arg static
502
- // factory (`C.from(x)`). Returns 0 if recv or signature is nil.
1112
+ // a call/construct signature accepts under compiler rules, including required
1113
+ // tuple-rest positions and trailing void-accepting parameters. It uses the
1114
+ // upstream default arity flags, including the untyped-JavaScript zero rule;
1115
+ // this minimum alone does not validate a call's argument types or maximum arity.
1116
+ // Nonnil inputs must belong to the same checker graph. Returns 0 if recv or
1117
+ // signature is nil; computing a result can populate signature arity state.
1118
+ //
1119
+ // @evidence contracts/common.md#principled-implementation Upstream minimum-arity calculation accounts for required tuple-rest positions, optionality, untyped JavaScript and trailing void acceptance instead of counting declarations before a rest marker.
1120
+ // @evidence contracts/common.md#clear-and-simple-design One arity query exposes the compiler's default minimum-argument rule without a second parameter-counting policy or a promise of full call validation.
1121
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts The result comes from actual signature semantics rather than a consumer's constructor strategy or fixed expected arity.
1122
+ // @evidence contracts/common.md#meaningful-documentation Native prose distinguishes default minimum arity from full call validation, includes tuple/void/JavaScript cases and documents same-checker and nil conditions.
1123
+ // @evidenceExclude contracts/performance.md#bound-retention-and-release-resources This forwarding wrapper returns an integer and owns no retained result graph, buffer or handle. Signature arity state and any semantic types resolved by the calculation remain owned by the producing checker.
1124
+ // @evidenceExclude contracts/performance.md#efficient-algorithms The wrapper only guards nil inputs. Upstream calculation can scan tuple-rest elements and trailing parameters, resolve their types and examine void-containing constituents; those list and semantic-resolution costs belong to the checker rather than fixed local steps.
1125
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work Upstream resolvedMinArgumentCount coordinates ordinary default-flag reuse, while the untyped-JavaScript early-zero branch can return before caching. The wrapper owns no additional arity cache or repeated-query coordination.
1126
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation Signature typing uses the supplied checker graph; the wrapper adds no path, host or platform policy.
503
1127
  func Checker_getMinArgumentCount(recv *innerchecker.Checker, signature *innerchecker.Signature) int {
504
1128
  if recv == nil || signature == nil {
505
1129
  return 0
@@ -507,14 +1131,22 @@ func Checker_getMinArgumentCount(recv *innerchecker.Checker, signature *innerche
507
1131
  return checkerGetMinArgumentCount(recv, signature)
508
1132
  }
509
1133
 
510
- // Checker_getSignaturesOfType returns the call or construct signatures declared
511
- // on t, selected by kind (SignatureKindCall / SignatureKindConstruct). This is
512
- // the producer companion to Checker_getMinArgumentCount and
513
- // Checker_getReturnTypeOfSignature: without it the *Signature those two consume
514
- // could not be obtained. A type-transform plugin uses the construct signatures
515
- // of a class's constructor type to detect the `new C(x)` strategy and the call
516
- // signatures of a static `from` member to detect the `C.from(x)` strategy.
517
- // Returns nil if recv or t is nil.
1134
+ // Checker_getSignaturesOfType returns semantic call or construct signatures
1135
+ // selected by kind (SignatureKindCall / SignatureKindConstruct), after reduced
1136
+ // apparent-type normalization. Structured-member resolution can inherit,
1137
+ // instantiate or combine signatures; these are not limited to direct declarations.
1138
+ // Results can be passed to minimum-arity or return-type queries and share the
1139
+ // checker's resolved signature slice. Nonnil t must belong to recv's graph.
1140
+ // Returns nil for nil recv/t or a normalized type with no structured signatures.
1141
+ //
1142
+ // @evidence contracts/common.md#principled-implementation The upstream type query selects call or construct signatures by kind, retaining instantiated overload identities for further checker queries.
1143
+ // @evidence contracts/common.md#clear-and-simple-design One explicit kind parameter separates invocation from construction without duplicating type traversal.
1144
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts Signatures are actual compiler results rather than assumed constructor or factory shapes.
1145
+ // @evidence contracts/common.md#meaningful-documentation Native prose states selectable populations, relationships to arity/return queries and nil absence.
1146
+ // @evidence contracts/performance.md#bound-retention-and-release-resources The returned call/construct subslice shares checker-owned structured signature storage; entries can retain declarations, target/composite signatures and type mappers. The caller controls additional retention, while this wrapper stores no independent result or handle.
1147
+ // @evidenceExclude contracts/performance.md#efficient-algorithms The wrapper only guards nil inputs and forwards the kind. Upstream reduction and structured-member resolution own base/member instantiation and union/intersection signature formation or comparison; their type/signature graph costs precede the direct subslice selection.
1148
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work Structured member resolution and its combined signature storage coordinate reuse within the producing checker. This wrapper adds no signature cache or repeated-query coordination.
1149
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation Signature normalization and resolution use the supplied checker/program; this wrapper introduces no path, host or platform policy.
518
1150
  func Checker_getSignaturesOfType(recv *innerchecker.Checker, t *innerchecker.Type, kind innerchecker.SignatureKind) []*innerchecker.Signature {
519
1151
  if recv == nil || t == nil {
520
1152
  return nil
@@ -522,10 +1154,21 @@ func Checker_getSignaturesOfType(recv *innerchecker.Checker, t *innerchecker.Typ
522
1154
  return recv.GetSignaturesOfType(t, kind)
523
1155
  }
524
1156
 
525
- // Checker_getReturnTypeOfSignature returns the return type of signature, used to
526
- // verify that a static `from(x)` factory actually returns the class instance
527
- // type before selecting the `C.from(x)` construction strategy. Returns nil if
528
- // recv or signature is nil.
1157
+ // Checker_getReturnTypeOfSignature resolves a signature's semantic return type
1158
+ // in its producing checker, including instantiated/composite signatures and
1159
+ // annotation or body inference. Upstream recursion handling can yield error
1160
+ // or any types and report diagnostics; the resolved result is signature state.
1161
+ // This query does not select a consumer's construction strategy. Returns nil
1162
+ // if recv or signature is nil.
1163
+ //
1164
+ // @evidence contracts/common.md#principled-implementation Upstream signature return typing applies its instantiated semantic context rather than using a syntactic return annotation that may be inferred or generic.
1165
+ // @evidence contracts/common.md#clear-and-simple-design One return query complements signature enumeration while keeping semantic resolution inside the checker.
1166
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts The return comes from signature semantics rather than a function's name or a consumer's construction convention.
1167
+ // @evidence contracts/common.md#meaningful-documentation Native prose states producing-checker resolution, inference/composite cases, recursion fallback/state effects and nil inputs without prescribing consumer policy.
1168
+ // @evidence contracts/performance.md#bound-retention-and-release-resources Resolved return types, instantiation/composite type state and diagnostics belong to the producing checker/signature lifetime. The caller can retain that graph through the returned type; this wrapper stores no independent result or handle.
1169
+ // @evidenceExclude contracts/performance.md#efficient-algorithms The wrapper only guards nil inputs. Upstream uncached resolution follows target/composite signatures, instantiates their return types or resolves annotations/function bodies, with cycle handling and optional-chain adjustments; cost follows those semantic/body graphs rather than fixed wrapper steps.
1170
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work Upstream resolvedReturnType and type-resolution state coordinate result reuse and recursion handling. This wrapper adds no return-type cache or repeated-query policy.
1171
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation Return typing and inference remain with the supplied checker/program; the wrapper adds no path, host or platform policy.
529
1172
  func Checker_getReturnTypeOfSignature(recv *innerchecker.Checker, signature *innerchecker.Signature) *innerchecker.Type {
530
1173
  if recv == nil || signature == nil {
531
1174
  return nil
@@ -533,19 +1176,25 @@ func Checker_getReturnTypeOfSignature(recv *innerchecker.Checker, signature *inn
533
1176
  return recv.GetReturnTypeOfSignature(signature)
534
1177
  }
535
1178
 
536
- // Signature_parameterCount returns the number of declared value parameters of a
537
- // call/construct signature. A rest parameter counts as one and the `this`
1179
+ // Signature_parameterCount returns the number of stored value parameters of a
1180
+ // call/construct signature, including synthesized signatures. A rest parameter
1181
+ // counts as one and the `this`
538
1182
  // parameter is excluded (it is held separately from the value parameters).
539
1183
  //
540
1184
  // Checker_getMinArgumentCount alone cannot tell a zero-parameter signature
541
1185
  // (`()` minimum 0) from a single-optional-parameter one (`(x?)` also
542
- // minimum 0). A type-transform plugin needs that distinction to replicate the
543
- // type-level "single meaningful argument" rule: a FIRST parameter must exist
544
- // and every later parameter must be optional or rest, as
545
- // `Signature_parameterCount(sig) >= 1 && Checker_getMinArgumentCount(c, sig) <= 1`.
546
- // Without it the `new C(x)` / `C.from(x)` strategies silently fall back to field
547
- // copy for every optional-first constructor or factory. Returns 0 if signature
548
- // is nil.
1186
+ // minimum 0). This length query does not select a consumer's constructor or
1187
+ // factory strategy, nor replace overload/call validation. Returns 0 if
1188
+ // signature is nil.
1189
+ //
1190
+ // @evidence contracts/common.md#principled-implementation The compiler stores value parameters separately from this; their slice length counts actual stored entries, including one rest entry, independently of minimum call arity or declaration versus synthesized signature origin.
1191
+ // @evidence contracts/common.md#clear-and-simple-design A direct length query answers stored parameter count without conflating it with Checker_getMinArgumentCount.
1192
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts No constructor convention alters the count; it is computed from the actual signature parameter slice.
1193
+ // @evidence contracts/common.md#meaningful-documentation Native paragraphs explain rest/this counting, the distinction from minimum arity and nil zero with useful examples.
1194
+ // @evidenceExclude contracts/performance.md#bound-retention-and-release-resources Signature_parameterCount acquires no handle, buffer or cache and retains nothing after it returns.
1195
+ // @evidenceExclude contracts/performance.md#efficient-algorithms This projection reads the existing upstream parameter slice length after a nil guard and owns no parameter construction, traversal or semantic arity-validation algorithm.
1196
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work The length projection coordinates no completed or in-flight producer, cache or invalidation across requests; the signature owner supplies the already constructed parameter list.
1197
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation Signature_parameterCount computes from its arguments only; it opens no file, builds no path and calls no platform or process API.
549
1198
  func Signature_parameterCount(signature *innerchecker.Signature) int {
550
1199
  if signature == nil {
551
1200
  return 0
@@ -553,15 +1202,24 @@ func Signature_parameterCount(signature *innerchecker.Signature) int {
553
1202
  return len(signature.Parameters())
554
1203
  }
555
1204
 
556
- // Signature_parameters returns the declared value-parameter symbols of a
557
- // call/construct signature, in declaration order, excluding the synthetic
558
- // `this` parameter. The first element is the seed parameter of a `new C(seed)`
559
- // constructor or a `C.from(seed)` factory; feeding it to Checker_getTypeOfSymbol
560
- // yields the seed TYPE the plugin must decode before constructing the instance.
1205
+ // Signature_parameters returns a call/construct signature's stored ordered
1206
+ // value-parameter symbols, including synthesized signature parameters. `this`
1207
+ // is held separately upstream. This accessor does not select a consumer's
1208
+ // constructor/factory seed or validate its type.
561
1209
  //
562
1210
  // Signature_parameterCount is len() of this slice; the slice itself is needed
563
- // because detection (count + min-args) is not enough; emission requires the
564
- // seed parameter's type. Returns nil if signature is nil.
1211
+ // for consumers that need the actual symbols rather than an arity projection.
1212
+ // Returns nil if signature is nil.
1213
+ // The returned slice is compiler-owned; callers must not mutate it.
1214
+ //
1215
+ // @evidence contracts/common.md#principled-implementation Returning the signature's existing value-parameter symbols preserves stored order and checker identity, including synthesized lists, with this represented separately upstream.
1216
+ // @evidence contracts/common.md#clear-and-simple-design One accessor exposes the same slice counted by Signature_parameterCount, avoiding a copied shim parameter representation.
1217
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts The accessor does not create synthetic seed parameters or filter parameters for a particular consumer strategy.
1218
+ // @evidence contracts/common.md#meaningful-documentation Native prose states value/this separation, stored order, synthesized-list and consumer-policy limits, nil behavior and compiler-owned immutable-by-caller slice use.
1219
+ // @evidence contracts/performance.md#bound-retention-and-release-resources The caller receives the signature-owned slice without copying it; retaining that slice can retain its backing store, symbols and semantic graph. The supplied signature/checker owner controls their lifetime, and callers must not mutate the shared contents. This bridge keeps no additional parameter history or handle.
1220
+ // @evidenceExclude contracts/performance.md#efficient-algorithms The upstream accessor returns existing parameter storage directly. The guarded forwarding shim chooses no traversal, filtering, copying or parameter-construction algorithm.
1221
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work The signature owner supplies an already constructed list; this bridge coordinates no completed or in-flight producer, parameter cache or invalidation across requests.
1222
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation Signature_parameters computes from its arguments only; it opens no file, builds no path and calls no platform or process API.
565
1223
  func Signature_parameters(signature *innerchecker.Signature) []*innerast.Symbol {
566
1224
  if signature == nil {
567
1225
  return nil
@@ -569,21 +1227,22 @@ func Signature_parameters(signature *innerchecker.Signature) []*innerast.Symbol
569
1227
  return signature.Parameters()
570
1228
  }
571
1229
 
572
- // Signature_hasRestParameter reports whether the signature's last value
573
- // parameter is a rest parameter (`...xs: S[]`). It is the signal a from/new
574
- // transform needs to tell a rest-only single-seed call `(...xs: S[])`, whose
575
- // seed is the ELEMENT S, from a genuine array-typed parameter `(seed: S[])`,
576
- // whose seed is the array S[]: getTypeOfSymbol yields `S[]` for BOTH, so without
577
- // this flag they are indistinguishable and the rest case decodes the wrong
578
- // shape.
579
- //
580
- // The rest ELEMENT is the seed ONLY when the rest parameter is the sole value
581
- // parameter, i.e. `Signature_hasRestParameter(sig) && Signature_parameterCount(sig) == 1`.
582
- // A leading-required + rest-tail signature `(s: S, ...r: R[])` also has a rest
583
- // parameter (this returns true), but its seed is the FIRST parameter S. Read it
584
- // from Signature_parameters(sig)[0], NOT the rest element, matching
585
- // ClassifiableSeed, whose `[infer P, ...Rest]` arm picks P=S there. Returns
586
- // false if signature is nil.
1230
+ // Signature_hasRestParameter reads the upstream signature's rest flag, which
1231
+ // declaration checking and synthesized/composite signature construction set.
1232
+ // For ordinary declarations it distinguishes a rest parameter (`...xs: S[]`)
1233
+ // from an array-typed ordinary parameter (`xs: S[]`); an earlier required
1234
+ // parameter does not make a later rest parameter disappear. This predicate
1235
+ // does not choose a consumer's seed or compute its rest element type.
1236
+ // Returns false if signature is nil.
1237
+ //
1238
+ // @evidence contracts/common.md#principled-implementation Reading the actual signature flag preserves upstream declaration and synthesized-signature rest semantics; array typing alone and a consumer's seed policy do not replace that flag.
1239
+ // @evidence contracts/common.md#clear-and-simple-design One predicate exposes declaration shape separately from parameter count and rest element typing.
1240
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts Array typing is not used as a shortcut for rest syntax; actual signature flags decide the result.
1241
+ // @evidence contracts/common.md#meaningful-documentation Native prose explains signature-flag provenance, ordinary rest-versus-array distinction, consumer-policy limits and nil false.
1242
+ // @evidenceExclude contracts/performance.md#bound-retention-and-release-resources Signature_hasRestParameter acquires no handle, buffer or cache and retains nothing after it returns.
1243
+ // @evidenceExclude contracts/performance.md#efficient-algorithms Upstream HasRestParameter owns direct signature-flag inspection; this shim only guards nil and chooses no parameter traversal or rest-type calculation algorithm.
1244
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work The predicate reads an existing signature and coordinates no completed or in-flight producer, cache or invalidation across requests.
1245
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation Signature_hasRestParameter computes from its arguments only; it opens no file, builds no path and calls no platform or process API.
587
1246
  func Signature_hasRestParameter(signature *innerchecker.Signature) bool {
588
1247
  if signature == nil {
589
1248
  return false
@@ -591,16 +1250,23 @@ func Signature_hasRestParameter(signature *innerchecker.Signature) bool {
591
1250
  return signature.HasRestParameter()
592
1251
  }
593
1252
 
594
- // Checker_getRestTypeOfSignature returns the ELEMENT type of the signature's
595
- // rest parameter (`...xs: S[]` -> S; a tuple rest unwraps to its element too),
596
- // which is the seed type for a rest-ONLY single-argument constructor/factory,
597
- // matching ClassifiableSeed, which unwraps the rest to its element. When the
598
- // signature has NO rest parameter it falls back to `any` upstream; and a
599
- // leading-required + rest-tail `(s: S, ...r: R[])` has a rest parameter yet its
600
- // seed is the FIRST parameter S, not the rest element. So take the rest element
601
- // only when `Signature_hasRestParameter(sig) && Signature_parameterCount(sig) == 1`;
602
- // otherwise read Signature_parameters(sig)[0]. Returns nil if recv or signature
603
- // is nil.
1253
+ // Checker_getRestTypeOfSignature exposes the upstream rest-type query. It
1254
+ // numeric-indexes the last rest parameter's type (`...xs: S[]` -> S). For a
1255
+ // tuple rest, upstream first derives its variable tail and then numeric-indexes
1256
+ // that derived type; this is not a union of all fixed tuple positions.
1257
+ // Missing rest parameters or absent derived/index information return the
1258
+ // checker's any type. This query does not choose a consumer's seed parameter.
1259
+ // Nonnil inputs must belong to the same checker graph. Returns nil if recv or
1260
+ // signature is nil.
1261
+ //
1262
+ // @evidence contracts/common.md#principled-implementation The compiler derives the last rest parameter's type, extracts a tuple's variable rest part when present, then applies numeric indexing; absent derivable rest typing returns upstream any rather than a fabricated fixed-tuple element union.
1263
+ // @evidence contracts/common.md#clear-and-simple-design One query exposes upstream rest typing independently of declared parameter count or a consumer's choice of seed argument.
1264
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts Ordinary array parameters are not treated as rest declarations and fixed tuple-rest absence is not hidden with a guessed element type.
1265
+ // @evidence contracts/common.md#meaningful-documentation Native prose states the tuple-tail then numeric-index pipeline, any fallback, consumer-policy boundary and same-checker/nil conditions.
1266
+ // @evidence contracts/performance.md#bound-retention-and-release-resources The result is a checker-owned semantic type, including the shared any fallback; the caller can retain its type graph. Upstream tuple-tail derivation owns temporary element slices and any constructed union/index state, while this wrapper keeps no independent result or handle.
1267
+ // @evidenceExclude contracts/performance.md#efficient-algorithms The wrapper only guards nil inputs. Upstream rest-symbol typing, tuple argument/tail traversal and union construction precede numeric index-info resolution; these semantic graph/list costs belong to the checker rather than a fixed-step local strategy.
1268
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work Signature symbol types, tuple/type arguments and structured index information reuse producing-checker state; this wrapper introduces no rest-query cache or repeated-work coordination.
1269
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation Rest and index typing remain with the supplied checker/program; this wrapper adds no path, host or platform policy.
604
1270
  func Checker_getRestTypeOfSignature(recv *innerchecker.Checker, signature *innerchecker.Signature) *innerchecker.Type {
605
1271
  if recv == nil || signature == nil {
606
1272
  return nil
@@ -618,10 +1284,21 @@ func checkerNewSimpleTypeMapper(source *innerchecker.Type, target *innerchecker.
618
1284
  func checkerNewTypeMapper(sources []*innerchecker.Type, targets []*innerchecker.Type) *innerchecker.TypeMapper
619
1285
 
620
1286
  // 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.
1287
+ // types selected by mapper through upstream semantic type structure. Nested
1288
+ // references, unions and other supported type forms use the compiler's
1289
+ // instantiation rules, not textual substitution. Types with no relevant type
1290
+ // variables can pass through; excessive depth/work can yield an error type
1291
+ // and a checker diagnostic. Returns nil if recv or t is nil.
1292
+ // Type and mapper entries must belong to recv; a nil mapper preserves the type.
1293
+ //
1294
+ // @evidence contracts/common.md#principled-implementation The compiler instantiator applies mapper identity through nested semantic type structure, preserving compiler type relationships instead of textual type-parameter replacement.
1295
+ // @evidence contracts/common.md#clear-and-simple-design One instantiation bridge consumes the same mapper model exposed by constructors, avoiding a separate recursive type copier.
1296
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts Substitution uses actual type identities rather than parameter names or selected container special cases.
1297
+ // @evidence contracts/common.md#meaningful-documentation Native prose explains nested substitution, nil result, nil mapper identity and producing-checker premises.
1298
+ // @evidence contracts/performance.md#bound-retention-and-release-resources Returned or constructed types and diagnostics belong to the producing checker graph, which the caller can retain through the result. Upstream active-mapper maps/lists own temporary instantiation state; normal pop clears map entries and mapper references while retaining storage for reuse. The wrapper stores no independent result or handle.
1299
+ // @evidenceExclude contracts/performance.md#efficient-algorithms This wrapper only guards nil inputs. Upstream type-variable detection, active-mapper lookup/cache-key work and recursive instantiation/reduction own graph/list costs, with compiler depth/count limits; the wrapper selects no replacement instantiation strategy.
1300
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work Upstream active mapper caches and type-variable metadata coordinate instantiation reuse. The forwarding wrapper adds no instantiation cache or repeated-work policy.
1301
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation Type/mapper instantiation uses the supplied checker/program; the wrapper introduces no path, host or platform policy.
625
1302
  func Checker_instantiateType(recv *innerchecker.Checker, t *innerchecker.Type, mapper *innerchecker.TypeMapper) *innerchecker.Type {
626
1303
  if recv == nil || t == nil {
627
1304
  return nil
@@ -633,6 +1310,16 @@ func Checker_instantiateType(recv *innerchecker.Checker, t *innerchecker.Type, m
633
1310
  // `source` with `target`. It is the building block for instantiating a generic
634
1311
  // class's constructor type with its reference type arguments. Returns nil if
635
1312
  // source or target is nil.
1313
+ // Source and target must belong to the same semantic checker context.
1314
+ //
1315
+ // @evidence contracts/common.md#principled-implementation Upstream's simple mapper records one source-type identity and its target, providing semantic substitution without name collisions.
1316
+ // @evidence contracts/common.md#clear-and-simple-design The one-pair constructor is distinct from parallel and composed mappings, exposing the representation required for its actual operation.
1317
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts No guessed type-parameter name or fixed consumer class determines the mapping.
1318
+ // @evidence contracts/common.md#meaningful-documentation Native prose identifies one-pair substitution, nil refusal and same-context types.
1319
+ // @evidence contracts/performance.md#bound-retention-and-release-resources Construction acquires one upstream mapper retaining the source and target type references, and transfers it to the caller. Retaining that mapper can retain their semantic graphs; the bridge keeps no additional mapper registry, handle or historical population.
1320
+ // @evidenceExclude contracts/performance.md#efficient-algorithms The upstream simple-mapper constructor owns its fixed-size allocation and its later direct pointer-identity substitution. The bridge only rejects nil inputs and forwards the pair, selecting no separate graph-traversal or substitution algorithm.
1321
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work This constructor transfers a semantic mapping value; it does not coordinate a shared instantiation producer or cache its results. Any reuse by an instantiating checker is owned by that checker, not a new constructor cache.
1322
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation Mapper construction retains supplied semantic type identities and introduces no independent host, path or process policy.
636
1323
  func Checker_newSimpleTypeMapper(source *innerchecker.Type, target *innerchecker.Type) *innerchecker.TypeMapper {
637
1324
  if source == nil || target == nil {
638
1325
  return nil
@@ -645,6 +1332,21 @@ func Checker_newSimpleTypeMapper(source *innerchecker.Type, target *innerchecker
645
1332
  // one substitution's target through later substitutions, so a mapping such as
646
1333
  // `[A, B] -> [B, A]` preserves both target identities. Returns nil when the
647
1334
  // slices are empty, differ in length, or contain nil types.
1335
+ //
1336
+ // For multiple pairs the compiler retains the supplied slices; callers must
1337
+ // not mutate them after construction. A single pair stores the two type
1338
+ // references in a simple mapper. All entries must belong to one semantic
1339
+ // checker context. Mapping selects the first matching source identity without
1340
+ // feeding the selected target back through this mapper.
1341
+ //
1342
+ // @evidence contracts/common.md#principled-implementation Parallel source/target identities are validated pairwise and passed to the compiler mapper without composing targets through other pairs, preserving simultaneous substitution such as a swap.
1343
+ // @evidence contracts/common.md#clear-and-simple-design One constructor owns parallel-shape validation, separate from the explicitly compositional mapper operation.
1344
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts Invalid arrays are rejected rather than truncated, padded or converted into successive substitutions that change meaning.
1345
+ // @evidence contracts/common.md#meaningful-documentation Native paragraphs explain parallel-versus-composed substitution, a swap example, rejection conditions and retained-slice ownership.
1346
+ // @evidence contracts/performance.md#bound-retention-and-release-resources Construction transfers one mapper to the caller: a single pair retains its type references, while multiple pairs retain both caller-owned slice backing stores and their type graphs without copying them. Slice contents must remain stable during use; dropping this mapper releases only its references, not graphs still owned elsewhere. The bridge keeps no historical mapper registry.
1347
+ // @evidence contracts/performance.md#efficient-algorithms One O(N) validation pass checks corresponding nonnil pairs without composing substitutions or allocating copied arrays. Upstream construction stores references in bounded wrapper storage; later mapping is direct for one pair and first-match linear in N for an array mapper. This preserves simultaneous substitution and input identity without a sequential substitution rebuild.
1348
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work The constructor validates and transfers a mapping value rather than coordinating a shared instantiation result or in-flight producer. Instantiating checker state owns any semantic-result reuse; this bridge has no separate cross-request mapper cache/invalidation policy.
1349
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation Works on in-memory type values only; it accesses no path or filesystem.
648
1350
  func Checker_newTypeMapper(sources []*innerchecker.Type, targets []*innerchecker.Type) *innerchecker.TypeMapper {
649
1351
  if len(sources) == 0 || len(sources) != len(targets) {
650
1352
  return nil
@@ -666,6 +1368,17 @@ func checkerCombineTypeMappers(recv *innerchecker.Checker, m1 *innerchecker.Type
666
1368
  // declaration-parameter mappings. Returns m2 when m1 is nil, including when
667
1369
  // recv is nil. Returns nil when m1 is non-nil and recv or m2 is nil, because
668
1370
  // both are required to build a usable composite mapper.
1371
+ //
1372
+ // Types and mappers must belong to recv's semantic checker context.
1373
+ //
1374
+ // @evidence contracts/common.md#principled-implementation Upstream mapper composition instantiates the first stage's target through the second, while absent first stage acts as identity; a nonempty first stage requires both checker and second mapper.
1375
+ // @evidence contracts/common.md#clear-and-simple-design Composition has its own named operation and explicit nil policy, distinct from simultaneous parallel parameter mapping.
1376
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts The stages are composed by compiler semantics rather than flattened into a misleading pair list or repaired with arbitrary fallback types.
1377
+ // @evidence contracts/common.md#meaningful-documentation Native prose states composition order, parallel alternative, all nil cases and same-checker premises.
1378
+ // @evidence contracts/performance.md#bound-retention-and-release-resources The nonempty composition returns one upstream composite mapper retaining recv, m1 and m2; the caller owns its lifetime and the reachable checker/type state. Nil branches allocate no composite, and the wrapper keeps no separate handle or cache.
1379
+ // @evidence contracts/performance.md#efficient-algorithms Fixed nil checks delegate to the upstream O(1) composite construction without visiting mapped types. Applying the returned mapper later owns first-stage mapping and second-stage instantiation costs.
1380
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work The wrapper transfers an existing second mapper or creates a caller-owned composition; it owns no semantic mapper cache or coordination of later mapping work, which belongs to the upstream checker.
1381
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation Checker_combineTypeMappers computes from its arguments only; it opens no file, builds no path and calls no platform or process API.
669
1382
  func Checker_combineTypeMappers(recv *innerchecker.Checker, m1 *innerchecker.TypeMapper, m2 *innerchecker.TypeMapper) *innerchecker.TypeMapper {
670
1383
  if m1 == nil {
671
1384
  return m2