@shapeshift-labs/frontier-lang-compiler 0.2.150 → 0.2.151

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 (276) hide show
  1. package/README.md +315 -9
  2. package/bench/real-repo-corpus-checkout-identity.mjs +134 -0
  3. package/bench/real-repo-corpus-checkout-proof.mjs +263 -0
  4. package/bench/real-repo-corpus-command-execution.mjs +314 -0
  5. package/bench/real-repo-corpus-evidence.mjs +165 -0
  6. package/bench/real-repo-corpus-suite.mjs +273 -0
  7. package/bench/smoke.mjs +109 -7
  8. package/dist/declarations/import-adapter-core.d.ts +4 -3
  9. package/dist/declarations/import-adapter-options-native.d.ts +21 -0
  10. package/dist/declarations/js-ts-project-merge-admission-routes.d.ts +35 -0
  11. package/dist/declarations/js-ts-project-merge-commonjs-interop.d.ts +29 -0
  12. package/dist/declarations/js-ts-project-merge-confidence.d.ts +64 -0
  13. package/dist/declarations/js-ts-project-merge-declaration-emit-parity.d.ts +37 -0
  14. package/dist/declarations/js-ts-project-merge-declarations.d.ts +65 -0
  15. package/dist/declarations/js-ts-project-merge-diagnostics.d.ts +97 -0
  16. package/dist/declarations/js-ts-project-merge-global-augmentation.d.ts +30 -0
  17. package/dist/declarations/js-ts-project-merge-jsx-render-branch.d.ts +48 -0
  18. package/dist/declarations/js-ts-project-merge-proof-levels.d.ts +109 -0
  19. package/dist/declarations/js-ts-project-merge-quality-gates.d.ts +38 -0
  20. package/dist/declarations/js-ts-project-merge-semantic-equivalence-proof.d.ts +45 -0
  21. package/dist/declarations/js-ts-project-merge-tsconfig.d.ts +43 -0
  22. package/dist/declarations/js-ts-safe-merge.d.ts +47 -0
  23. package/dist/declarations/js-ts-safe-project-merge.d.ts +120 -38
  24. package/dist/declarations/native-project-compiler-assignability-oracle.d.ts +41 -0
  25. package/dist/declarations/native-project-compiler-callable-signatures.d.ts +31 -0
  26. package/dist/declarations/native-project-compiler-class-member-runtime-proof.d.ts +87 -0
  27. package/dist/declarations/native-project-compiler-composite-types.d.ts +23 -0
  28. package/dist/declarations/native-project-compiler-enum-proof.d.ts +58 -0
  29. package/dist/declarations/native-project-compiler-index-signature.d.ts +7 -0
  30. package/dist/declarations/native-project-compiler-public-api-source-binding.d.ts +8 -0
  31. package/dist/declarations/native-project-compiler-scope.d.ts +37 -0
  32. package/dist/declarations/native-project-compiler-type-reference-targets.d.ts +38 -0
  33. package/dist/declarations/native-project-css-modules.d.ts +90 -0
  34. package/dist/declarations/native-project-decorator-metadata.d.ts +126 -0
  35. package/dist/declarations/native-project-jsx-graph.d.ts +313 -0
  36. package/dist/declarations/native-project-module-declarations.d.ts +52 -0
  37. package/dist/declarations/native-project-module-resolution.d.ts +76 -1
  38. package/dist/declarations/native-project-runtime-effect-target.d.ts +29 -0
  39. package/dist/declarations/native-project-runtime-executable-effect-evidence.d.ts +107 -0
  40. package/dist/declarations/native-project-runtime-mutation-target.d.ts +33 -0
  41. package/dist/declarations/native-project-runtime-promise-chain.d.ts +30 -0
  42. package/dist/declarations/native-project-runtime-promise-combinator.d.ts +22 -0
  43. package/dist/declarations/native-project-runtime-reachability.d.ts +30 -0
  44. package/dist/declarations/native-project-runtime-resource-management.d.ts +27 -0
  45. package/dist/declarations/native-project-runtime-yield-delegation.d.ts +10 -0
  46. package/dist/declarations/native-project-scope-template-reference.d.ts +13 -0
  47. package/dist/declarations/native-project-source-evidence.d.ts +8 -0
  48. package/dist/declarations/native-project.d.ts +40 -39
  49. package/dist/declarations/semantic-edit-script.d.ts +10 -8
  50. package/dist/declarations/semantic-graph-layers.d.ts +79 -0
  51. package/dist/declarations/semantic-sidecar.d.ts +3 -2
  52. package/dist/declarations/semantic-structural-diff.d.ts +94 -0
  53. package/dist/declarations/source-preservation.d.ts +32 -1
  54. package/dist/declarations/target-adapters.d.ts +22 -2
  55. package/dist/index.d.ts +31 -0
  56. package/dist/index.js +5 -0
  57. package/dist/internal/index-impl/compileNativeSource.js +53 -5
  58. package/dist/internal/index-impl/createLightweightNativeImport.js +58 -4
  59. package/dist/internal/index-impl/createNativeImportFromSyntaxAst.js +17 -1
  60. package/dist/internal/index-impl/createNativeImportFromTypeScriptAst.js +28 -4
  61. package/dist/internal/index-impl/createNativeProjectImportResult.js +31 -27
  62. package/dist/internal/index-impl/createNativeProjectModuleResolutionFromPackageManifests.js +145 -0
  63. package/dist/internal/index-impl/createNativeSourcePreservation.js +34 -7
  64. package/dist/internal/index-impl/createSemanticImportSidecar.js +27 -1
  65. package/dist/internal/index-impl/createTypeScriptCompilerNativeImporterAdapter.js +16 -5
  66. package/dist/internal/index-impl/dynamicImportExpressionMetadata.js +80 -0
  67. package/dist/internal/index-impl/importMetaUrlDependencyMetadata.js +176 -0
  68. package/dist/internal/index-impl/importNativeSource.js +2 -3
  69. package/dist/internal/index-impl/moduleImportAttributeMetadata.js +232 -0
  70. package/dist/internal/index-impl/projectSemanticEditScriptToSource.js +8 -1
  71. package/dist/internal/index-impl/projectSymbolGraphClassStaticBlocks.js +148 -0
  72. package/dist/internal/index-impl/projectSymbolGraphCompilerAdvancedTypeMetadata.js +45 -0
  73. package/dist/internal/index-impl/projectSymbolGraphCompilerCallableSignatureEquivalence.js +107 -0
  74. package/dist/internal/index-impl/projectSymbolGraphCompilerClassPrivateAccessorRuntimeProof.js +280 -0
  75. package/dist/internal/index-impl/projectSymbolGraphCompilerClassShapeEquivalence.js +103 -0
  76. package/dist/internal/index-impl/projectSymbolGraphCompilerConditionalTypeEquivalence.js +242 -0
  77. package/dist/internal/index-impl/projectSymbolGraphCompilerDecoratorRuntimeProof.js +197 -0
  78. package/dist/internal/index-impl/projectSymbolGraphCompilerEnumEquivalence.js +188 -0
  79. package/dist/internal/index-impl/projectSymbolGraphCompilerFacts.js +244 -0
  80. package/dist/internal/index-impl/projectSymbolGraphCompilerIndexSignatureEquivalence.js +58 -0
  81. package/dist/internal/index-impl/projectSymbolGraphCompilerMetadata.js +168 -0
  82. package/dist/internal/index-impl/projectSymbolGraphCompilerTypeEquivalence.js +199 -0
  83. package/dist/internal/index-impl/projectSymbolGraphCompilerTypeEquivalenceProof.js +204 -0
  84. package/dist/internal/index-impl/projectSymbolGraphCompilerTypeReferenceTargetEquivalence.js +99 -0
  85. package/dist/internal/index-impl/projectSymbolGraphCssModuleRecords.js +264 -0
  86. package/dist/internal/index-impl/projectSymbolGraphCssModuleScanners.js +242 -0
  87. package/dist/internal/index-impl/projectSymbolGraphCssModuleUtils.js +152 -0
  88. package/dist/internal/index-impl/projectSymbolGraphCssModules.js +82 -0
  89. package/dist/internal/index-impl/projectSymbolGraphJsxComponentImports.js +170 -0
  90. package/dist/internal/index-impl/projectSymbolGraphJsxComponentProviderLookup.js +167 -0
  91. package/dist/internal/index-impl/projectSymbolGraphJsxComponentWrappers.js +150 -0
  92. package/dist/internal/index-impl/projectSymbolGraphJsxContextTargets.js +71 -0
  93. package/dist/internal/index-impl/projectSymbolGraphJsxContextValues.js +212 -0
  94. package/dist/internal/index-impl/projectSymbolGraphJsxEventHandlers.js +172 -0
  95. package/dist/internal/index-impl/projectSymbolGraphJsxHookEffects.js +124 -0
  96. package/dist/internal/index-impl/projectSymbolGraphJsxHooks.js +281 -0
  97. package/dist/internal/index-impl/projectSymbolGraphJsxMemberComponents.js +139 -0
  98. package/dist/internal/index-impl/projectSymbolGraphJsxPropFlows.js +320 -0
  99. package/dist/internal/index-impl/projectSymbolGraphJsxPropValues.js +145 -0
  100. package/dist/internal/index-impl/projectSymbolGraphJsxProviderFlows.js +133 -0
  101. package/dist/internal/index-impl/projectSymbolGraphJsxRecords.js +315 -0
  102. package/dist/internal/index-impl/projectSymbolGraphJsxRenderCollections.js +155 -0
  103. package/dist/internal/index-impl/projectSymbolGraphJsxRenderReturns.js +291 -0
  104. package/dist/internal/index-impl/projectSymbolGraphJsxRenderRisk.js +279 -0
  105. package/dist/internal/index-impl/projectSymbolGraphModuleDeclarationShapes.js +138 -0
  106. package/dist/internal/index-impl/projectSymbolGraphModuleResolution.js +89 -87
  107. package/dist/internal/index-impl/projectSymbolGraphPackageConditions.js +314 -0
  108. package/dist/internal/index-impl/projectSymbolGraphReExportImportTargets.js +43 -0
  109. package/dist/internal/index-impl/projectSymbolGraphReExports.js +55 -1
  110. package/dist/internal/index-impl/projectSymbolGraphRuntimeRegions.js +108 -0
  111. package/dist/internal/index-impl/projectSymbolGraphScopeUseDefAliases.js +307 -0
  112. package/dist/internal/index-impl/projectSymbolGraphScopeUseDefLexical.js +320 -0
  113. package/dist/internal/index-impl/projectSymbolGraphScopeUseDefOwners.js +50 -0
  114. package/dist/internal/index-impl/projectSymbolGraphScopeUseDefRecordBuilders.js +112 -0
  115. package/dist/internal/index-impl/projectSymbolGraphScopeUseDefRecords.js +238 -0
  116. package/dist/internal/index-impl/projectSymbolGraphScopeUseDefStructural.js +104 -0
  117. package/dist/internal/index-impl/projectSymbolGraphScopeUseDefStructuralNormalize.js +242 -0
  118. package/dist/internal/index-impl/projectSymbolGraphScopeUseDefUseHashes.js +107 -0
  119. package/dist/internal/index-impl/projectSymbolGraphSourceMapGeneratedBoundary.js +111 -0
  120. package/dist/internal/index-impl/projectSymbolGraphSourceRecords.js +268 -0
  121. package/dist/internal/index-impl/projectSymbolGraphSourceRecordsOwnership.js +309 -0
  122. package/dist/internal/index-impl/replaySemanticEditProjection.js +53 -39
  123. package/dist/internal/index-impl/runtimeOrderEvidenceBinding.js +151 -0
  124. package/dist/internal/index-impl/runtimeOrderProofSurfaces.js +253 -0
  125. package/dist/internal/index-impl/semanticEditCallsiteArgumentMerge.js +319 -0
  126. package/dist/internal/index-impl/semanticEditExplicitSourceReplacement.js +7 -2
  127. package/dist/internal/index-impl/semanticEditProjectionRecord.js +8 -0
  128. package/dist/internal/index-impl/semanticEditReplayDiagnostics.js +7 -2
  129. package/dist/internal/index-impl/semanticEditReplayOutputBinding.js +61 -0
  130. package/dist/internal/index-impl/semanticEditReplayRerunRoute.js +27 -0
  131. package/dist/internal/index-impl/semanticEditReplaySourceReplacement.js +6 -1
  132. package/dist/internal/index-impl/semanticEditRuntimeOrderReasons.js +320 -0
  133. package/dist/internal/index-impl/semanticEditScriptClassification.js +90 -5
  134. package/dist/internal/index-impl/semanticEditScripts.js +42 -5
  135. package/dist/internal/index-impl/semanticEditTypeSyntaxReasons.js +134 -0
  136. package/dist/internal/index-impl/semanticIndexFromNativeDeclarations.js +11 -5
  137. package/dist/internal/index-impl/semanticStructuralDiffRecords.js +150 -0
  138. package/dist/internal/index-impl/sourceMapGeneratedBoundaryGate.js +185 -0
  139. package/dist/internal/index-impl/staticMemberLiteral.js +31 -0
  140. package/dist/internal/index-impl/staticOptionalMemberReference.js +22 -0
  141. package/dist/internal/index-impl/syntaxAstSourcePreservation.js +273 -0
  142. package/dist/internal/index-impl/syntaxCommonJsModuleDeclarationEntries.js +297 -0
  143. package/dist/internal/index-impl/syntaxModuleDeclarationEntries.js +56 -132
  144. package/dist/internal/index-impl/syntaxModuleEntryRecords.js +160 -0
  145. package/dist/internal/index-impl/typeScriptCompilerAdvancedTypeShapes.js +160 -0
  146. package/dist/internal/index-impl/typeScriptCompilerAssignabilityOracle.js +97 -0
  147. package/dist/internal/index-impl/typeScriptCompilerClassApi.js +238 -0
  148. package/dist/internal/index-impl/typeScriptCompilerDecoratorMetadata.js +290 -0
  149. package/dist/internal/index-impl/typeScriptCompilerEnumShape.js +279 -0
  150. package/dist/internal/index-impl/typeScriptCompilerFacts.js +294 -0
  151. package/dist/internal/index-impl/typeScriptCompilerInferenceSyntax.js +170 -0
  152. package/dist/internal/index-impl/typeScriptCompilerReferenceGraph.js +186 -0
  153. package/dist/internal/index-impl/typeScriptCompilerSymbolIdentity.js +294 -0
  154. package/dist/internal/index-impl/typeScriptCompilerTypeReferenceTargets.js +142 -0
  155. package/dist/internal/index-impl/typeScriptDeclaration.js +10 -38
  156. package/dist/internal/index-impl/typeScriptModuleDeclarationEntries.js +52 -15
  157. package/dist/internal/index-impl/typeScriptSourceFilePreservation.js +296 -0
  158. package/dist/js-ts-safe-member-class-invariants.js +247 -0
  159. package/dist/js-ts-safe-member-merge-result.js +23 -3
  160. package/dist/js-ts-safe-member-merge.js +28 -4
  161. package/dist/js-ts-safe-merge-binding-patterns.js +170 -0
  162. package/dist/js-ts-safe-merge-jsx-attribute-fallback.js +151 -157
  163. package/dist/js-ts-safe-merge-jsx-attribute-parser.js +277 -0
  164. package/dist/js-ts-safe-merge-jsx-child-expression-fallback.js +161 -0
  165. package/dist/js-ts-safe-merge-jsx-child-expression-merge.js +319 -0
  166. package/dist/js-ts-safe-merge-jsx-child-expression-parser.js +300 -0
  167. package/dist/js-ts-safe-merge-parse-declarations.js +46 -2
  168. package/dist/js-ts-safe-merge-parse-statements.js +8 -0
  169. package/dist/js-ts-safe-merge-semantic-edit-fallback.js +13 -5
  170. package/dist/js-ts-safe-merge-source-shape-fallbacks.js +3 -1
  171. package/dist/js-ts-safe-merge-top-level-rename-fallback.js +31 -5
  172. package/dist/js-ts-safe-merge-top-level-rename-result.js +7 -2
  173. package/dist/js-ts-safe-merge-variable-declarator-fallback.js +124 -6
  174. package/dist/js-ts-safe-merge-variable-declarator-parser.js +34 -4
  175. package/dist/js-ts-safe-merge.js +136 -0
  176. package/dist/js-ts-safe-project-merge-admission-routes.js +216 -0
  177. package/dist/js-ts-safe-project-merge-admission.js +161 -0
  178. package/dist/js-ts-safe-project-merge-ambient.js +110 -0
  179. package/dist/js-ts-safe-project-merge-core.js +85 -0
  180. package/dist/js-ts-safe-project-merge-css-module-conflicts.js +60 -0
  181. package/dist/js-ts-safe-project-merge-declaration-emit-parity.js +186 -0
  182. package/dist/js-ts-safe-project-merge-declarations.js +227 -0
  183. package/dist/js-ts-safe-project-merge-diagnostics-metadata.js +42 -0
  184. package/dist/js-ts-safe-project-merge-diagnostics-ts.js +73 -0
  185. package/dist/js-ts-safe-project-merge-diagnostics.js +283 -0
  186. package/dist/js-ts-safe-project-merge-evidence-routing.js +38 -0
  187. package/dist/js-ts-safe-project-merge-files.js +70 -0
  188. package/dist/js-ts-safe-project-merge-global-augmentation-compatibility.js +99 -0
  189. package/dist/js-ts-safe-project-merge-graph-conflicts.js +90 -2
  190. package/dist/js-ts-safe-project-merge-graph-delta-commonjs-interop.js +108 -0
  191. package/dist/js-ts-safe-project-merge-graph-delta-compiler-conflicts.js +179 -0
  192. package/dist/js-ts-safe-project-merge-graph-delta-compiler-details.js +189 -0
  193. package/dist/js-ts-safe-project-merge-graph-delta-conflicts.js +51 -184
  194. package/dist/js-ts-safe-project-merge-graph-delta-identity-conflicts.js +202 -0
  195. package/dist/js-ts-safe-project-merge-graph-delta-inference-syntax.js +80 -0
  196. package/dist/js-ts-safe-project-merge-graph-delta-module-declarations.js +155 -0
  197. package/dist/js-ts-safe-project-merge-graph-limits.js +16 -1
  198. package/dist/js-ts-safe-project-merge-graph.js +37 -5
  199. package/dist/js-ts-safe-project-merge-import-removal.js +292 -0
  200. package/dist/js-ts-safe-project-merge-jsx-graph-conflict-details.js +235 -0
  201. package/dist/js-ts-safe-project-merge-jsx-graph-conflicts.js +173 -0
  202. package/dist/js-ts-safe-project-merge-jsx-prop-contracts.js +86 -0
  203. package/dist/js-ts-safe-project-merge-jsx-render-branch-proof.js +189 -0
  204. package/dist/js-ts-safe-project-merge-missing-evidence.js +310 -0
  205. package/dist/js-ts-safe-project-merge-move-rename.js +209 -0
  206. package/dist/js-ts-safe-project-merge-proof-conflicts.js +44 -0
  207. package/dist/js-ts-safe-project-merge-proof-levels.js +320 -0
  208. package/dist/js-ts-safe-project-merge-quality-gates.js +140 -0
  209. package/dist/js-ts-safe-project-merge-routing-calibration.js +125 -0
  210. package/dist/js-ts-safe-project-merge-runtime-region-conflicts.js +156 -0
  211. package/dist/js-ts-safe-project-merge-scope-use-def-conflicts.js +292 -0
  212. package/dist/js-ts-safe-project-merge-semantic-equivalence-proof.js +175 -0
  213. package/dist/js-ts-safe-project-merge-semantic-replay-proof.js +311 -0
  214. package/dist/js-ts-safe-project-merge-semantic-replay-routes.js +179 -0
  215. package/dist/js-ts-safe-project-merge-source-span-conflicts.js +310 -0
  216. package/dist/js-ts-safe-project-merge-source-span-roundtrip-proof.js +172 -0
  217. package/dist/js-ts-safe-project-merge-split-merge-admission.js +96 -0
  218. package/dist/js-ts-safe-project-merge-split-merge-records.js +320 -0
  219. package/dist/js-ts-safe-project-merge-split-merge-shapes.js +234 -0
  220. package/dist/js-ts-safe-project-merge-split-merge.js +218 -0
  221. package/dist/js-ts-safe-project-merge-summary.js +320 -0
  222. package/dist/js-ts-safe-project-merge-symbol-move-admission.js +63 -0
  223. package/dist/js-ts-safe-project-merge-symbol-move-default-admission.js +143 -0
  224. package/dist/js-ts-safe-project-merge-symbol-move-risks.js +213 -0
  225. package/dist/js-ts-safe-project-merge-symbol-move.js +316 -0
  226. package/dist/js-ts-safe-project-merge-symbol-rename-admission.js +59 -0
  227. package/dist/js-ts-safe-project-merge-symbol-rename-default-admission.js +111 -0
  228. package/dist/js-ts-safe-project-merge-symbol-rename.js +319 -0
  229. package/dist/js-ts-safe-project-merge-ts-options.js +205 -0
  230. package/dist/js-ts-safe-project-merge-ts-program.js +268 -0
  231. package/dist/js-ts-safe-project-merge-typed-property-rename-rebase-utils.js +69 -0
  232. package/dist/js-ts-safe-project-merge-typed-property-rename-rebase.js +317 -0
  233. package/dist/js-ts-safe-project-merge-unsupported-surfaces.js +319 -0
  234. package/dist/js-ts-safe-project-merge.js +170 -171
  235. package/dist/js-ts-semantic-scope-use-def-bindings.js +287 -0
  236. package/dist/js-ts-semantic-scope-use-def-scan.js +241 -0
  237. package/dist/js-ts-semantic-scope-use-def-utils.js +132 -0
  238. package/dist/js-ts-semantic-scope-use-def.js +217 -0
  239. package/dist/lightweight-dependency-effects.js +28 -4
  240. package/dist/lightweight-dependency-relations.js +13 -7
  241. package/dist/lightweight-dependency-top-level.js +63 -0
  242. package/dist/native-import-language-profiles.js +27 -1
  243. package/dist/native-js-ts-importers.js +9 -5
  244. package/dist/native-parser-ast-format-profiles.js +12 -0
  245. package/dist/native-parser-html-css-format-profiles.js +85 -0
  246. package/dist/native-region-scanner-core.js +5 -3
  247. package/dist/native-region-scanner-js-commonjs.js +155 -0
  248. package/dist/native-region-scanner-js-imports.js +51 -13
  249. package/dist/native-region-scanner-js-reexports.js +79 -0
  250. package/dist/native-region-scanner-js-ts-helpers.js +23 -0
  251. package/dist/native-source-ledger-helpers.js +1 -1
  252. package/dist/native-source-ledger.js +24 -10
  253. package/dist/native-source-maps-ecma426.js +316 -0
  254. package/dist/native-source-maps.js +36 -6
  255. package/dist/native-source-preservation-ownership.js +292 -0
  256. package/dist/native-source-preservation-scanner.js +63 -25
  257. package/dist/native-source-preservation-types.d.ts +3 -0
  258. package/dist/semantic-import-effect-occurrences.js +242 -0
  259. package/dist/semantic-import-effect-regions.js +95 -58
  260. package/dist/semantic-import-graph-layers.js +224 -0
  261. package/dist/semantic-import-runtime-conditional-evidence.js +135 -0
  262. package/dist/semantic-import-runtime-effect-target-evidence.js +145 -0
  263. package/dist/semantic-import-runtime-exit-evidence.js +32 -0
  264. package/dist/semantic-import-runtime-import-meta-evidence.js +33 -0
  265. package/dist/semantic-import-runtime-mutation-evidence.js +155 -0
  266. package/dist/semantic-import-runtime-order-evidence.js +318 -0
  267. package/dist/semantic-import-runtime-promise-chain-evidence.js +103 -0
  268. package/dist/semantic-import-runtime-promise-combinator-evidence.js +166 -0
  269. package/dist/semantic-import-runtime-reachability-evidence.js +269 -0
  270. package/dist/semantic-import-runtime-resource-management-evidence.js +293 -0
  271. package/dist/semantic-import-runtime-switch-evidence.js +304 -0
  272. package/dist/semantic-import-runtime-throw-evidence.js +44 -0
  273. package/dist/semantic-import-runtime-try-finally-evidence.js +172 -0
  274. package/dist/semantic-import-sidecar-entry.js +4 -0
  275. package/dist/semantic-import-source-preservation.js +6 -2
  276. package/package.json +1 -1
@@ -0,0 +1,170 @@
1
+ import { hashSemanticValue } from '@shapeshift-labs/frontier-lang-kernel';
2
+
3
+ const TypeInferenceSyntaxProofKind = 'typescript-checker-public-api-type-inference-syntax-evidence';
4
+
5
+ function compilerTypeInferenceSyntaxRecord(checker, identitySymbol, location, ts) {
6
+ const records = compilerTypeInferenceSyntaxRecords(checker, identitySymbol, location, ts);
7
+ if (!records.length) return {};
8
+ const counts = inferenceSyntaxCounts(records);
9
+ const typeInferenceSyntaxHash = hashSemanticValue({
10
+ kind: 'frontier.lang.typescript.compilerTypeInferenceSyntaxEvidence.v1',
11
+ records: records.map(canonicalInferenceSyntaxRecord)
12
+ });
13
+ return {
14
+ typeInferenceSyntax: records,
15
+ typeInferenceSyntaxKinds: uniqueStrings(records.map((record) => record.kind)),
16
+ typeInferenceSyntaxCount: records.length,
17
+ satisfiesExpressionCount: counts.satisfiesExpressionCount || undefined,
18
+ asConstAssertionCount: counts.asConstAssertionCount || undefined,
19
+ constTypeParameterCount: counts.constTypeParameterCount || undefined,
20
+ typeInferenceSyntaxHash,
21
+ typeInferenceSyntaxProof: {
22
+ kind: TypeInferenceSyntaxProofKind,
23
+ status: 'passed',
24
+ proofLevel: 'typescript-checker-public-api-type-inference-syntax',
25
+ checkerInvariant: 'inference syntax node/type texts complete',
26
+ requiredSignals: [
27
+ 'compiler-type-inference-syntax-node-texts',
28
+ 'compiler-type-inference-syntax-expression-texts',
29
+ 'compiler-type-inference-syntax-type-texts'
30
+ ],
31
+ typeInferenceSyntaxHash,
32
+ ...counts,
33
+ autoMergeClaim: false,
34
+ semanticEquivalenceClaim: false
35
+ }
36
+ };
37
+ }
38
+
39
+ function compilerTypeInferenceSyntaxRecords(checker, identitySymbol, location, ts) {
40
+ const records = [];
41
+ for (const declaration of Array.isArray(identitySymbol?.declarations) ? identitySymbol.declarations : []) {
42
+ visitSyntaxNodes(ts, declaration, (node) => {
43
+ const record = inferenceSyntaxNodeRecord(checker, node, location, ts);
44
+ if (record) records.push(record);
45
+ });
46
+ }
47
+ return uniqueRecords(records, (record) => [record.kind, record.nodeText, record.typeText].join('\0'));
48
+ }
49
+
50
+ function inferenceSyntaxNodeRecord(checker, node, location, ts) {
51
+ if (isSyntaxKind(ts, node, 'SatisfiesExpression')) return satisfiesExpressionRecord(checker, node, location, ts);
52
+ if (isAsConstAssertion(node, ts)) return asConstAssertionRecord(checker, node, location, ts);
53
+ if (isConstTypeParameter(node, ts)) return constTypeParameterRecord(checker, node, location, ts);
54
+ return undefined;
55
+ }
56
+
57
+ function satisfiesExpressionRecord(checker, node, location, ts) {
58
+ return compactRecord({
59
+ kind: 'satisfies-expression',
60
+ syntaxKind: syntaxKindName(ts, node.kind),
61
+ nodeText: nodeText(node),
62
+ expressionText: nodeText(node.expression),
63
+ expressionTypeText: typeTextAt(checker, node.expression, location),
64
+ typeText: typeTextFromTypeNode(checker, node.type, location)
65
+ });
66
+ }
67
+
68
+ function asConstAssertionRecord(checker, node, location, ts) {
69
+ return compactRecord({
70
+ kind: 'as-const-assertion',
71
+ syntaxKind: syntaxKindName(ts, node.kind),
72
+ nodeText: nodeText(node),
73
+ expressionText: nodeText(node.expression),
74
+ expressionTypeText: typeTextAt(checker, node.expression, location),
75
+ typeText: typeTextAt(checker, node, location)
76
+ });
77
+ }
78
+
79
+ function constTypeParameterRecord(checker, node, location, ts) {
80
+ return compactRecord({
81
+ kind: 'const-type-parameter',
82
+ syntaxKind: syntaxKindName(ts, node.kind),
83
+ nodeText: nodeText(node),
84
+ name: stringValue(node.name?.escapedText ?? node.name?.text),
85
+ typeText: typeTextAt(checker, node.name ?? node, location),
86
+ constraintTypeText: typeTextFromTypeNode(checker, node.constraint, location),
87
+ defaultTypeText: typeTextFromTypeNode(checker, node.default, location)
88
+ });
89
+ }
90
+
91
+ function visitSyntaxNodes(ts, node, visit) {
92
+ if (!node || typeof node !== 'object') return;
93
+ visit(node);
94
+ if (typeof ts?.forEachChild === 'function') {
95
+ ts.forEachChild(node, (child) => visitSyntaxNodes(ts, child, visit));
96
+ return;
97
+ }
98
+ for (const value of Object.values(node)) {
99
+ if (Array.isArray(value)) value.forEach((child) => visitSyntaxNodes(ts, child, visit));
100
+ else if (value && typeof value === 'object' && Number.isFinite(value.kind)) visitSyntaxNodes(ts, value, visit);
101
+ }
102
+ }
103
+
104
+ function isAsConstAssertion(node, ts) {
105
+ if (!isSyntaxKind(ts, node, 'AsExpression')) return false;
106
+ return /\bas\s+const\b/.test(nodeText(node));
107
+ }
108
+
109
+ function isConstTypeParameter(node, ts) {
110
+ if (!isSyntaxKind(ts, node, 'TypeParameter')) return false;
111
+ const constKeyword = syntaxKind(ts, 'ConstKeyword');
112
+ return constKeyword !== undefined && Array.isArray(node.modifiers)
113
+ && node.modifiers.some((modifier) => modifier.kind === constKeyword);
114
+ }
115
+
116
+ function inferenceSyntaxCounts(records) {
117
+ return {
118
+ satisfiesExpressionCount: countKind(records, 'satisfies-expression'),
119
+ asConstAssertionCount: countKind(records, 'as-const-assertion'),
120
+ constTypeParameterCount: countKind(records, 'const-type-parameter')
121
+ };
122
+ }
123
+
124
+ function canonicalInferenceSyntaxRecord(record) {
125
+ return compactRecord({
126
+ kind: record.kind,
127
+ nodeText: record.nodeText,
128
+ expressionText: record.expressionText,
129
+ expressionTypeText: record.expressionTypeText,
130
+ typeText: record.typeText,
131
+ constraintTypeText: record.constraintTypeText,
132
+ defaultTypeText: record.defaultTypeText,
133
+ name: record.name
134
+ });
135
+ }
136
+
137
+ function typeTextFromTypeNode(checker, node, location) {
138
+ const type = safeCall(checker?.getTypeFromTypeNode, checker, node) ?? safeCall(checker?.getTypeAtLocation, checker, node ?? location);
139
+ return type ? stringValue(safeCall(checker?.typeToString, checker, type)) : nodeText(node);
140
+ }
141
+
142
+ function typeTextAt(checker, node, location) {
143
+ const type = safeCall(checker?.getTypeAtLocation, checker, node ?? location);
144
+ return type ? stringValue(safeCall(checker?.typeToString, checker, type)) : nodeText(node);
145
+ }
146
+
147
+ function syntaxKind(ts, name) { return numberValue(ts?.SyntaxKind?.[name]); }
148
+ function isSyntaxKind(ts, node, name) { return node?.kind === syntaxKind(ts, name); }
149
+ function syntaxKindName(ts, kind) { return stringValue(ts?.SyntaxKind?.[kind]) ?? (Number.isFinite(kind) ? String(kind) : undefined); }
150
+ function nodeText(node) { return stringValue(safeCall(node?.getText, node)); }
151
+ function countKind(records, kind) { return records.filter((record) => record.kind === kind).length; }
152
+ function safeCall(fn, receiver, ...args) {
153
+ if (typeof fn !== 'function') return undefined;
154
+ try { return fn.apply(receiver, args); } catch { return undefined; }
155
+ }
156
+ function stringValue(value) { return value === undefined || value === null || value === '' ? undefined : String(value); }
157
+ function numberValue(value) { return Number.isFinite(value) ? value : undefined; }
158
+ function compactRecord(record) { return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined)); }
159
+ function uniqueStrings(values) { return [...new Set(values.filter((value) => typeof value === 'string' && value.length > 0))]; }
160
+ function uniqueRecords(records, keyFn) {
161
+ const seen = new Set();
162
+ return records.filter((record) => {
163
+ const key = keyFn(record);
164
+ if (seen.has(key)) return false;
165
+ seen.add(key);
166
+ return true;
167
+ });
168
+ }
169
+
170
+ export { compilerTypeInferenceSyntaxRecord };
@@ -0,0 +1,186 @@
1
+ import { hashSemanticValue } from '@shapeshift-labs/frontier-lang-kernel';
2
+ import { idFragment } from '../../native-import-utils.js';
3
+ import { spanFromTypeScriptNode } from './spanFromTypeScriptNode.js';
4
+ import { typeScriptCompilerSymbolRecordForNode } from './typeScriptCompilerSymbolIdentity.js';
5
+ import { typeScriptKindName } from './typeScriptKindName.js';
6
+
7
+ function createTypeScriptCompilerReferenceGraph(sourceFile, input, options = {}, context, semanticIndex) {
8
+ const checker = options.typeChecker ?? options.checker ?? options.program?.getTypeChecker?.();
9
+ if (!checker || !sourceFile) return emptyReferenceGraph();
10
+ const documentId = semanticIndex?.documents?.[0]?.id ?? `doc_${idFragment(input.sourcePath ?? input.language)}_${idFragment(input.sourceHash)}`;
11
+ const evidenceId = `evidence_${idFragment(input.sourcePath ?? input.language)}_${idFragment(options.astFormat ?? options.parser)}_compiler_references`;
12
+ const records = [];
13
+ visitCompilerReferenceNodes(sourceFile, undefined, options.ts, (node, parent) => {
14
+ if (isDeclarationName(node, parent, options.ts)) return;
15
+ const spanNode = compilerReferenceSpanNode(node, parent, options.ts);
16
+ const compiler = typeScriptCompilerSymbolRecordForNode(node, input, options);
17
+ if (!compiler) return;
18
+ const nativeAstNodeId = context?.objectIds?.get?.(spanNode) ?? context?.objectIds?.get?.(node);
19
+ const span = spanFromTypeScriptNode(spanNode, sourceFile);
20
+ const key = `${compiler.symbolId}\0${nativeAstNodeId ?? spanKey(span)}`;
21
+ if (records.some((record) => record.key === key)) return;
22
+ records.push({ key, node, nativeAstNodeId, span, compiler });
23
+ });
24
+ if (!records.length) return emptyReferenceGraph();
25
+ const occurrences = records.map((record, index) => referenceOccurrence(record, documentId, index));
26
+ const relations = records.map((record, index) => referenceRelation(record, documentId, occurrences[index], evidenceId));
27
+ const facts = records.map((record, index) => referenceFact(record, occurrences[index], relations[index], evidenceId));
28
+ const semanticSymbolIds = new Set((semanticIndex?.symbols ?? []).map((symbol) => symbol.id));
29
+ const mappings = records
30
+ .map((record, index) => referenceMapping(record, occurrences[index], evidenceId, index, semanticSymbolIds))
31
+ .filter(Boolean);
32
+ const evidence = [referenceEvidence(evidenceId, input, options, records)];
33
+ return {
34
+ occurrences,
35
+ relations,
36
+ facts,
37
+ mappings,
38
+ evidence,
39
+ summary: {
40
+ references: records.length,
41
+ symbols: new Set(records.map((record) => record.compiler.symbolId)).size,
42
+ evidenceId
43
+ }
44
+ };
45
+ }
46
+
47
+ function attachTypeScriptCompilerReferenceGraph(semanticIndex, graph) {
48
+ if (!graph?.summary?.references) return semanticIndex;
49
+ return {
50
+ ...semanticIndex,
51
+ occurrences: [...(semanticIndex.occurrences ?? []), ...graph.occurrences],
52
+ relations: [...(semanticIndex.relations ?? []), ...graph.relations],
53
+ facts: [...(semanticIndex.facts ?? []), ...graph.facts],
54
+ evidence: [...(semanticIndex.evidence ?? []), ...graph.evidence],
55
+ metadata: {
56
+ ...(semanticIndex.metadata ?? {}),
57
+ graphCoverage: 'module-edge-declarations+compiler-references',
58
+ compilerReferenceGraph: graph.summary
59
+ }
60
+ };
61
+ }
62
+
63
+ function visitCompilerReferenceNodes(node, parent, ts, visit) {
64
+ if (!node || typeof node !== 'object') return;
65
+ if (isCompilerReferenceNode(node, ts)) visit(node, parent);
66
+ const each = (child) => visitCompilerReferenceNodes(child, node, ts, visit);
67
+ if (ts && typeof ts.forEachChild === 'function') ts.forEachChild(node, each);
68
+ else if (typeof node.forEachChild === 'function') node.forEachChild(each);
69
+ else if (Array.isArray(node.children)) node.children.forEach(each);
70
+ }
71
+
72
+ function isCompilerReferenceNode(node, ts) {
73
+ const kind = typeScriptKindName(node, ts);
74
+ return kind === 'Identifier' || kind === 'PrivateIdentifier';
75
+ }
76
+
77
+ function compilerReferenceSpanNode(node, parent, ts) {
78
+ return isReceiverMemberName(node, parent, ts) ? parent : node;
79
+ }
80
+
81
+ function isReceiverMemberName(node, parent, ts) {
82
+ if (parent?.name !== node) return false;
83
+ if (typeScriptKindName(parent, ts) !== 'PropertyAccessExpression') return false;
84
+ const receiverKind = typeScriptKindName(parent.expression, ts);
85
+ return receiverKind === 'ThisKeyword' || receiverKind === 'SuperKeyword';
86
+ }
87
+
88
+ function referenceOccurrence(record, documentId, index) {
89
+ return compactRecord({
90
+ id: `occ_${idFragment(record.nativeAstNodeId ?? record.key)}_${index + 1}_compiler_reference`,
91
+ documentId,
92
+ symbolId: record.compiler.symbolId,
93
+ role: 'reference',
94
+ span: record.span,
95
+ nativeAstNodeId: record.nativeAstNodeId,
96
+ metadata: { compilerReference: true, compilerSymbol: record.compiler.compilerSymbol }
97
+ });
98
+ }
99
+
100
+ function referenceRelation(record, documentId, occurrence, evidenceId) {
101
+ return {
102
+ id: `rel_${idFragment(hashSemanticValue([documentId, occurrence.id, record.compiler.symbolId, 'compiler-reference']))}`,
103
+ sourceId: occurrence.id,
104
+ predicate: 'references',
105
+ targetId: record.compiler.symbolId,
106
+ evidenceIds: [evidenceId],
107
+ metadata: { compilerReference: true }
108
+ };
109
+ }
110
+
111
+ function referenceFact(record, occurrence, relation, evidenceId) {
112
+ return {
113
+ id: `fact_${idFragment(hashSemanticValue([occurrence.id, relation.id, 'compiler-symbol-reference']))}_compiler_symbol_reference`,
114
+ predicate: 'compilerSymbolReference',
115
+ subjectId: occurrence.id,
116
+ objectId: record.compiler.symbolId,
117
+ value: { ...record.compiler.compilerSymbol, identityHash: record.compiler.compilerSymbolIdentityHash },
118
+ evidenceIds: [evidenceId]
119
+ };
120
+ }
121
+
122
+ function referenceMapping(record, occurrence, evidenceId, index, semanticSymbolIds) {
123
+ if (!semanticSymbolIds.has(record.compiler.symbolId)) return undefined;
124
+ return compactRecord({
125
+ id: `map_${idFragment(record.nativeAstNodeId ?? occurrence.id)}_${index + 1}_compiler_reference`,
126
+ nativeAstNodeId: record.nativeAstNodeId,
127
+ semanticSymbolId: record.compiler.symbolId,
128
+ semanticOccurrenceId: occurrence.id,
129
+ sourceSpan: record.span,
130
+ evidenceIds: [evidenceId],
131
+ lossIds: [],
132
+ precision: record.span ? 'reference' : 'unknown'
133
+ });
134
+ }
135
+
136
+ function referenceEvidence(evidenceId, input, options, records) {
137
+ return {
138
+ id: evidenceId,
139
+ kind: 'typescript-compiler-reference-graph',
140
+ status: 'passed',
141
+ path: input.sourcePath,
142
+ summary: `Resolved ${records.length} TypeScript compiler reference(s).`,
143
+ metadata: {
144
+ parser: options.parser,
145
+ astFormat: options.astFormat,
146
+ language: input.language,
147
+ references: records.length,
148
+ symbols: new Set(records.map((record) => record.compiler.symbolId)).size
149
+ }
150
+ };
151
+ }
152
+
153
+ function isDeclarationName(node, parent, ts) {
154
+ return parent?.name === node && DeclarationNameParentKinds.has(typeScriptKindName(parent, ts));
155
+ }
156
+ function spanKey(span) { return `${span?.path ?? ''}:${span?.startLine ?? ''}:${span?.startColumn ?? ''}:${span?.endLine ?? ''}:${span?.endColumn ?? ''}`; }
157
+ function compactRecord(record) { return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined)); }
158
+ function emptyReferenceGraph() { return { occurrences: [], relations: [], facts: [], mappings: [], evidence: [], summary: { references: 0, symbols: 0 } }; }
159
+
160
+ const DeclarationNameParentKinds = new Set([
161
+ 'BindingElement',
162
+ 'ClassDeclaration',
163
+ 'ClassExpression',
164
+ 'EnumDeclaration',
165
+ 'EnumMember',
166
+ 'FunctionDeclaration',
167
+ 'FunctionExpression',
168
+ 'GetAccessor',
169
+ 'ImportClause',
170
+ 'ImportEqualsDeclaration',
171
+ 'ImportSpecifier',
172
+ 'InterfaceDeclaration',
173
+ 'MethodDeclaration',
174
+ 'MethodSignature',
175
+ 'ModuleDeclaration',
176
+ 'NamespaceImport',
177
+ 'Parameter',
178
+ 'PropertyDeclaration',
179
+ 'PropertySignature',
180
+ 'SetAccessor',
181
+ 'TypeAliasDeclaration',
182
+ 'TypeParameter',
183
+ 'VariableDeclaration'
184
+ ]);
185
+
186
+ export { attachTypeScriptCompilerReferenceGraph, createTypeScriptCompilerReferenceGraph };
@@ -0,0 +1,294 @@
1
+ import { hashSemanticValue } from '@shapeshift-labs/frontier-lang-kernel';
2
+ import { idFragment } from '../../native-import-utils.js';
3
+ import { compilerAdvancedTypeShapes } from './typeScriptCompilerAdvancedTypeShapes.js';
4
+ import { compilerAssignabilityOracleRecord, hasFocusedCompilerApiShape } from './typeScriptCompilerAssignabilityOracle.js';
5
+ import { compilerClassApiRecord } from './typeScriptCompilerClassApi.js';
6
+ import { compilerEnumShapeRecord } from './typeScriptCompilerEnumShape.js';
7
+ import { compilerTypeInferenceSyntaxRecord } from './typeScriptCompilerInferenceSyntax.js';
8
+ import { compilerTypeReferenceTargets } from './typeScriptCompilerTypeReferenceTargets.js';
9
+
10
+ function typeScriptCompilerSymbolRecordForNode(node, input, options = {}, fallbackNode = undefined, idOptions = {}) {
11
+ const checker = options.typeChecker ?? options.checker ?? options.program?.getTypeChecker?.();
12
+ const symbol = safeCall(checker?.getSymbolAtLocation, checker, node) ?? safeCall(checker?.getSymbolAtLocation, checker, fallbackNode);
13
+ if (!symbol) return undefined;
14
+ const aliasedSymbol = safeCall(checker?.getAliasedSymbol, checker, symbol);
15
+ const targetSymbol = aliasedSymbol && aliasedSymbol !== symbol ? aliasedSymbol : undefined;
16
+ const identitySymbol = targetSymbol ?? symbol;
17
+ const fullyQualifiedName = stringValue(safeCall(checker?.getFullyQualifiedName, checker, identitySymbol));
18
+ const localName = compilerSymbolLocalName(symbol, node, options.ts);
19
+ const targetName = targetSymbol ? stringValue(targetSymbol.escapedName ?? targetSymbol.name) : undefined;
20
+ const identity = fullyQualifiedName ?? targetName ?? localName;
21
+ if (!identity) return undefined;
22
+ const compilerSymbol = compactRecord({
23
+ parser: options.parser,
24
+ localName,
25
+ targetName,
26
+ fullyQualifiedName,
27
+ flags: numberValue(symbol.flags),
28
+ targetFlags: numberValue(targetSymbol?.flags),
29
+ declarations: Array.isArray(identitySymbol.declarations) ? identitySymbol.declarations.length : undefined,
30
+ aliased: Boolean(targetSymbol)
31
+ });
32
+ const compilerType = typeScriptCompilerTypeRecordForNode(node, {
33
+ ...options,
34
+ sourcePath: input.sourcePath,
35
+ sourceHash: input.sourceHash
36
+ }, fallbackNode, identitySymbol);
37
+ return {
38
+ identity,
39
+ compilerSymbol,
40
+ compilerSymbolIdentityHash: hashSemanticValue(compilerSymbol),
41
+ compilerType,
42
+ compilerTypeIdentityHash: compilerType ? hashSemanticValue(compilerType) : undefined,
43
+ symbolId: `symbol:${input.language}:compiler:${idOptions.importRole ? 'import:' : ''}${idFragment(identity)}`
44
+ };
45
+ }
46
+
47
+ function typeScriptCompilerTypeRecordForNode(node, options = {}, fallbackNode = undefined, identitySymbol = undefined) {
48
+ const checker = options.typeChecker ?? options.checker ?? options.program?.getTypeChecker?.();
49
+ const type = safeCall(checker?.getTypeAtLocation, checker, node) ?? safeCall(checker?.getTypeAtLocation, checker, fallbackNode);
50
+ if (!type) return undefined;
51
+ const apparentType = safeCall(checker?.getApparentType, checker, type);
52
+ const typeText = stringValue(safeCall(checker?.typeToString, checker, type));
53
+ const apparentTypeText = stringValue(apparentType ? safeCall(checker?.typeToString, checker, apparentType) : undefined);
54
+ const apiSignature = compilerApiSignatureRecord(checker, type, apparentType, node, fallbackNode, options, identitySymbol);
55
+ return compactRecord({
56
+ parser: options.parser,
57
+ typeText,
58
+ apparentTypeText,
59
+ flags: numberValue(type.flags),
60
+ objectFlags: numberValue(type.objectFlags),
61
+ intrinsicName: stringValue(type.intrinsicName),
62
+ ...apiSignature,
63
+ apiSignatureHash: hashSemanticValue({
64
+ kind: 'frontier.lang.typescript.compilerPublicApiSignature.v1',
65
+ parser: options.parser,
66
+ typeText,
67
+ apparentTypeText,
68
+ ...canonicalApiSignatureRecord(apiSignature)
69
+ })
70
+ });
71
+ }
72
+
73
+ function compilerApiSignatureRecord(checker, type, apparentType, node, fallbackNode, options, identitySymbol) {
74
+ const location = fallbackNode ?? node;
75
+ const signatureType = type ?? apparentType;
76
+ const propertyType = apparentType ?? type;
77
+ const typeParameters = compilerTypeParameterRecords(checker, identitySymbol, location, options.ts);
78
+ const callSignatures = compilerSignatureRecords(checker, signatureType, signatureKind(options.ts, 'Call', 0), location, options.ts);
79
+ const constructSignatures = compilerSignatureRecords(checker, signatureType, signatureKind(options.ts, 'Construct', 1), location, options.ts);
80
+ const properties = compilerPropertyRecords(checker, propertyType, location, options.ts);
81
+ const indexSignatures = compilerIndexSignatureRecords(checker, propertyType);
82
+ const advancedTypeShapes = compilerAdvancedTypeShapes(checker, identitySymbol, location, options.ts);
83
+ const typeReferenceTargets = compilerTypeReferenceTargets(checker, identitySymbol, location, options.ts);
84
+ const classApi = compilerClassApiRecord(checker, identitySymbol, location, options.ts);
85
+ const enumShape = compilerEnumShapeRecord(checker, identitySymbol, location, options.ts, options);
86
+ const typeInferenceSyntax = compilerTypeInferenceSyntaxRecord(checker, identitySymbol, location, options.ts);
87
+ const assignabilityOracle = hasFocusedCompilerApiShape({ typeParameters, callSignatures, constructSignatures, properties, indexSignatures, advancedTypeShapes, typeReferenceTargets, classApi, enumShape, typeInferenceSyntax })
88
+ ? undefined
89
+ : compilerAssignabilityOracleRecord(checker, type, apparentType, identitySymbol, location, options.ts);
90
+ return compactRecord({
91
+ typeParameters: nonEmptyArray(typeParameters),
92
+ typeParameterCount: typeParameters.length || undefined,
93
+ typeParameterDefaultCount: typeParameters.filter((parameter) => parameter.hasDefault).length || undefined,
94
+ typeParameterConstraintCount: typeParameters.filter((parameter) => parameter.hasConstraint).length || undefined,
95
+ callSignatures: nonEmptyArray(callSignatures),
96
+ constructSignatures: nonEmptyArray(constructSignatures),
97
+ properties: nonEmptyArray(properties),
98
+ indexSignatures: nonEmptyArray(indexSignatures),
99
+ indexSignatureCount: indexSignatures.length || undefined,
100
+ indexSignatureReadonlyCount: indexSignatures.filter((signature) => signature.readonly === true).length || undefined,
101
+ advancedTypeShapes: nonEmptyArray(advancedTypeShapes),
102
+ advancedTypeShapeKinds: nonEmptyArray(uniqueStrings(advancedTypeShapes.map((shape) => shape.kind))),
103
+ advancedTypeShapeCount: advancedTypeShapes.length || undefined,
104
+ typeReferenceTargets: nonEmptyArray(typeReferenceTargets),
105
+ typeReferenceTargetCount: typeReferenceTargets.length || undefined,
106
+ conditionalTypeCount: countAdvancedTypeShapeKind(advancedTypeShapes, 'conditional-type') || undefined,
107
+ mappedTypeCount: countAdvancedTypeShapeKind(advancedTypeShapes, 'mapped-type') || undefined,
108
+ indexedAccessTypeCount: countAdvancedTypeShapeKind(advancedTypeShapes, 'indexed-access-type') || undefined,
109
+ keyofTypeOperatorCount: countAdvancedTypeShapeKind(advancedTypeShapes, 'keyof-type-operator') || undefined,
110
+ templateLiteralTypeCount: countAdvancedTypeShapeKind(advancedTypeShapes, 'template-literal-type') || undefined,
111
+ inferTypeCount: countAdvancedTypeShapeKind(advancedTypeShapes, 'infer-type') || undefined,
112
+ ...enumShape,
113
+ ...typeInferenceSyntax,
114
+ assignabilityOracleCount: assignabilityOracle ? 1 : undefined,
115
+ assignabilityOracleDirectionCount: assignabilityOracle?.directionCount,
116
+ assignabilityOracleHash: assignabilityOracle ? hashSemanticValue({ kind: 'frontier.lang.typescript.compilerPublicApiAssignabilityOracle.v1', assignabilityOracle }) : undefined,
117
+ assignabilityOracle,
118
+ ...classApi
119
+ });
120
+ }
121
+
122
+ function compilerTypeParameterRecords(checker, identitySymbol, location, ts) {
123
+ const declaration = (Array.isArray(identitySymbol?.declarations) ? identitySymbol.declarations : [])
124
+ .find((item) => Array.isArray(item?.typeParameters) && item.typeParameters.length > 0);
125
+ if (!declaration) return [];
126
+ return declaration.typeParameters.map((parameter, ordinal) => {
127
+ const parameterSymbol = safeCall(checker?.getSymbolAtLocation, checker, parameter.name) ?? parameter.symbol;
128
+ const parameterType = safeCall(checker?.getTypeAtLocation, checker, parameter.name ?? parameter);
129
+ const constraintType = parameter.constraint ? safeCall(checker?.getTypeFromTypeNode, checker, parameter.constraint) : undefined;
130
+ const defaultType = parameter.default ? safeCall(checker?.getTypeFromTypeNode, checker, parameter.default) : undefined;
131
+ return compactRecord({
132
+ name: stringValue(parameter.name?.escapedText ?? parameter.name?.text),
133
+ ordinal,
134
+ typeText: parameterType ? stringValue(safeCall(checker?.typeToString, checker, parameterType)) : undefined,
135
+ constraintTypeText: constraintType ? stringValue(safeCall(checker?.typeToString, checker, constraintType)) : undefined,
136
+ defaultTypeText: defaultType ? stringValue(safeCall(checker?.typeToString, checker, defaultType)) : undefined,
137
+ flags: numberValue(parameterSymbol?.flags),
138
+ hasConstraint: parameter.constraint ? true : undefined,
139
+ hasDefault: parameter.default ? true : undefined,
140
+ variance: typeParameterVariance(ts, parameter)
141
+ });
142
+ });
143
+ }
144
+
145
+ function compilerSignatureRecords(checker, type, kind, location, ts) {
146
+ const signatures = safeCall(checker?.getSignaturesOfType, checker, type, kind);
147
+ if (!Array.isArray(signatures) || !signatures.length) return [];
148
+ return signatures.map((signature) => compactRecord({
149
+ signatureText: stringValue(safeCall(checker?.signatureToString, checker, signature)),
150
+ returnTypeText: compilerReturnTypeText(checker, signature),
151
+ parameters: nonEmptyArray(compilerSignatureParameterRecords(checker, signature, location, ts))
152
+ }));
153
+ }
154
+
155
+ function compilerSignatureParameterRecords(checker, signature, location, ts) {
156
+ const parameters = Array.isArray(signature?.parameters)
157
+ ? signature.parameters
158
+ : safeCall(signature?.getParameters, signature);
159
+ if (!Array.isArray(parameters)) return [];
160
+ return parameters.map((parameter) => {
161
+ const parameterType = safeCall(checker?.getTypeOfSymbolAtLocation, checker, parameter, location);
162
+ return compactRecord({
163
+ name: stringValue(parameter.escapedName ?? parameter.name),
164
+ typeText: parameterType ? stringValue(safeCall(checker?.typeToString, checker, parameterType)) : undefined,
165
+ flags: numberValue(parameter.flags),
166
+ optional: hasSymbolFlag(parameter, ts, 'Optional')
167
+ });
168
+ });
169
+ }
170
+
171
+ function compilerReturnTypeText(checker, signature) {
172
+ const returnType = safeCall(checker?.getReturnTypeOfSignature, checker, signature);
173
+ return returnType ? stringValue(safeCall(checker?.typeToString, checker, returnType)) : undefined;
174
+ }
175
+
176
+ function compilerPropertyRecords(checker, type, location, ts) {
177
+ const properties = safeCall(checker?.getPropertiesOfType, checker, type);
178
+ if (!Array.isArray(properties) || !properties.length) return [];
179
+ return properties
180
+ .map((property) => {
181
+ const declaration = Array.isArray(property.declarations) ? property.declarations[0] : undefined;
182
+ const propertyType = safeCall(checker?.getTypeOfSymbolAtLocation, checker, property, declaration ?? location);
183
+ return compactRecord({
184
+ name: stringValue(property.escapedName ?? property.name),
185
+ typeText: propertyType ? stringValue(safeCall(checker?.typeToString, checker, propertyType)) : undefined,
186
+ flags: numberValue(property.flags),
187
+ optional: hasSymbolFlag(property, ts, 'Optional'),
188
+ readonly: compilerPropertyReadonly(property, ts),
189
+ declarations: Array.isArray(property.declarations) ? property.declarations.length : undefined
190
+ });
191
+ })
192
+ .sort((left, right) => String(left.name ?? '').localeCompare(String(right.name ?? '')));
193
+ }
194
+
195
+ function compilerIndexSignatureRecords(checker, type) {
196
+ const indexInfos = safeCall(checker?.getIndexInfosOfType, checker, type);
197
+ if (!Array.isArray(indexInfos) || !indexInfos.length) return [];
198
+ return indexInfos.map((info, ordinal) => compactRecord({
199
+ ordinal,
200
+ keyTypeText: info?.keyType ? stringValue(safeCall(checker?.typeToString, checker, info.keyType)) : undefined,
201
+ valueTypeText: info?.type ? stringValue(safeCall(checker?.typeToString, checker, info.type)) : undefined,
202
+ readonly: typeof info?.isReadonly === 'boolean' ? info.isReadonly : undefined,
203
+ declarationText: nodeText(info?.declaration)
204
+ })).sort((left, right) => String(left.keyTypeText ?? '').localeCompare(String(right.keyTypeText ?? '')));
205
+ }
206
+
207
+ function countAdvancedTypeShapeKind(records, kind) { return records.filter((record) => record.kind === kind).length; }
208
+
209
+ function safeCall(fn, receiver, ...args) {
210
+ if (typeof fn !== 'function') return undefined;
211
+ try { return fn.apply(receiver, args); } catch { return undefined; }
212
+ }
213
+
214
+ function stringValue(value) {
215
+ return value === undefined || value === null || value === '' ? undefined : String(value);
216
+ }
217
+
218
+ function numberValue(value) { return Number.isFinite(value) ? value : undefined; }
219
+ function compilerSymbolLocalName(symbol, node, ts) {
220
+ return isPrivateIdentifier(node, ts)
221
+ ? nodeText(node)
222
+ : stringValue(symbol.escapedName ?? symbol.name);
223
+ }
224
+ function signatureKind(ts, name, fallback) { return numberValue(ts?.SignatureKind?.[name]) ?? fallback; }
225
+ function typeParameterVariance(ts, parameter) {
226
+ const modifiers = Array.isArray(parameter?.modifiers) ? parameter.modifiers : [];
227
+ const inKeyword = numberValue(ts?.SyntaxKind?.InKeyword);
228
+ const outKeyword = numberValue(ts?.SyntaxKind?.OutKeyword);
229
+ const hasIn = inKeyword !== undefined && modifiers.some((modifier) => modifier.kind === inKeyword);
230
+ const hasOut = outKeyword !== undefined && modifiers.some((modifier) => modifier.kind === outKeyword);
231
+ if (hasIn && hasOut) return 'in out';
232
+ if (hasIn) return 'in';
233
+ if (hasOut) return 'out';
234
+ return undefined;
235
+ }
236
+ function compilerPropertyReadonly(property, ts) {
237
+ const readonlyFlag = numberValue(ts?.ModifierFlags?.Readonly);
238
+ const modifierFlags = numberValue(safeCall(ts?.getDeclarationModifierFlagsFromSymbol, ts, property));
239
+ if (readonlyFlag !== undefined && modifierFlags !== undefined) return Boolean(modifierFlags & readonlyFlag);
240
+ const declarations = Array.isArray(property?.declarations) ? property.declarations : [];
241
+ const readonlyKeyword = numberValue(ts?.SyntaxKind?.ReadonlyKeyword);
242
+ if (readonlyKeyword === undefined || !declarations.length) return undefined;
243
+ return declarations.some((declaration) => (
244
+ Array.isArray(declaration?.modifiers)
245
+ && declaration.modifiers.some((modifier) => modifier.kind === readonlyKeyword)
246
+ ));
247
+ }
248
+ function hasSymbolFlag(symbol, ts, flagName) {
249
+ const flag = numberValue(ts?.SymbolFlags?.[flagName]);
250
+ return flag !== undefined && numberValue(symbol?.flags) !== undefined ? Boolean(symbol.flags & flag) : undefined;
251
+ }
252
+ function canonicalApiSignatureRecord(record) {
253
+ return compactRecord({
254
+ ...record,
255
+ typeParameters: nonEmptyArray(arrayValue(record.typeParameters).map(({ flags: _flags, ...parameter }) => parameter)),
256
+ callSignatures: nonEmptyArray(arrayValue(record.callSignatures).map(canonicalSignatureRecord)),
257
+ constructSignatures: nonEmptyArray(arrayValue(record.constructSignatures).map(canonicalSignatureRecord)),
258
+ properties: nonEmptyArray(arrayValue(record.properties).map(({ flags: _flags, ...property }) => property)),
259
+ indexSignatures: nonEmptyArray(arrayValue(record.indexSignatures)),
260
+ typeReferenceTargets: nonEmptyArray(arrayValue(record.typeReferenceTargets).map(canonicalTypeReferenceTargetRecord))
261
+ });
262
+ }
263
+ function canonicalTypeReferenceTargetRecord(target) {
264
+ return compactRecord({
265
+ kind: target.kind,
266
+ typeReferenceName: target.typeReferenceName,
267
+ targetStatus: target.targetStatus,
268
+ targetAliased: target.targetAliased,
269
+ targetSymbolName: target.targetSymbolName,
270
+ targetFullyQualifiedName: target.targetFullyQualifiedName,
271
+ targetSymbolFlags: target.targetSymbolFlags,
272
+ targetDeclarationKind: target.targetDeclarationKind,
273
+ typeArgumentCount: target.typeArgumentCount
274
+ });
275
+ }
276
+ function canonicalSignatureRecord(signature) {
277
+ return compactRecord({
278
+ ...signature,
279
+ parameters: nonEmptyArray(arrayValue(signature.parameters).map(({ flags: _flags, ...parameter }) => parameter))
280
+ });
281
+ }
282
+ function nonEmptyArray(value) { return Array.isArray(value) && value.length ? value : undefined; }
283
+ function arrayValue(value) { return Array.isArray(value) ? value : []; }
284
+ function nodeText(node) { return stringValue(safeCall(node?.getText, node)); }
285
+ function isPrivateIdentifier(node, ts) {
286
+ const privateIdentifier = numberValue(ts?.SyntaxKind?.PrivateIdentifier);
287
+ return privateIdentifier !== undefined
288
+ ? node?.kind === privateIdentifier
289
+ : nodeText(node)?.startsWith('#') === true;
290
+ }
291
+ function uniqueStrings(values) { return [...new Set(values.filter((value) => typeof value === 'string' && value.length > 0))]; }
292
+ function compactRecord(record) { return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined)); }
293
+
294
+ export { typeScriptCompilerSymbolRecordForNode };