tsc-ts 0.0.4 → 0.0.6

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 (584) hide show
  1. package/README.md +34 -2
  2. package/dist/api/compiler/ast-utilities.d.ts +82 -0
  3. package/dist/api/compiler/ast-utilities.js +462 -0
  4. package/dist/api/compiler/ast.d.ts +2351 -0
  5. package/dist/api/compiler/ast.js +11212 -0
  6. package/dist/api/compiler/astnav.d.ts +37 -0
  7. package/dist/api/compiler/astnav.js +767 -0
  8. package/dist/api/compiler/binder-utilities.d.ts +182 -0
  9. package/dist/api/compiler/binder-utilities.js +1241 -0
  10. package/dist/api/compiler/binder.d.ts +33 -0
  11. package/dist/api/compiler/binder.js +2359 -0
  12. package/dist/api/compiler/character-codes.d.ts +161 -0
  13. package/dist/api/compiler/character-codes.js +160 -0
  14. package/dist/api/compiler/checker-calls.d.ts +46 -0
  15. package/dist/api/compiler/checker-calls.js +1641 -0
  16. package/dist/api/compiler/checker-classes.d.ts +30 -0
  17. package/dist/api/compiler/checker-classes.js +582 -0
  18. package/dist/api/compiler/checker-contextual.d.ts +77 -0
  19. package/dist/api/compiler/checker-contextual.js +1136 -0
  20. package/dist/api/compiler/checker-declaration-order.d.ts +12 -0
  21. package/dist/api/compiler/checker-declaration-order.js +357 -0
  22. package/dist/api/compiler/checker-declarations.d.ts +33 -0
  23. package/dist/api/compiler/checker-declarations.js +888 -0
  24. package/dist/api/compiler/checker-declared-types.d.ts +48 -0
  25. package/dist/api/compiler/checker-declared-types.js +788 -0
  26. package/dist/api/compiler/checker-decorators.d.ts +26 -0
  27. package/dist/api/compiler/checker-decorators.js +562 -0
  28. package/dist/api/compiler/checker-deprecation.d.ts +33 -0
  29. package/dist/api/compiler/checker-deprecation.js +314 -0
  30. package/dist/api/compiler/checker-destructuring.d.ts +34 -0
  31. package/dist/api/compiler/checker-destructuring.js +584 -0
  32. package/dist/api/compiler/checker-elaboration.d.ts +15 -0
  33. package/dist/api/compiler/checker-elaboration.js +291 -0
  34. package/dist/api/compiler/checker-emit-helpers.d.ts +58 -0
  35. package/dist/api/compiler/checker-emit-helpers.js +154 -0
  36. package/dist/api/compiler/checker-emit-resolver.d.ts +75 -0
  37. package/dist/api/compiler/checker-emit-resolver.js +580 -0
  38. package/dist/api/compiler/checker-evaluator.d.ts +27 -0
  39. package/dist/api/compiler/checker-evaluator.js +188 -0
  40. package/dist/api/compiler/checker-expressions.d.ts +67 -0
  41. package/dist/api/compiler/checker-expressions.js +1351 -0
  42. package/dist/api/compiler/checker-features.d.ts +6 -0
  43. package/dist/api/compiler/checker-features.js +354 -0
  44. package/dist/api/compiler/checker-flow.d.ts +86 -0
  45. package/dist/api/compiler/checker-flow.js +169 -0
  46. package/dist/api/compiler/checker-functions.d.ts +43 -0
  47. package/dist/api/compiler/checker-functions.js +1002 -0
  48. package/dist/api/compiler/checker-generated-code.d.ts +25 -0
  49. package/dist/api/compiler/checker-generated-code.js +168 -0
  50. package/dist/api/compiler/checker-globals.d.ts +14 -0
  51. package/dist/api/compiler/checker-globals.js +37 -0
  52. package/dist/api/compiler/checker-grammar.d.ts +35 -0
  53. package/dist/api/compiler/checker-grammar.js +2587 -0
  54. package/dist/api/compiler/checker-heritage.d.ts +28 -0
  55. package/dist/api/compiler/checker-heritage.js +901 -0
  56. package/dist/api/compiler/checker-inference.d.ts +179 -0
  57. package/dist/api/compiler/checker-inference.js +2105 -0
  58. package/dist/api/compiler/checker-iteration.d.ts +115 -0
  59. package/dist/api/compiler/checker-iteration.js +857 -0
  60. package/dist/api/compiler/checker-javascript.d.ts +42 -0
  61. package/dist/api/compiler/checker-javascript.js +442 -0
  62. package/dist/api/compiler/checker-jsdoc.d.ts +30 -0
  63. package/dist/api/compiler/checker-jsdoc.js +320 -0
  64. package/dist/api/compiler/checker-jsx.d.ts +94 -0
  65. package/dist/api/compiler/checker-jsx.js +1433 -0
  66. package/dist/api/compiler/checker-literals.d.ts +6 -0
  67. package/dist/api/compiler/checker-literals.js +43 -0
  68. package/dist/api/compiler/checker-members.d.ts +200 -0
  69. package/dist/api/compiler/checker-members.js +2148 -0
  70. package/dist/api/compiler/checker-modules.d.ts +85 -0
  71. package/dist/api/compiler/checker-modules.js +2141 -0
  72. package/dist/api/compiler/checker-narrowing.d.ts +120 -0
  73. package/dist/api/compiler/checker-narrowing.js +2797 -0
  74. package/dist/api/compiler/checker-object-literals.d.ts +14 -0
  75. package/dist/api/compiler/checker-object-literals.js +483 -0
  76. package/dist/api/compiler/checker-operators.d.ts +33 -0
  77. package/dist/api/compiler/checker-operators.js +1040 -0
  78. package/dist/api/compiler/checker-overloads.d.ts +7 -0
  79. package/dist/api/compiler/checker-overloads.js +271 -0
  80. package/dist/api/compiler/checker-property-access.d.ts +34 -0
  81. package/dist/api/compiler/checker-property-access.js +672 -0
  82. package/dist/api/compiler/checker-services.d.ts +49 -0
  83. package/dist/api/compiler/checker-services.js +995 -0
  84. package/dist/api/compiler/checker-signatures.d.ts +55 -0
  85. package/dist/api/compiler/checker-signatures.js +789 -0
  86. package/dist/api/compiler/checker-source-file.d.ts +27 -0
  87. package/dist/api/compiler/checker-source-file.js +619 -0
  88. package/dist/api/compiler/checker-statements.d.ts +18 -0
  89. package/dist/api/compiler/checker-statements.js +226 -0
  90. package/dist/api/compiler/checker-super.d.ts +13 -0
  91. package/dist/api/compiler/checker-super.js +241 -0
  92. package/dist/api/compiler/checker-symbol-types.d.ts +51 -0
  93. package/dist/api/compiler/checker-symbol-types.js +955 -0
  94. package/dist/api/compiler/checker-symbols.d.ts +181 -0
  95. package/dist/api/compiler/checker-symbols.js +1784 -0
  96. package/dist/api/compiler/checker-type-factory.d.ts +142 -0
  97. package/dist/api/compiler/checker-type-factory.js +2542 -0
  98. package/dist/api/compiler/checker-type-nodes.d.ts +26 -0
  99. package/dist/api/compiler/checker-type-nodes.js +828 -0
  100. package/dist/api/compiler/checker-type-operators.d.ts +109 -0
  101. package/dist/api/compiler/checker-type-operators.js +1842 -0
  102. package/dist/api/compiler/checker-types.d.ts +1093 -0
  103. package/dist/api/compiler/checker-types.js +1874 -0
  104. package/dist/api/compiler/checker-unused.d.ts +19 -0
  105. package/dist/api/compiler/checker-unused.js +524 -0
  106. package/dist/api/compiler/checker-utilities.d.ts +33 -0
  107. package/dist/api/compiler/checker-utilities.js +141 -0
  108. package/dist/api/compiler/checker.d.ts +512 -0
  109. package/dist/api/compiler/checker.js +932 -0
  110. package/dist/api/compiler/command-line.d.ts +32 -0
  111. package/dist/api/compiler/command-line.js +383 -0
  112. package/dist/api/compiler/compile-program.d.ts +118 -0
  113. package/dist/api/compiler/compile-program.js +384 -0
  114. package/dist/api/compiler/diagnostic-locales.d.ts +22 -0
  115. package/dist/api/compiler/diagnostic-locales.js +64 -0
  116. package/dist/api/compiler/diagnostic-messages.d.ts +2166 -0
  117. package/dist/api/compiler/diagnostic-messages.js +184 -0
  118. package/dist/api/compiler/diagnostics.d.ts +161 -0
  119. package/dist/api/compiler/diagnostics.js +784 -0
  120. package/dist/api/compiler/emitter.d.ts +71 -0
  121. package/dist/api/compiler/emitter.js +327 -0
  122. package/dist/api/compiler/file-include.d.ts +144 -0
  123. package/dist/api/compiler/file-include.js +599 -0
  124. package/dist/api/compiler/file-loader.d.ts +290 -0
  125. package/dist/api/compiler/file-loader.js +1323 -0
  126. package/dist/api/compiler/file-system.d.ts +51 -0
  127. package/dist/api/compiler/file-system.js +132 -0
  128. package/dist/api/compiler/flow.d.ts +60 -0
  129. package/dist/api/compiler/flow.js +45 -0
  130. package/dist/api/compiler/instantiation.d.ts +74 -0
  131. package/dist/api/compiler/instantiation.js +835 -0
  132. package/dist/api/compiler/jsdoc.d.ts +75 -0
  133. package/dist/api/compiler/jsdoc.js +1229 -0
  134. package/dist/api/compiler/link-tables.d.ts +105 -0
  135. package/dist/api/compiler/link-tables.js +319 -0
  136. package/dist/api/compiler/locale-data.d.ts +24 -0
  137. package/dist/api/compiler/locale-data.js +183 -0
  138. package/dist/api/compiler/locale.d.ts +4 -0
  139. package/dist/api/compiler/locale.js +317 -0
  140. package/dist/api/compiler/locales/cs-CZ.d.ts +2 -0
  141. package/dist/api/compiler/locales/cs-CZ.js +3 -0
  142. package/dist/api/compiler/locales/de-DE.d.ts +2 -0
  143. package/dist/api/compiler/locales/de-DE.js +3 -0
  144. package/dist/api/compiler/locales/es-ES.d.ts +2 -0
  145. package/dist/api/compiler/locales/es-ES.js +3 -0
  146. package/dist/api/compiler/locales/fr-FR.d.ts +2 -0
  147. package/dist/api/compiler/locales/fr-FR.js +3 -0
  148. package/dist/api/compiler/locales/it-IT.d.ts +2 -0
  149. package/dist/api/compiler/locales/it-IT.js +3 -0
  150. package/dist/api/compiler/locales/ja-JP.d.ts +2 -0
  151. package/dist/api/compiler/locales/ja-JP.js +3 -0
  152. package/dist/api/compiler/locales/ko-KR.d.ts +2 -0
  153. package/dist/api/compiler/locales/ko-KR.js +3 -0
  154. package/dist/api/compiler/locales/pl-PL.d.ts +2 -0
  155. package/dist/api/compiler/locales/pl-PL.js +3 -0
  156. package/dist/api/compiler/locales/pt-BR.d.ts +2 -0
  157. package/dist/api/compiler/locales/pt-BR.js +3 -0
  158. package/dist/api/compiler/locales/ru-RU.d.ts +2 -0
  159. package/dist/api/compiler/locales/ru-RU.js +3 -0
  160. package/dist/api/compiler/locales/tr-TR.d.ts +2 -0
  161. package/dist/api/compiler/locales/tr-TR.js +3 -0
  162. package/dist/api/compiler/locales/zh-CN.d.ts +2 -0
  163. package/dist/api/compiler/locales/zh-CN.js +3 -0
  164. package/dist/api/compiler/locales/zh-TW.d.ts +2 -0
  165. package/dist/api/compiler/locales/zh-TW.js +3 -0
  166. package/dist/api/compiler/module-resolution-types.d.ts +83 -0
  167. package/dist/api/compiler/module-resolution-types.js +176 -0
  168. package/dist/api/compiler/module-resolution.d.ts +71 -0
  169. package/dist/api/compiler/module-resolution.js +1598 -0
  170. package/dist/api/compiler/module-specifiers.d.ts +64 -0
  171. package/dist/api/compiler/module-specifiers.js +1101 -0
  172. package/dist/api/compiler/name-resolver.d.ts +43 -0
  173. package/dist/api/compiler/name-resolver.js +509 -0
  174. package/dist/api/compiler/node-builder-names.d.ts +32 -0
  175. package/dist/api/compiler/node-builder-names.js +854 -0
  176. package/dist/api/compiler/node-builder-pseudo.d.ts +36 -0
  177. package/dist/api/compiler/node-builder-pseudo.js +745 -0
  178. package/dist/api/compiler/node-builder-reuse.d.ts +4 -0
  179. package/dist/api/compiler/node-builder-reuse.js +647 -0
  180. package/dist/api/compiler/node-builder.d.ts +270 -0
  181. package/dist/api/compiler/node-builder.js +2645 -0
  182. package/dist/api/compiler/option-declarations.d.ts +90 -0
  183. package/dist/api/compiler/option-declarations.js +1460 -0
  184. package/dist/api/compiler/options.d.ts +289 -0
  185. package/dist/api/compiler/options.js +1197 -0
  186. package/dist/api/compiler/output-paths.d.ts +42 -0
  187. package/dist/api/compiler/output-paths.js +195 -0
  188. package/dist/api/compiler/package-json.d.ts +175 -0
  189. package/dist/api/compiler/package-json.js +1015 -0
  190. package/dist/api/compiler/parallel-parse.d.ts +221 -0
  191. package/dist/api/compiler/parallel-parse.js +541 -0
  192. package/dist/api/compiler/parser.d.ts +604 -0
  193. package/dist/api/compiler/parser.js +6426 -0
  194. package/dist/api/compiler/path.d.ts +91 -0
  195. package/dist/api/compiler/path.js +705 -0
  196. package/dist/api/compiler/printer/async-helpers.d.ts +22 -0
  197. package/dist/api/compiler/printer/async-helpers.js +91 -0
  198. package/dist/api/compiler/printer/auto-generate.d.ts +13 -0
  199. package/dist/api/compiler/printer/auto-generate.js +20 -0
  200. package/dist/api/compiler/printer/decorator-helpers.d.ts +24 -0
  201. package/dist/api/compiler/printer/decorator-helpers.js +118 -0
  202. package/dist/api/compiler/printer/emit-context.d.ts +157 -0
  203. package/dist/api/compiler/printer/emit-context.js +582 -0
  204. package/dist/api/compiler/printer/emit-flags.d.ts +60 -0
  205. package/dist/api/compiler/printer/emit-flags.js +2 -0
  206. package/dist/api/compiler/printer/factory-base.d.ts +171 -0
  207. package/dist/api/compiler/printer/factory-base.js +1505 -0
  208. package/dist/api/compiler/printer/factory.d.ts +147 -0
  209. package/dist/api/compiler/printer/factory.js +542 -0
  210. package/dist/api/compiler/printer/helpers.d.ts +27 -0
  211. package/dist/api/compiler/printer/helpers.js +164 -0
  212. package/dist/api/compiler/printer/name-generator.d.ts +41 -0
  213. package/dist/api/compiler/printer/name-generator.js +283 -0
  214. package/dist/api/compiler/printer/printer.d.ts +411 -0
  215. package/dist/api/compiler/printer/printer.js +4517 -0
  216. package/dist/api/compiler/printer/text-writer.d.ts +46 -0
  217. package/dist/api/compiler/printer/text-writer.js +172 -0
  218. package/dist/api/compiler/printer/utilities.d.ts +82 -0
  219. package/dist/api/compiler/printer/utilities.js +817 -0
  220. package/dist/api/compiler/program-checker.d.ts +156 -0
  221. package/dist/api/compiler/program-checker.js +529 -0
  222. package/dist/api/compiler/program-utilities.d.ts +52 -0
  223. package/dist/api/compiler/program-utilities.js +365 -0
  224. package/dist/api/compiler/program.d.ts +180 -0
  225. package/dist/api/compiler/program.js +1019 -0
  226. package/dist/api/compiler/pseudo-bigint.d.ts +5 -0
  227. package/dist/api/compiler/pseudo-bigint.js +61 -0
  228. package/dist/api/compiler/regexp-checker.d.ts +38 -0
  229. package/dist/api/compiler/regexp-checker.js +942 -0
  230. package/dist/api/compiler/relations.d.ts +263 -0
  231. package/dist/api/compiler/relations.js +4002 -0
  232. package/dist/api/compiler/reparser.d.ts +48 -0
  233. package/dist/api/compiler/reparser.js +1323 -0
  234. package/dist/api/compiler/scanner.d.ts +256 -0
  235. package/dist/api/compiler/scanner.js +2853 -0
  236. package/dist/api/compiler/side-state.d.ts +16 -0
  237. package/dist/api/compiler/side-state.js +89 -0
  238. package/dist/api/compiler/sourcemap.d.ts +55 -0
  239. package/dist/api/compiler/sourcemap.js +340 -0
  240. package/dist/api/compiler/spelling.d.ts +14 -0
  241. package/dist/api/compiler/spelling.js +128 -0
  242. package/dist/api/compiler/symbol-accessibility.d.ts +57 -0
  243. package/dist/api/compiler/symbol-accessibility.js +991 -0
  244. package/dist/api/compiler/symbol.d.ts +282 -0
  245. package/dist/api/compiler/symbol.js +339 -0
  246. package/dist/api/compiler/symlinks.d.ts +32 -0
  247. package/dist/api/compiler/symlinks.js +114 -0
  248. package/dist/api/compiler/syntax-kind.d.ts +389 -0
  249. package/dist/api/compiler/syntax-kind.js +2 -0
  250. package/dist/api/compiler/timeline.d.ts +9 -0
  251. package/dist/api/compiler/timeline.js +54 -0
  252. package/dist/api/compiler/transformers/alias-references.d.ts +39 -0
  253. package/dist/api/compiler/transformers/alias-references.js +677 -0
  254. package/dist/api/compiler/transformers/async-utilities.d.ts +51 -0
  255. package/dist/api/compiler/transformers/async-utilities.js +260 -0
  256. package/dist/api/compiler/transformers/async.d.ts +53 -0
  257. package/dist/api/compiler/transformers/async.js +645 -0
  258. package/dist/api/compiler/transformers/class-fields.d.ts +206 -0
  259. package/dist/api/compiler/transformers/class-fields.js +2418 -0
  260. package/dist/api/compiler/transformers/class-utilities.d.ts +46 -0
  261. package/dist/api/compiler/transformers/class-utilities.js +261 -0
  262. package/dist/api/compiler/transformers/commonjs-module.d.ts +103 -0
  263. package/dist/api/compiler/transformers/commonjs-module.js +1180 -0
  264. package/dist/api/compiler/transformers/const-enum-inliner.d.ts +11 -0
  265. package/dist/api/compiler/transformers/const-enum-inliner.js +36 -0
  266. package/dist/api/compiler/transformers/declarations-diagnostics.d.ts +52 -0
  267. package/dist/api/compiler/transformers/declarations-diagnostics.js +539 -0
  268. package/dist/api/compiler/transformers/declarations-pseudo.d.ts +160 -0
  269. package/dist/api/compiler/transformers/declarations-pseudo.js +799 -0
  270. package/dist/api/compiler/transformers/declarations-resolver.d.ts +152 -0
  271. package/dist/api/compiler/transformers/declarations-resolver.js +35 -0
  272. package/dist/api/compiler/transformers/declarations-syntactic.d.ts +119 -0
  273. package/dist/api/compiler/transformers/declarations-syntactic.js +1582 -0
  274. package/dist/api/compiler/transformers/declarations-tracker.d.ts +46 -0
  275. package/dist/api/compiler/transformers/declarations-tracker.js +198 -0
  276. package/dist/api/compiler/transformers/declarations.d.ts +175 -0
  277. package/dist/api/compiler/transformers/declarations.js +2381 -0
  278. package/dist/api/compiler/transformers/decorator-metadata.d.ts +54 -0
  279. package/dist/api/compiler/transformers/decorator-metadata.js +554 -0
  280. package/dist/api/compiler/transformers/decorator-utilities.d.ts +38 -0
  281. package/dist/api/compiler/transformers/decorator-utilities.js +238 -0
  282. package/dist/api/compiler/transformers/destructuring.d.ts +25 -0
  283. package/dist/api/compiler/transformers/destructuring.js +626 -0
  284. package/dist/api/compiler/transformers/downlevel.d.ts +6 -0
  285. package/dist/api/compiler/transformers/downlevel.js +45 -0
  286. package/dist/api/compiler/transformers/emit-resolver.d.ts +61 -0
  287. package/dist/api/compiler/transformers/emit-resolver.js +197 -0
  288. package/dist/api/compiler/transformers/es-decorators.d.ts +118 -0
  289. package/dist/api/compiler/transformers/es-decorators.js +1901 -0
  290. package/dist/api/compiler/transformers/exponentiation.d.ts +11 -0
  291. package/dist/api/compiler/transformers/exponentiation.js +76 -0
  292. package/dist/api/compiler/transformers/external-module-info.d.ts +35 -0
  293. package/dist/api/compiler/transformers/external-module-info.js +351 -0
  294. package/dist/api/compiler/transformers/for-await.d.ts +43 -0
  295. package/dist/api/compiler/transformers/for-await.js +469 -0
  296. package/dist/api/compiler/transformers/import-elision.d.ts +16 -0
  297. package/dist/api/compiler/transformers/import-elision.js +124 -0
  298. package/dist/api/compiler/transformers/jsx-entities.d.ts +1 -0
  299. package/dist/api/compiler/transformers/jsx-entities.js +256 -0
  300. package/dist/api/compiler/transformers/jsx.d.ts +71 -0
  301. package/dist/api/compiler/transformers/jsx.js +700 -0
  302. package/dist/api/compiler/transformers/legacy-decorators.d.ts +56 -0
  303. package/dist/api/compiler/transformers/legacy-decorators.js +564 -0
  304. package/dist/api/compiler/transformers/logical-assignment.d.ts +14 -0
  305. package/dist/api/compiler/transformers/logical-assignment.js +62 -0
  306. package/dist/api/compiler/transformers/module-utilities.d.ts +9 -0
  307. package/dist/api/compiler/transformers/module-utilities.js +36 -0
  308. package/dist/api/compiler/transformers/module.d.ts +49 -0
  309. package/dist/api/compiler/transformers/module.js +296 -0
  310. package/dist/api/compiler/transformers/named-evaluation.d.ts +26 -0
  311. package/dist/api/compiler/transformers/named-evaluation.js +266 -0
  312. package/dist/api/compiler/transformers/nullish-coalescing.d.ts +9 -0
  313. package/dist/api/compiler/transformers/nullish-coalescing.js +26 -0
  314. package/dist/api/compiler/transformers/object-rest-spread.d.ts +34 -0
  315. package/dist/api/compiler/transformers/object-rest-spread.js +411 -0
  316. package/dist/api/compiler/transformers/optional-catch.d.ts +9 -0
  317. package/dist/api/compiler/transformers/optional-catch.js +20 -0
  318. package/dist/api/compiler/transformers/optional-chain.d.ts +14 -0
  319. package/dist/api/compiler/transformers/optional-chain.js +188 -0
  320. package/dist/api/compiler/transformers/reference-resolver.d.ts +129 -0
  321. package/dist/api/compiler/transformers/reference-resolver.js +1157 -0
  322. package/dist/api/compiler/transformers/runtime-syntax.d.ts +71 -0
  323. package/dist/api/compiler/transformers/runtime-syntax.js +753 -0
  324. package/dist/api/compiler/transformers/subtree-facts.d.ts +10 -0
  325. package/dist/api/compiler/transformers/subtree-facts.js +205 -0
  326. package/dist/api/compiler/transformers/syntax-facts.d.ts +52 -0
  327. package/dist/api/compiler/transformers/syntax-facts.js +258 -0
  328. package/dist/api/compiler/transformers/tagged-template.d.ts +17 -0
  329. package/dist/api/compiler/transformers/tagged-template.js +148 -0
  330. package/dist/api/compiler/transformers/transformer.d.ts +17 -0
  331. package/dist/api/compiler/transformers/transformer.js +54 -0
  332. package/dist/api/compiler/transformers/type-eraser.d.ts +21 -0
  333. package/dist/api/compiler/transformers/type-eraser.js +346 -0
  334. package/dist/api/compiler/transformers/type-serialization.d.ts +20 -0
  335. package/dist/api/compiler/transformers/type-serialization.js +347 -0
  336. package/dist/api/compiler/transformers/using.d.ts +56 -0
  337. package/dist/api/compiler/transformers/using.js +453 -0
  338. package/dist/api/compiler/transformers/utilities.d.ts +50 -0
  339. package/dist/api/compiler/transformers/utilities.js +347 -0
  340. package/dist/api/compiler/transformers/visitor-base.d.ts +6 -0
  341. package/dist/api/compiler/transformers/visitor-base.js +817 -0
  342. package/dist/api/compiler/transformers/visitor-hooks.d.ts +29 -0
  343. package/dist/api/compiler/transformers/visitor-hooks.js +189 -0
  344. package/dist/api/compiler/tsconfig.d.ts +177 -0
  345. package/dist/api/compiler/tsconfig.js +1311 -0
  346. package/dist/api/compiler/type-printer.d.ts +15 -0
  347. package/dist/api/compiler/type-printer.js +74 -0
  348. package/dist/api/compiler/types.d.ts +87 -0
  349. package/dist/api/compiler/types.js +23 -0
  350. package/dist/api/compiler/unicode-identifiers.d.ts +2 -0
  351. package/dist/api/compiler/unicode-identifiers.js +209 -0
  352. package/dist/api/compiler/unicode-properties.d.ts +8 -0
  353. package/dist/api/compiler/unicode-properties.js +531 -0
  354. package/dist/api/compiler/vfs-match.d.ts +24 -0
  355. package/dist/api/compiler/vfs-match.js +587 -0
  356. package/dist/api/library/ast.d.ts +3 -2
  357. package/dist/api/library/ast.generated.d.ts +127 -139
  358. package/dist/api/library/checker.d.ts +51 -0
  359. package/dist/api/library/checker.js +318 -0
  360. package/dist/api/library/diagnostics.d.ts +13 -0
  361. package/dist/api/library/diagnostics.js +50 -0
  362. package/dist/api/library/disk.d.ts +13 -0
  363. package/dist/api/library/disk.js +66 -0
  364. package/dist/api/library/errors.d.ts +13 -0
  365. package/dist/api/library/errors.js +24 -0
  366. package/dist/api/library/host.d.ts +24 -0
  367. package/dist/api/library/host.js +52 -0
  368. package/dist/api/library/index.d.ts +5 -1
  369. package/dist/api/library/index.js +4 -0
  370. package/dist/api/library/nodes.d.ts +51 -0
  371. package/dist/api/library/nodes.js +196 -0
  372. package/dist/api/library/options.d.ts +144 -0
  373. package/dist/api/library/options.js +308 -0
  374. package/dist/api/library/parse.d.ts +19 -0
  375. package/dist/api/library/parse.js +41 -0
  376. package/dist/api/library/program.d.ts +21 -0
  377. package/dist/api/library/program.js +234 -0
  378. package/dist/api/library/types.d.ts +14 -1
  379. package/package.json +12 -8
  380. package/src/compiler/ast-utilities.ts +548 -0
  381. package/src/compiler/ast.ts +12870 -0
  382. package/src/compiler/astnav.ts +799 -0
  383. package/src/compiler/binder-utilities.ts +1392 -0
  384. package/src/compiler/binder.ts +2707 -0
  385. package/src/compiler/build-info.ts +1197 -0
  386. package/src/compiler/character-codes.ts +323 -0
  387. package/src/compiler/checker-calls.ts +2155 -0
  388. package/src/compiler/checker-classes.ts +706 -0
  389. package/src/compiler/checker-contextual.ts +1457 -0
  390. package/src/compiler/checker-declaration-order.ts +438 -0
  391. package/src/compiler/checker-declarations.ts +1201 -0
  392. package/src/compiler/checker-declared-types.ts +919 -0
  393. package/src/compiler/checker-decorators.ts +694 -0
  394. package/src/compiler/checker-deprecation.ts +355 -0
  395. package/src/compiler/checker-destructuring.ts +805 -0
  396. package/src/compiler/checker-elaboration.ts +477 -0
  397. package/src/compiler/checker-emit-helpers.ts +224 -0
  398. package/src/compiler/checker-emit-resolver.ts +769 -0
  399. package/src/compiler/checker-evaluator.ts +243 -0
  400. package/src/compiler/checker-expressions.ts +1831 -0
  401. package/src/compiler/checker-features.ts +361 -0
  402. package/src/compiler/checker-flow.ts +394 -0
  403. package/src/compiler/checker-functions.ts +1296 -0
  404. package/src/compiler/checker-generated-code.ts +227 -0
  405. package/src/compiler/checker-globals.ts +52 -0
  406. package/src/compiler/checker-grammar.ts +3596 -0
  407. package/src/compiler/checker-heritage.ts +1240 -0
  408. package/src/compiler/checker-inference.ts +2584 -0
  409. package/src/compiler/checker-iteration.ts +1206 -0
  410. package/src/compiler/checker-javascript.ts +502 -0
  411. package/src/compiler/checker-jsdoc.ts +360 -0
  412. package/src/compiler/checker-jsx.ts +1928 -0
  413. package/src/compiler/checker-literals.ts +61 -0
  414. package/src/compiler/checker-members.ts +2480 -0
  415. package/src/compiler/checker-modules.ts +2896 -0
  416. package/src/compiler/checker-narrowing.ts +3230 -0
  417. package/src/compiler/checker-object-literals.ts +591 -0
  418. package/src/compiler/checker-operators.ts +1422 -0
  419. package/src/compiler/checker-overloads.ts +328 -0
  420. package/src/compiler/checker-property-access.ts +906 -0
  421. package/src/compiler/checker-services.ts +1149 -0
  422. package/src/compiler/checker-signatures.ts +1032 -0
  423. package/src/compiler/checker-source-file.ts +732 -0
  424. package/src/compiler/checker-statements.ts +292 -0
  425. package/src/compiler/checker-super.ts +261 -0
  426. package/src/compiler/checker-symbol-types.ts +1187 -0
  427. package/src/compiler/checker-symbols.ts +2157 -0
  428. package/src/compiler/checker-type-factory.ts +2616 -0
  429. package/src/compiler/checker-type-nodes.ts +1033 -0
  430. package/src/compiler/checker-type-operators.ts +2510 -0
  431. package/src/compiler/checker-types.ts +2520 -0
  432. package/src/compiler/checker-unused.ts +642 -0
  433. package/src/compiler/checker-utilities.ts +161 -0
  434. package/src/compiler/checker.ts +1138 -0
  435. package/src/compiler/command-line.ts +436 -0
  436. package/src/compiler/compile-program.ts +439 -0
  437. package/src/compiler/decoder.ts +1209 -0
  438. package/src/compiler/diagnostic-locales.ts +86 -0
  439. package/src/compiler/diagnostic-messages.ts +2349 -0
  440. package/src/compiler/diagnostics.ts +858 -0
  441. package/src/compiler/emitter.ts +434 -0
  442. package/src/compiler/encoder.ts +1945 -0
  443. package/src/compiler/file-include.ts +741 -0
  444. package/src/compiler/file-loader.ts +1597 -0
  445. package/src/compiler/file-system.ts +143 -0
  446. package/src/compiler/flow.ts +89 -0
  447. package/src/compiler/help.ts +473 -0
  448. package/src/compiler/incremental.ts +2818 -0
  449. package/src/compiler/init.ts +141 -0
  450. package/src/compiler/instantiation.ts +938 -0
  451. package/src/compiler/jsdoc.ts +1386 -0
  452. package/src/compiler/link-tables.ts +343 -0
  453. package/src/compiler/locale-data.ts +203 -0
  454. package/src/compiler/locale.ts +307 -0
  455. package/src/compiler/locales/cs-CZ.ts +5 -0
  456. package/src/compiler/locales/de-DE.ts +5 -0
  457. package/src/compiler/locales/es-ES.ts +5 -0
  458. package/src/compiler/locales/fr-FR.ts +5 -0
  459. package/src/compiler/locales/it-IT.ts +5 -0
  460. package/src/compiler/locales/ja-JP.ts +5 -0
  461. package/src/compiler/locales/ko-KR.ts +5 -0
  462. package/src/compiler/locales/pl-PL.ts +5 -0
  463. package/src/compiler/locales/pt-BR.ts +5 -0
  464. package/src/compiler/locales/ru-RU.ts +5 -0
  465. package/src/compiler/locales/tr-TR.ts +5 -0
  466. package/src/compiler/locales/zh-CN.ts +5 -0
  467. package/src/compiler/locales/zh-TW.ts +5 -0
  468. package/src/compiler/module-resolution-types.ts +243 -0
  469. package/src/compiler/module-resolution.ts +2072 -0
  470. package/src/compiler/module-specifiers.ts +1491 -0
  471. package/src/compiler/name-resolver.ts +646 -0
  472. package/src/compiler/node-builder-names.ts +1071 -0
  473. package/src/compiler/node-builder-pseudo.ts +892 -0
  474. package/src/compiler/node-builder-reuse.ts +764 -0
  475. package/src/compiler/node-builder.ts +3433 -0
  476. package/src/compiler/option-declarations.ts +1560 -0
  477. package/src/compiler/options.ts +1576 -0
  478. package/src/compiler/output-paths.ts +334 -0
  479. package/src/compiler/package-json.ts +1083 -0
  480. package/src/compiler/parallel-check.ts +1954 -0
  481. package/src/compiler/parallel-parse.ts +595 -0
  482. package/src/compiler/parse-thread.ts +136 -0
  483. package/src/compiler/parser.ts +7766 -0
  484. package/src/compiler/path.ts +717 -0
  485. package/src/compiler/printer/async-helpers.ts +183 -0
  486. package/src/compiler/printer/auto-generate.ts +27 -0
  487. package/src/compiler/printer/decorator-helpers.ts +218 -0
  488. package/src/compiler/printer/emit-context.ts +684 -0
  489. package/src/compiler/printer/emit-flags.ts +64 -0
  490. package/src/compiler/printer/factory-base.ts +2577 -0
  491. package/src/compiler/printer/factory.ts +764 -0
  492. package/src/compiler/printer/helpers.ts +291 -0
  493. package/src/compiler/printer/name-generator.ts +372 -0
  494. package/src/compiler/printer/printer.ts +5072 -0
  495. package/src/compiler/printer/text-writer.ts +183 -0
  496. package/src/compiler/printer/utilities.ts +884 -0
  497. package/src/compiler/program-checker.ts +594 -0
  498. package/src/compiler/program-utilities.ts +435 -0
  499. package/src/compiler/program.ts +1426 -0
  500. package/src/compiler/pseudo-bigint.ts +62 -0
  501. package/src/compiler/regexp-checker.ts +1142 -0
  502. package/src/compiler/relations.ts +5149 -0
  503. package/src/compiler/reparser.ts +1566 -0
  504. package/src/compiler/scanner.ts +2951 -0
  505. package/src/compiler/show-config.ts +239 -0
  506. package/src/compiler/side-state.ts +125 -0
  507. package/src/compiler/sourcemap.ts +366 -0
  508. package/src/compiler/spelling.ts +122 -0
  509. package/src/compiler/symbol-accessibility.ts +1166 -0
  510. package/src/compiler/symbol.ts +557 -0
  511. package/src/compiler/symlinks.ts +137 -0
  512. package/src/compiler/syntax-kind.ts +391 -0
  513. package/src/compiler/thread-entry.ts +191 -0
  514. package/src/compiler/timeline.ts +53 -0
  515. package/src/compiler/transformers/alias-references.ts +757 -0
  516. package/src/compiler/transformers/async-utilities.ts +335 -0
  517. package/src/compiler/transformers/async.ts +838 -0
  518. package/src/compiler/transformers/class-fields.ts +2967 -0
  519. package/src/compiler/transformers/class-utilities.ts +324 -0
  520. package/src/compiler/transformers/commonjs-module.ts +1621 -0
  521. package/src/compiler/transformers/const-enum-inliner.ts +50 -0
  522. package/src/compiler/transformers/declarations-diagnostics.ts +833 -0
  523. package/src/compiler/transformers/declarations-pseudo.ts +969 -0
  524. package/src/compiler/transformers/declarations-resolver.ts +249 -0
  525. package/src/compiler/transformers/declarations-syntactic.ts +1867 -0
  526. package/src/compiler/transformers/declarations-tracker.ts +269 -0
  527. package/src/compiler/transformers/declarations.ts +3120 -0
  528. package/src/compiler/transformers/decorator-metadata.ts +697 -0
  529. package/src/compiler/transformers/decorator-utilities.ts +283 -0
  530. package/src/compiler/transformers/destructuring.ts +708 -0
  531. package/src/compiler/transformers/downlevel.ts +50 -0
  532. package/src/compiler/transformers/emit-resolver.ts +258 -0
  533. package/src/compiler/transformers/es-decorators.ts +2682 -0
  534. package/src/compiler/transformers/exponentiation.ts +80 -0
  535. package/src/compiler/transformers/external-module-info.ts +412 -0
  536. package/src/compiler/transformers/for-await.ts +687 -0
  537. package/src/compiler/transformers/import-elision.ts +152 -0
  538. package/src/compiler/transformers/jsx-entities.ts +256 -0
  539. package/src/compiler/transformers/jsx.ts +824 -0
  540. package/src/compiler/transformers/legacy-decorators.ts +726 -0
  541. package/src/compiler/transformers/logical-assignment.ts +75 -0
  542. package/src/compiler/transformers/module-utilities.ts +42 -0
  543. package/src/compiler/transformers/module.ts +474 -0
  544. package/src/compiler/transformers/named-evaluation.ts +389 -0
  545. package/src/compiler/transformers/nullish-coalescing.ts +35 -0
  546. package/src/compiler/transformers/object-rest-spread.ts +577 -0
  547. package/src/compiler/transformers/optional-catch.ts +29 -0
  548. package/src/compiler/transformers/optional-chain.ts +246 -0
  549. package/src/compiler/transformers/reference-resolver.ts +1213 -0
  550. package/src/compiler/transformers/runtime-syntax.ts +942 -0
  551. package/src/compiler/transformers/subtree-facts.ts +253 -0
  552. package/src/compiler/transformers/syntax-facts.ts +358 -0
  553. package/src/compiler/transformers/tagged-template.ts +167 -0
  554. package/src/compiler/transformers/transformer.ts +56 -0
  555. package/src/compiler/transformers/type-eraser.ts +520 -0
  556. package/src/compiler/transformers/type-serialization.ts +374 -0
  557. package/src/compiler/transformers/using.ts +613 -0
  558. package/src/compiler/transformers/utilities.ts +419 -0
  559. package/src/compiler/transformers/visitor-base.ts +1601 -0
  560. package/src/compiler/transformers/visitor-hooks.ts +252 -0
  561. package/src/compiler/tsc-build.ts +1422 -0
  562. package/src/compiler/tsc-cli.ts +669 -0
  563. package/src/compiler/tsc-compile.ts +446 -0
  564. package/src/compiler/tsc-watch.ts +922 -0
  565. package/src/compiler/tsconfig.ts +1574 -0
  566. package/src/compiler/type-printer.ts +110 -0
  567. package/src/compiler/types.ts +115 -0
  568. package/src/compiler/unicode-identifiers.ts +212 -0
  569. package/src/compiler/unicode-properties.ts +537 -0
  570. package/src/compiler/vfs-match.ts +597 -0
  571. package/src/compiler/xxh3.ts +650 -0
  572. package/src/library/ast.generated.ts +141 -167
  573. package/src/library/ast.ts +4 -1
  574. package/src/library/checker.ts +384 -0
  575. package/src/library/diagnostics.ts +72 -0
  576. package/src/library/disk.ts +73 -0
  577. package/src/library/errors.ts +26 -0
  578. package/src/library/host.ts +63 -0
  579. package/src/library/index.ts +21 -0
  580. package/src/library/nodes.ts +232 -0
  581. package/src/library/options.ts +449 -0
  582. package/src/library/parse.ts +63 -0
  583. package/src/library/program.ts +293 -0
  584. package/src/library/types.ts +14 -1
@@ -0,0 +1,2520 @@
1
+ // The checker's type model: types, signatures, index infos, mappers and the links the checker
2
+ // caches per symbol and node. Flag values match tsgo, because union ordering depends on them.
3
+ import type { ProgramLifetime } from '@scriptc/types';
4
+ import type { Node } from './ast.js';
5
+ import { getSymbolId, type Symbol, type SymbolTable } from './symbol.js';
6
+
7
+ export const enum TypeFlags {
8
+ None = 0,
9
+ Any = 1 << 0,
10
+ Unknown = 1 << 1,
11
+ Undefined = 1 << 2,
12
+ Null = 1 << 3,
13
+ Void = 1 << 4,
14
+ String = 1 << 5,
15
+ Number = 1 << 6,
16
+ BigInt = 1 << 7,
17
+ Boolean = 1 << 8,
18
+ ESSymbol = 1 << 9,
19
+ StringLiteral = 1 << 10,
20
+ NumberLiteral = 1 << 11,
21
+ BigIntLiteral = 1 << 12,
22
+ BooleanLiteral = 1 << 13,
23
+ UniqueESSymbol = 1 << 14,
24
+ /** Always combined with StringLiteral, NumberLiteral, or Union. */
25
+ EnumLiteral = 1 << 15,
26
+ /** A numeric enum member with a computed value. */
27
+ Enum = 1 << 16,
28
+ NonPrimitive = 1 << 17,
29
+ Never = 1 << 18,
30
+ TypeParameter = 1 << 19,
31
+ Object = 1 << 20,
32
+ Index = 1 << 21,
33
+ TemplateLiteral = 1 << 22,
34
+ StringMapping = 1 << 23,
35
+ Substitution = 1 << 24,
36
+ IndexedAccess = 1 << 25,
37
+ Conditional = 1 << 26,
38
+ Union = 1 << 27,
39
+ Intersection = 1 << 28,
40
+ Reserved1 = 1 << 29,
41
+ Reserved2 = 1 << 30,
42
+
43
+ AnyOrUnknown = Any | Unknown,
44
+ Nullable = Undefined | Null,
45
+ Literal = StringLiteral | NumberLiteral | BigIntLiteral | BooleanLiteral,
46
+ Unit = Enum | Literal | UniqueESSymbol | Nullable,
47
+ Freshable = Enum | Literal,
48
+ StringOrNumberLiteral = StringLiteral | NumberLiteral,
49
+ StringOrNumberLiteralOrUnique = StringLiteral | NumberLiteral | UniqueESSymbol,
50
+ DefinitelyFalsy = StringLiteral | NumberLiteral | BigIntLiteral | BooleanLiteral | Void | Undefined | Null,
51
+ PossiblyFalsy = DefinitelyFalsy | String | Number | BigInt | Boolean,
52
+ Intrinsic = Any | Unknown | String | Number | BigInt | ESSymbol | Void | Undefined | Null | Never | NonPrimitive,
53
+ StringLike = String | StringLiteral | TemplateLiteral | StringMapping,
54
+ NumberLike = Number | NumberLiteral | Enum,
55
+ BigIntLike = BigInt | BigIntLiteral,
56
+ BooleanLike = Boolean | BooleanLiteral,
57
+ EnumLike = Enum | EnumLiteral,
58
+ ESSymbolLike = ESSymbol | UniqueESSymbol,
59
+ VoidLike = Void | Undefined,
60
+ Primitive = StringLike | NumberLike | BigIntLike | BooleanLike | EnumLike | ESSymbolLike | VoidLike | Null,
61
+ DefinitelyNonNullable = StringLike |
62
+ NumberLike |
63
+ BigIntLike |
64
+ BooleanLike |
65
+ EnumLike |
66
+ ESSymbolLike |
67
+ Object |
68
+ NonPrimitive,
69
+ DisjointDomains = NonPrimitive | StringLike | NumberLike | BigIntLike | BooleanLike | ESSymbolLike | VoidLike | Null,
70
+ UnionOrIntersection = Union | Intersection,
71
+ StructuredType = Object | Union | Intersection,
72
+ TypeVariable = TypeParameter | IndexedAccess,
73
+ InstantiableNonPrimitive = TypeVariable | Conditional | Substitution,
74
+ InstantiablePrimitive = Index | TemplateLiteral | StringMapping,
75
+ Instantiable = InstantiableNonPrimitive | InstantiablePrimitive,
76
+ StructuredOrInstantiable = StructuredType | Instantiable,
77
+ ObjectFlagsType = Any | Nullable | Never | Object | Union | Intersection,
78
+ Simplifiable = IndexedAccess | Conditional | Index,
79
+ Singleton = Any |
80
+ Unknown |
81
+ String |
82
+ Number |
83
+ Boolean |
84
+ BigInt |
85
+ ESSymbol |
86
+ Void |
87
+ Undefined |
88
+ Null |
89
+ Never |
90
+ NonPrimitive,
91
+ /** Types where narrowing actually narrows. */
92
+ Narrowable = Any |
93
+ Unknown |
94
+ StructuredOrInstantiable |
95
+ StringLike |
96
+ NumberLike |
97
+ BigIntLike |
98
+ BooleanLike |
99
+ ESSymbol |
100
+ UniqueESSymbol |
101
+ NonPrimitive,
102
+ /** Aggregated during union and intersection construction. */
103
+ IncludesMask = Any |
104
+ Unknown |
105
+ Primitive |
106
+ Never |
107
+ Object |
108
+ Union |
109
+ Intersection |
110
+ NonPrimitive |
111
+ TemplateLiteral |
112
+ StringMapping,
113
+ // Reused during union and intersection construction.
114
+ IncludesMissingType = TypeParameter,
115
+ IncludesNonWideningType = Index,
116
+ IncludesWildcard = IndexedAccess,
117
+ IncludesEmptyObject = Conditional,
118
+ IncludesInstantiable = Substitution,
119
+ IncludesConstrainedTypeVariable = Reserved1,
120
+ IncludesError = Reserved2,
121
+ NotPrimitiveUnion = Any | Unknown | Void | Never | Object | Intersection | IncludesInstantiable,
122
+ }
123
+
124
+ /** The sign bit, which TypeScript enums can't hold as a positive flag. */
125
+ export const typeFlagsReserved3 = -2147483648;
126
+
127
+ export const enum ObjectFlags {
128
+ None = 0,
129
+ Class = 1 << 0,
130
+ Interface = 1 << 1,
131
+ /** A generic type reference. */
132
+ Reference = 1 << 2,
133
+ Tuple = 1 << 3,
134
+ Anonymous = 1 << 4,
135
+ Mapped = 1 << 5,
136
+ /** An instantiated anonymous or mapped type. */
137
+ Instantiated = 1 << 6,
138
+ ObjectLiteral = 1 << 7,
139
+ EvolvingArray = 1 << 8,
140
+ ObjectLiteralPatternWithComputedProperties = 1 << 9,
141
+ ReverseMapped = 1 << 10,
142
+ JsxAttributes = 1 << 11,
143
+ /** Declared in JS: reads and writes of missing members are allowed. */
144
+ JSLiteral = 1 << 12,
145
+ FreshLiteral = 1 << 13,
146
+ ArrayLiteral = 1 << 14,
147
+ PrimitiveUnion = 1 << 15,
148
+ ContainsWideningType = 1 << 16,
149
+ ContainsObjectOrArrayLiteral = 1 << 17,
150
+ /** Is or contains anyFunctionType or silentNeverType. */
151
+ NonInferrableType = 1 << 18,
152
+ CouldContainTypeVariablesComputed = 1 << 19,
153
+ CouldContainTypeVariables = 1 << 20,
154
+ MembersResolved = 1 << 21,
155
+
156
+ ClassOrInterface = Class | Interface,
157
+ RequiresWidening = ContainsWideningType | ContainsObjectOrArrayLiteral,
158
+ PropagatingFlags = ContainsWideningType | ContainsObjectOrArrayLiteral | NonInferrableType,
159
+ InstantiatedMapped = Mapped | Instantiated,
160
+
161
+ // Object types only.
162
+ ContainsSpread = 1 << 22,
163
+ ObjectRestType = 1 << 23,
164
+ InstantiationExpressionType = 1 << 24,
165
+ SingleSignatureType = 1 << 25,
166
+ IsClassInstanceClone = 1 << 26,
167
+ // Type references only.
168
+ IdenticalBaseTypeCalculated = 1 << 27,
169
+ IdenticalBaseTypeExists = 1 << 28,
170
+ UnresolvedMembers = 1 << 29,
171
+ FromTypeNode = 1 << 30,
172
+ /**
173
+ * The type keeps the state that is computed lazily in the checker's side tables instead of its
174
+ * own fields, which stay unset (`sideOf`). Every type with `TSC_TS_SIDE_STATE=1`.
175
+ */
176
+ SideState = 1 << 31,
177
+ // Unions, intersections and substitutions only.
178
+ IsGenericTypeComputed = 1 << 22,
179
+ IsGenericObjectType = 1 << 23,
180
+ IsGenericIndexType = 1 << 24,
181
+ IsGenericType = IsGenericObjectType | IsGenericIndexType,
182
+ // Unions only.
183
+ ContainsIntersections = 1 << 25,
184
+ IsUnknownLikeUnionComputed = 1 << 26,
185
+ IsUnknownLikeUnion = 1 << 27,
186
+ // Intersections only.
187
+ IsNeverIntersectionComputed = 1 << 25,
188
+ IsNeverIntersection = 1 << 26,
189
+ IsConstrainedTypeVariable = 1 << 27,
190
+
191
+ ObjectTypeKindMask = ClassOrInterface |
192
+ Reference |
193
+ Tuple |
194
+ Anonymous |
195
+ Mapped |
196
+ ReverseMapped |
197
+ EvolvingArray |
198
+ InstantiationExpressionType |
199
+ SingleSignatureType,
200
+ }
201
+
202
+ export const enum ElementFlags {
203
+ None = 0,
204
+ Required = 1 << 0,
205
+ Optional = 1 << 1,
206
+ Rest = 1 << 2,
207
+ Variadic = 1 << 3,
208
+ Fixed = Required | Optional,
209
+ Variable = Rest | Variadic,
210
+ NonRequired = Optional | Rest | Variadic,
211
+ NonRest = Required | Optional | Variadic,
212
+ }
213
+
214
+ export const enum SignatureFlags {
215
+ None = 0,
216
+ HasRestParameter = 1 << 0,
217
+ HasLiteralTypes = 1 << 1,
218
+ Construct = 1 << 2,
219
+ Abstract = 1 << 3,
220
+ IsInnerCallChain = 1 << 4,
221
+ IsOuterCallChain = 1 << 5,
222
+ IsUntypedSignatureInJSFile = 1 << 6,
223
+ IsNonInferrable = 1 << 7,
224
+ IsSignatureCandidateForOverloadFailure = 1 << 8,
225
+ /** The signature keeps its lazily computed state in the checker's side tables (`signatureSideOf`). */
226
+ SideState = 1 << 9,
227
+ PropagatingFlags = HasRestParameter |
228
+ HasLiteralTypes |
229
+ Construct |
230
+ Abstract |
231
+ IsUntypedSignatureInJSFile |
232
+ IsSignatureCandidateForOverloadFailure,
233
+ CallChainFlags = IsInnerCallChain | IsOuterCallChain,
234
+ }
235
+
236
+ export const enum SignatureKind {
237
+ Call = 0,
238
+ Construct = 1,
239
+ }
240
+
241
+ export const enum IndexFlags {
242
+ None = 0,
243
+ StringsOnly = 1 << 0,
244
+ NoIndexSignatures = 1 << 1,
245
+ NoReducibleCheck = 1 << 2,
246
+ }
247
+
248
+ export const enum AccessFlags {
249
+ None = 0,
250
+ IncludeUndefined = 1 << 0,
251
+ NoIndexSignatures = 1 << 1,
252
+ Writing = 1 << 2,
253
+ CacheSymbol = 1 << 3,
254
+ AllowMissing = 1 << 4,
255
+ ExpressionPosition = 1 << 5,
256
+ ReportDeprecated = 1 << 6,
257
+ SuppressNoImplicitAnyError = 1 << 7,
258
+ Contextual = 1 << 8,
259
+ Persistent = IncludeUndefined,
260
+ }
261
+
262
+ export const enum VarianceFlags {
263
+ Invariant = 0,
264
+ Covariant = 1 << 0,
265
+ Contravariant = 1 << 1,
266
+ Bivariant = Covariant | Contravariant,
267
+ /** An unwitnessed type parameter. */
268
+ Independent = 1 << 2,
269
+ VarianceMask = Invariant | Covariant | Contravariant | Independent,
270
+ /** Relies on structural comparisons not reflected in generic relationships. */
271
+ Unmeasurable = 1 << 3,
272
+ /** May produce false negatives, never false positives. */
273
+ Unreliable = 1 << 4,
274
+ AllowsStructuralFallback = Unmeasurable | Unreliable,
275
+ }
276
+
277
+ /** `x & y` picks the lesser in False < Unknown < Maybe < True; `x | y` the greater. */
278
+ export const enum Ternary {
279
+ False = 0,
280
+ Unknown = 1,
281
+ Maybe = 3,
282
+ True = -1,
283
+ }
284
+
285
+ export const enum TypePredicateKind {
286
+ This = 0,
287
+ Identifier = 1,
288
+ AssertsThis = 2,
289
+ AssertsIdentifier = 3,
290
+ }
291
+
292
+ export const enum NodeCheckFlags {
293
+ None = 0,
294
+ TypeChecked = 1 << 0,
295
+ UnusedChecked = 1 << 1,
296
+ ContextChecked = 1 << 6,
297
+ EnumValuesComputed = 1 << 10,
298
+ AssignmentsMarked = 1 << 17,
299
+ ContainsClassWithPrivateIdentifiers = 1 << 20,
300
+ ContainsSuperPropertyInStaticInitializer = 1 << 21,
301
+ InCheckIdentifier = 1 << 22,
302
+ InitializerIsUndefined = 1 << 24,
303
+ InitializerIsUndefinedComputed = 1 << 25,
304
+ }
305
+
306
+ export const enum CheckMode {
307
+ Normal = 0,
308
+ Contextual = 1 << 0,
309
+ Inferential = 1 << 1,
310
+ SkipContextSensitive = 1 << 2,
311
+ SkipGenericFunctions = 1 << 3,
312
+ IsForSignatureHelp = 1 << 4,
313
+ RestBindingElement = 1 << 5,
314
+ TypeOnly = 1 << 6,
315
+ ForceTuple = 1 << 7,
316
+ }
317
+
318
+ export const enum TypeFormatFlags {
319
+ None = 0,
320
+ NoTruncation = 1 << 0,
321
+ WriteArrayAsGenericType = 1 << 1,
322
+ UseStructuralFallback = 1 << 3,
323
+ WriteTypeArgumentsOfSignature = 1 << 5,
324
+ UseFullyQualifiedType = 1 << 6,
325
+ SuppressAnyReturnType = 1 << 8,
326
+ MultilineObjectLiterals = 1 << 10,
327
+ WriteClassExpressionAsTypeLiteral = 1 << 11,
328
+ UseTypeOfFunction = 1 << 12,
329
+ OmitParameterModifiers = 1 << 13,
330
+ UseAliasDefinedOutsideCurrentScope = 1 << 14,
331
+ AllowUniqueESSymbolType = 1 << 20,
332
+ AddUndefined = 1 << 17,
333
+ WriteArrowStyleSignature = 1 << 18,
334
+ InArrayType = 1 << 19,
335
+ InElementType = 1 << 21,
336
+ InFirstTypeArgument = 1 << 22,
337
+ InTypeAlias = 1 << 23,
338
+ OmitThisParameter = 1 << 25,
339
+ WriteCallStyleSignature = 1 << 27,
340
+ UseSingleQuotesForStringLiteralType = 1 << 28,
341
+ NoTypeReduction = 1 << 29,
342
+ }
343
+
344
+ /** Kinds of the checker's `cachedTypesById` entries, which are keyed by kind and type id (tsgo's CachedTypeKey). */
345
+ export const enum CachedTypeKind {
346
+ LiteralUnionBaseType,
347
+ IndexType,
348
+ StringIndexType,
349
+ EquivalentBaseType,
350
+ Apparent,
351
+ Awaited,
352
+ EvolvingArray,
353
+ ArrayLiteral,
354
+ PermissiveInstantiation,
355
+ RestrictiveInstantiation,
356
+ RestrictiveTypeParameter,
357
+ IndexedAccessForReading,
358
+ IndexedAccessForWriting,
359
+ Widened,
360
+ RegularObjectLiteral,
361
+ PromisedTypeOfPromise,
362
+ Optional,
363
+ OptionalProperty,
364
+ }
365
+
366
+ export function cachedTypeKey(kind: CachedTypeKind, id: number): number {
367
+ return id * 32 + kind;
368
+ }
369
+
370
+ /** Type ids below this bound pack in pairs into a `cachedTypesByPair` key. */
371
+ const CachedTypePairIdLimit = 1 << 24;
372
+
373
+ /** The `cachedTypesByPair` key of two type ids and four bits, or -1 when an id is too large to pack. */
374
+ export function cachedTypePairKey(a: number, b: number, bits: number): number {
375
+ return a < CachedTypePairIdLimit && b < CachedTypePairIdLimit ? (a * CachedTypePairIdLimit + b) * 16 + bits : -1;
376
+ }
377
+
378
+ // ---- Types
379
+
380
+ /** An alias symbol and its type arguments, for types written through a type alias. */
381
+ export class TypeAlias {
382
+ readonly symbol: Symbol;
383
+ readonly typeArguments: Type[];
384
+
385
+ constructor(symbol: Symbol, typeArguments: Type[]) {
386
+ this.symbol = symbol;
387
+ this.typeArguments = typeArguments;
388
+ }
389
+ }
390
+
391
+ function sameTypeListParts(a: readonly Type[], b: readonly Type[]): boolean {
392
+ if (a.length !== b.length) return false;
393
+ for (let i = 0; i < a.length; i++) if (a[i]! !== b[i]!) return false;
394
+ return true;
395
+ }
396
+
397
+ function sameAliasParts(a: TypeAlias | undefined, b: TypeAlias | undefined): boolean {
398
+ if (a === undefined || b === undefined) return a === b;
399
+ return a.symbol === b.symbol && sameTypeListParts(a.typeArguments, b.typeArguments);
400
+ }
401
+
402
+ /**
403
+ * Values keyed by a list of types, an optional alias and a small tag: the keys `typeListKey(types) +
404
+ * aliasKey(alias)` plus a suffix spelled, without building them. A lookup takes a number hashing the
405
+ * parts (`typeListHash`); entries keep their parts, so a match is exact and keys sharing a hash chain.
406
+ * Like tsgo's hashed type list keys. A list must not change after it keys an entry.
407
+ *
408
+ * Entries are numbered in the order they are added: `heads` maps a hash to its first entry, and the
409
+ * lists and values of the entries are kept in arrays by number. Aliases, tags and the chains of
410
+ * entries that share a hash get arrays once an entry needs them.
411
+ */
412
+ export class TypeListCache<V> {
413
+ private heads: Map<number, number>;
414
+ private lists: (readonly Type[])[];
415
+ private values: V[];
416
+ private aliases: (TypeAlias | undefined)[] | undefined;
417
+ private tags: number[] | undefined;
418
+ /** The next entry with the same hash, or -1. */
419
+ private nexts: number[] | undefined;
420
+
421
+ constructor() {
422
+ this.heads = new Map<number, number>();
423
+ this.lists = [];
424
+ this.values = [];
425
+ this.aliases = undefined;
426
+ this.tags = undefined;
427
+ this.nexts = undefined;
428
+ }
429
+
430
+ get(hash: number, types: readonly Type[], alias: TypeAlias | undefined, tag: number): V | undefined {
431
+ const entry = this.find(hash, types, alias, tag);
432
+ return entry >= 0 ? this.values[entry] : undefined;
433
+ }
434
+
435
+ set(hash: number, types: readonly Type[], alias: TypeAlias | undefined, tag: number, value: V): void {
436
+ const head = this.heads.get(hash);
437
+ if (head !== undefined) {
438
+ const entry = this.findFrom(head, types, alias, tag);
439
+ if (entry >= 0) {
440
+ this.values[entry] = value;
441
+ return;
442
+ }
443
+ }
444
+ const entry = this.lists.length;
445
+ this.lists.push(types);
446
+ this.values.push(value);
447
+ const aliases = this.aliases;
448
+ if (aliases !== undefined) aliases.push(alias);
449
+ else if (alias !== undefined) {
450
+ const created: (TypeAlias | undefined)[] = [];
451
+ for (let i = 0; i < entry; i++) created.push(undefined);
452
+ created.push(alias);
453
+ this.aliases = created;
454
+ }
455
+ const tags = this.tags;
456
+ if (tags !== undefined) tags.push(tag);
457
+ else if (tag !== 0) {
458
+ const created: number[] = [];
459
+ for (let i = 0; i < entry; i++) created.push(0);
460
+ created.push(tag);
461
+ this.tags = created;
462
+ }
463
+ let nexts = this.nexts;
464
+ if (nexts !== undefined) nexts.push(-1);
465
+ if (head === undefined) {
466
+ this.heads.set(hash, entry);
467
+ return;
468
+ }
469
+ // A second entry with this hash: chain it after the first.
470
+ if (nexts === undefined) {
471
+ nexts = [];
472
+ for (let i = 0; i <= entry; i++) nexts.push(-1);
473
+ this.nexts = nexts;
474
+ }
475
+ nexts[entry] = nexts[head]!;
476
+ nexts[head] = entry;
477
+ }
478
+
479
+ clear(): void {
480
+ this.heads = new Map<number, number>();
481
+ this.lists = [];
482
+ this.values = [];
483
+ this.aliases = undefined;
484
+ this.tags = undefined;
485
+ this.nexts = undefined;
486
+ }
487
+
488
+ /** The number of the entry with these parts, or -1. */
489
+ private find(hash: number, types: readonly Type[], alias: TypeAlias | undefined, tag: number): number {
490
+ const head = this.heads.get(hash);
491
+ return head !== undefined ? this.findFrom(head, types, alias, tag) : -1;
492
+ }
493
+
494
+ private findFrom(head: number, types: readonly Type[], alias: TypeAlias | undefined, tag: number): number {
495
+ const tags = this.tags;
496
+ const aliases = this.aliases;
497
+ const nexts = this.nexts;
498
+ for (let entry = head; entry >= 0; entry = nexts !== undefined ? nexts[entry]! : -1)
499
+ if (
500
+ (tags !== undefined ? tags[entry]! : 0) === tag &&
501
+ sameTypeListParts(this.lists[entry]!, types) &&
502
+ sameAliasParts(aliases !== undefined ? aliases[entry] : undefined, alias)
503
+ )
504
+ return entry;
505
+ return -1;
506
+ }
507
+ }
508
+
509
+ /**
510
+ * One list for each sequence of types that a checker keeps (`Checker.typeLists`): references and
511
+ * instantiation caches hold the same type arguments in many places, mostly lists of one or two types,
512
+ * and share one list for them. A list must not change once it is in the table.
513
+ */
514
+ export class TypeListTable {
515
+ private readonly heads = new Map<number, number>();
516
+ private readonly lists: Type[][] = [];
517
+ /** The next list with the same hash, or -1, once two lists share one. */
518
+ private nexts: number[] | undefined = undefined;
519
+
520
+ /**
521
+ * The list in the table with the types of `types`, in order, or `types` itself, which joins the
522
+ * table. `hash` is `typeListHash(types, undefined, 0)`.
523
+ */
524
+ intern(hash: number, types: Type[]): Type[] {
525
+ if (types.length === 0) return types;
526
+ const head = this.heads.get(hash);
527
+ const nexts = this.nexts;
528
+ if (head !== undefined)
529
+ for (let entry = head; entry >= 0; entry = nexts !== undefined ? nexts[entry]! : -1) {
530
+ const list = this.lists[entry]!;
531
+ if (sameTypeListParts(list, types)) return list;
532
+ }
533
+ const entry = this.lists.length;
534
+ this.lists.push(types);
535
+ if (nexts !== undefined) nexts.push(-1);
536
+ if (head === undefined) {
537
+ this.heads.set(hash, entry);
538
+ return types;
539
+ }
540
+ // A second list with this hash: chain it after the first.
541
+ let chain = nexts;
542
+ if (chain === undefined) {
543
+ chain = [];
544
+ for (let i = 0; i <= entry; i++) chain.push(-1);
545
+ this.nexts = chain;
546
+ }
547
+ chain[entry] = chain[head]!;
548
+ chain[head] = entry;
549
+ return types;
550
+ }
551
+ }
552
+
553
+ /**
554
+ * The references to a generic class, interface or tuple type, by the hash of their type arguments
555
+ * (`createTypeReference`). A reference is its own entry: a lookup compares its type arguments. A
556
+ * reference whose hash another reference has is kept in `collisions`.
557
+ */
558
+ export class ReferenceCache {
559
+ private readonly references = new Map<number, TypeReference>();
560
+ private collisions: TypeListCache<TypeReference> | undefined = undefined;
561
+
562
+ get(hash: number, typeArguments: readonly Type[]): TypeReference | undefined {
563
+ const reference = this.references.get(hash);
564
+ if (reference === undefined) return undefined;
565
+ if (sameTypeListParts(reference.resolvedTypeArguments!, typeArguments)) return reference;
566
+ const collisions = this.collisions;
567
+ return collisions !== undefined ? collisions.get(hash, typeArguments, undefined, 0) : undefined;
568
+ }
569
+
570
+ /** Adds `reference`, whose type arguments `get` did not find. */
571
+ add(hash: number, reference: TypeReference): void {
572
+ if (this.references.get(hash) === undefined) {
573
+ this.references.set(hash, reference);
574
+ return;
575
+ }
576
+ let collisions = this.collisions;
577
+ if (collisions === undefined) {
578
+ collisions = new TypeListCache<TypeReference>();
579
+ this.collisions = collisions;
580
+ }
581
+ collisions.set(hash, reference.resolvedTypeArguments!, undefined, 0, reference);
582
+ }
583
+ }
584
+
585
+ /**
586
+ * Fields that few types set, kept out of line in `Type.extra`, which is created on the first write
587
+ * of a value other than the field's default. A type then costs one slot for all of them. Each field
588
+ * is read and written through an accessor of the type class it belongs to, which returns the
589
+ * default while the type has no extra fields. Rare fields that hot paths read stay inline (the
590
+ * alias, construct signatures): a native accessor returns an owned reference, which costs reference
591
+ * counting on every read of a counted value.
592
+ */
593
+ export class TypeExtra implements ProgramLifetime {
594
+ // StructuredType
595
+ objectTypeWithoutAbstractConstructSignatures: Type | undefined;
596
+ // ObjectType
597
+ instantiations: TypeListCache<Type> | undefined;
598
+ // TypeReference
599
+ node: Node | undefined;
600
+ // UnionType
601
+ resolvedReducedType: Type | undefined;
602
+ regularType: Type | undefined;
603
+ origin: Type | undefined;
604
+ keyPropertyName: string;
605
+ constituentMap: Map<Type, Type> | undefined;
606
+ constituentIds: Int32Array | undefined;
607
+ membershipTests: number;
608
+ // IntersectionType
609
+ uniqueLiteralFilledInstantiation: Type | undefined;
610
+
611
+ constructor() {
612
+ this.objectTypeWithoutAbstractConstructSignatures = undefined;
613
+ this.instantiations = undefined;
614
+ this.node = undefined;
615
+ this.resolvedReducedType = undefined;
616
+ this.regularType = undefined;
617
+ this.origin = undefined;
618
+ this.keyPropertyName = '';
619
+ this.constituentMap = undefined;
620
+ this.constituentIds = undefined;
621
+ this.membershipTests = 0;
622
+ this.uniqueLiteralFilledInstantiation = undefined;
623
+ }
624
+ }
625
+
626
+ /** The extra fields of `t`, created if it has none yet. */
627
+ export function typeExtra(t: Type): TypeExtra {
628
+ let extra = t.extra;
629
+ if (extra === undefined) {
630
+ extra = new TypeExtra();
631
+ t.extra = extra;
632
+ }
633
+ return extra;
634
+ }
635
+
636
+ /**
637
+ * The base of every type. Narrow by `flags` (and `objectFlags` for object types), then cast to
638
+ * the subclass, as tsgo does with `AsUnionType()` etc.
639
+ */
640
+ /**
641
+ * `TSC_TS_SIDE_STATE=1` (a test of the side tables): every type and signature keeps its lazily
642
+ * computed state in the checker's side tables (`ObjectFlags.SideState`, `SignatureFlags.SideState`).
643
+ */
644
+ export const sideStateForAll: boolean = process.env.TSC_TS_SIDE_STATE === '1';
645
+
646
+ /** `symbol`, with its id assigned (`getSymbolId`): every symbol tsc-ts's public API hands out has one. */
647
+ function withId(symbol: Symbol | undefined): Symbol | undefined {
648
+ if (symbol !== undefined) getSymbolId(symbol);
649
+ return symbol;
650
+ }
651
+
652
+ /**
653
+ * What the methods of types that tsc-ts's public API calls need from the checker that created the type
654
+ * (`InterfaceType.checking`, `ConditionalType.checking`); the Checker implements it.
655
+ */
656
+ export interface TypeChecking {
657
+ baseTypesOf(t: InterfaceType): readonly Type[];
658
+ trueTypeOf(t: ConditionalType): Type;
659
+ falseTypeOf(t: ConditionalType): Type;
660
+ }
661
+
662
+ export class Type implements ProgramLifetime {
663
+ flags: TypeFlags;
664
+ objectFlags: ObjectFlags;
665
+ readonly id: number;
666
+ symbol: Symbol | undefined;
667
+ alias: TypeAlias | undefined;
668
+ /** For types with a computed base constraint (type variables, structured types, …). */
669
+ resolvedBaseConstraint: Type | undefined;
670
+ /** Rarely set fields; undefined while all of them have their defaults. */
671
+ extra: TypeExtra | undefined;
672
+
673
+ constructor(flags: TypeFlags, objectFlags: ObjectFlags, id: number, symbol: Symbol | undefined) {
674
+ this.flags = flags;
675
+ this.objectFlags = sideStateForAll ? objectFlags | ObjectFlags.SideState : objectFlags;
676
+ this.id = id | 0;
677
+ this.symbol = symbol;
678
+ this.alias = undefined;
679
+ this.resolvedBaseConstraint = undefined;
680
+ this.extra = undefined;
681
+ }
682
+
683
+ // TypeScript 7's API (tsc-ts/api): the parts of a type, undefined or empty where its kind has none.
684
+
685
+ getSymbol(): Symbol | undefined {
686
+ return withId(this.symbol);
687
+ }
688
+
689
+ getAliasSymbol(): Symbol | undefined {
690
+ return withId(this.alias?.symbol);
691
+ }
692
+
693
+ getAliasTypeArguments(): readonly Type[] {
694
+ const alias = this.alias;
695
+ return alias === undefined ? emptyTypes : alias.typeArguments.slice();
696
+ }
697
+
698
+ /** The target of a type reference, index type or string mapping type. */
699
+ getTarget(): Type | undefined {
700
+ if ((this.flags & TypeFlags.Index) !== 0) return (this as unknown as IndexType).target;
701
+ if ((this.flags & TypeFlags.StringMapping) !== 0) return (this as unknown as StringMappingType).target;
702
+ if (this.isTypeReference()) return (this as unknown as TypeReference).target;
703
+ return undefined;
704
+ }
705
+
706
+ /** The members of a union or intersection type, or the types of a template literal type. */
707
+ getTypes(): readonly Type[] {
708
+ if ((this.flags & TypeFlags.TemplateLiteral) !== 0) return (this as unknown as TemplateLiteralType).types.slice();
709
+ if ((this.flags & TypeFlags.UnionOrIntersection) !== 0)
710
+ return (this as unknown as UnionOrIntersectionType).types.slice();
711
+ return emptyTypes;
712
+ }
713
+
714
+ getFreshType(): Type | undefined {
715
+ return this instanceof LiteralType ? this.freshType : undefined;
716
+ }
717
+
718
+ getRegularType(): Type | undefined {
719
+ return this instanceof LiteralType ? this.regularType : undefined;
720
+ }
721
+
722
+ getObjectType(): Type | undefined {
723
+ return (this.flags & TypeFlags.IndexedAccess) !== 0 ? (this as unknown as IndexedAccessType).objectType : undefined;
724
+ }
725
+
726
+ getIndexType(): Type | undefined {
727
+ return (this.flags & TypeFlags.IndexedAccess) !== 0 ? (this as unknown as IndexedAccessType).indexType : undefined;
728
+ }
729
+
730
+ getCheckType(): Type | undefined {
731
+ return (this.flags & TypeFlags.Conditional) !== 0 ? (this as unknown as ConditionalType).checkType : undefined;
732
+ }
733
+
734
+ getExtendsType(): Type | undefined {
735
+ return (this.flags & TypeFlags.Conditional) !== 0 ? (this as unknown as ConditionalType).extendsType : undefined;
736
+ }
737
+
738
+ getTrueType(): Type | undefined {
739
+ if ((this.flags & TypeFlags.Conditional) === 0) return undefined;
740
+ const conditional = this as unknown as ConditionalType;
741
+ return conditional.checking?.trueTypeOf(conditional);
742
+ }
743
+
744
+ getFalseType(): Type | undefined {
745
+ if ((this.flags & TypeFlags.Conditional) === 0) return undefined;
746
+ const conditional = this as unknown as ConditionalType;
747
+ return conditional.checking?.falseTypeOf(conditional);
748
+ }
749
+
750
+ /** The base type of a substitution type. */
751
+ getBaseType(): Type | undefined {
752
+ return (this.flags & TypeFlags.Substitution) !== 0 ? (this as unknown as SubstitutionType).baseType : undefined;
753
+ }
754
+
755
+ /** The constraint of a substitution type. */
756
+ getConstraint(): Type | undefined {
757
+ return (this.flags & TypeFlags.Substitution) !== 0 ? (this as unknown as SubstitutionType).constraint : undefined;
758
+ }
759
+
760
+ /** The type parameters of a class or interface type, outer and local, without its `this` type. */
761
+ getTypeParameters(): readonly Type[] {
762
+ return this.isClassOrInterface() ? (this as unknown as InterfaceType).typeParameters() : emptyTypes;
763
+ }
764
+
765
+ getOuterTypeParameters(): readonly Type[] {
766
+ return this.isClassOrInterface() ? (this as unknown as InterfaceType).outerTypeParameters() : emptyTypes;
767
+ }
768
+
769
+ getLocalTypeParameters(): readonly Type[] {
770
+ return this.isClassOrInterface() ? (this as unknown as InterfaceType).localTypeParameters() : emptyTypes;
771
+ }
772
+
773
+ /** The base types of a class or interface type, or undefined for any other type. */
774
+ getBaseTypes(): readonly Type[] | undefined {
775
+ if (!this.isClassOrInterface()) return undefined;
776
+ const declared = this as unknown as InterfaceType;
777
+ return declared.checking === undefined ? emptyTypes : declared.checking.baseTypesOf(declared).slice();
778
+ }
779
+
780
+ isClassOrInterface(): boolean {
781
+ return (this.flags & TypeFlags.Object) !== 0 && (this.objectFlags & ObjectFlags.ClassOrInterface) !== 0;
782
+ }
783
+
784
+ isUnionType(): boolean {
785
+ return (this.flags & TypeFlags.Union) !== 0;
786
+ }
787
+
788
+ isIntersectionType(): boolean {
789
+ return (this.flags & TypeFlags.Intersection) !== 0;
790
+ }
791
+
792
+ isObjectType(): boolean {
793
+ return (this.flags & TypeFlags.Object) !== 0;
794
+ }
795
+
796
+ isIntrinsicType(): boolean {
797
+ return (this.flags & TypeFlags.Intrinsic) !== 0;
798
+ }
799
+
800
+ /** Whether this is the error type: an intrinsic type named `error`. */
801
+ isErrorType(): boolean {
802
+ return this instanceof IntrinsicType && this.intrinsicName === 'error';
803
+ }
804
+
805
+ isLiteralType(): boolean {
806
+ return (this.flags & TypeFlags.Literal) !== 0;
807
+ }
808
+
809
+ isStringLiteralType(): boolean {
810
+ return (this.flags & TypeFlags.StringLiteral) !== 0;
811
+ }
812
+
813
+ isNumberLiteralType(): boolean {
814
+ return (this.flags & TypeFlags.NumberLiteral) !== 0;
815
+ }
816
+
817
+ isBigIntLiteralType(): boolean {
818
+ return (this.flags & TypeFlags.BigIntLiteral) !== 0;
819
+ }
820
+
821
+ isBooleanLiteralType(): boolean {
822
+ return (this.flags & TypeFlags.BooleanLiteral) !== 0;
823
+ }
824
+
825
+ isTypeReference(): boolean {
826
+ return (this.flags & TypeFlags.Object) !== 0 && (this.objectFlags & ObjectFlags.Reference) !== 0;
827
+ }
828
+
829
+ isTupleType(): boolean {
830
+ return (this.flags & TypeFlags.Object) !== 0 && (this.objectFlags & ObjectFlags.Tuple) !== 0;
831
+ }
832
+
833
+ isIndexType(): boolean {
834
+ return (this.flags & TypeFlags.Index) !== 0;
835
+ }
836
+
837
+ isIndexedAccessType(): boolean {
838
+ return (this.flags & TypeFlags.IndexedAccess) !== 0;
839
+ }
840
+
841
+ isConditionalType(): boolean {
842
+ return (this.flags & TypeFlags.Conditional) !== 0;
843
+ }
844
+
845
+ isSubstitutionType(): boolean {
846
+ return (this.flags & TypeFlags.Substitution) !== 0;
847
+ }
848
+
849
+ isTemplateLiteralType(): boolean {
850
+ return (this.flags & TypeFlags.TemplateLiteral) !== 0;
851
+ }
852
+
853
+ isStringMappingType(): boolean {
854
+ return (this.flags & TypeFlags.StringMapping) !== 0;
855
+ }
856
+
857
+ isTypeParameter(): boolean {
858
+ return (this.flags & TypeFlags.TypeParameter) !== 0;
859
+ }
860
+ }
861
+
862
+ export class IntrinsicType extends Type {
863
+ readonly intrinsicName: string;
864
+
865
+ constructor(flags: TypeFlags, objectFlags: ObjectFlags, id: number, intrinsicName: string) {
866
+ super(flags, objectFlags, id, undefined);
867
+ this.intrinsicName = intrinsicName;
868
+ }
869
+ }
870
+
871
+ /**
872
+ * A literal or enum member type. `value` is the string of string literals, the number of number
873
+ * literals, `true`/`false` for booleans, the decimal digits (with a leading `-`) of bigints, and
874
+ * unset for computed enum members.
875
+ */
876
+ export class LiteralType extends Type {
877
+ readonly stringValue: string;
878
+ readonly numberValue: number;
879
+ /** Created on first use, except for `true` and `false`. */
880
+ freshType: LiteralType | undefined;
881
+ regularType: LiteralType;
882
+
883
+ constructor(flags: TypeFlags, id: number, symbol: Symbol | undefined, stringValue: string, numberValue: number) {
884
+ super(flags, ObjectFlags.None, id, symbol);
885
+ this.stringValue = stringValue;
886
+ this.numberValue = numberValue;
887
+ this.freshType = undefined;
888
+ this.regularType = this;
889
+ }
890
+
891
+ /** The value, as TypeScript 7's API gives it: a string, number, bigint or boolean. */
892
+ get value(): string | number | bigint | boolean {
893
+ if ((this.flags & TypeFlags.StringLiteral) !== 0) return this.stringValue;
894
+ if ((this.flags & TypeFlags.BigIntLiteral) !== 0) return BigInt(this.stringValue);
895
+ if ((this.flags & TypeFlags.BooleanLiteral) !== 0) return this.stringValue === 'true';
896
+ return this.numberValue;
897
+ }
898
+ }
899
+
900
+ export class UniqueESSymbolType extends Type {
901
+ readonly name: string;
902
+
903
+ constructor(id: number, symbol: Symbol, name: string) {
904
+ super(TypeFlags.UniqueESSymbol, ObjectFlags.None, id, symbol);
905
+ this.name = name;
906
+ }
907
+ }
908
+
909
+ /**
910
+ * The members table of a type, built when `members` is read (checker-members.ts): of an instantiated
911
+ * type whose member symbols are instantiated on demand (`PendingInstantiatedMembers`), where reading
912
+ * `properties` builds the properties too, as tsgo builds them when it resolves the members, and
913
+ * lookups by name instantiate only the member asked for; or of a type whose members are all
914
+ * properties (`PropertyMembers`), where lookups by name read the properties.
915
+ */
916
+ export abstract class PendingMembers {
917
+ /**
918
+ * Set when `properties` is built and the members table is not (`PropertyMembers`): the type's
919
+ * properties, which lookups by name then read.
920
+ */
921
+ materializedProperties: Symbol[] | undefined = undefined;
922
+
923
+ /**
924
+ * Sets `t.propertiesValue`. Where lookups can read the properties, it replaces `t.pendingMembers`
925
+ * with a `PropertyMembers`; otherwise it sets `t.membersValue` too and clears `t.pendingMembers`.
926
+ */
927
+ abstract materialize(t: StructuredType): void;
928
+
929
+ /** Sets `t.membersValue` and `t.propertiesValue` and clears `t.pendingMembers`. */
930
+ abstract materializeTable(t: StructuredType): void;
931
+
932
+ /** `members.get(name)` of the table tsgo would have built by now. */
933
+ abstract get(name: string): Symbol | undefined;
934
+ }
935
+
936
+ /**
937
+ * The property names of instantiated types whose members tables are built on demand, shared by the
938
+ * instantiations of one source that have the same names in the same order: most instantiations of
939
+ * a class or interface have the members of their source and of the same bases.
940
+ */
941
+ export class MemberNames {
942
+ /** The names of the properties, in order. */
943
+ readonly names: string[];
944
+ /** The index of each name in `names`. */
945
+ readonly positions: Map<string, number>;
946
+ /** The indexes in `names` of the members table's names, in table order. */
947
+ readonly tableOrder: number[];
948
+
949
+ constructor(names: string[], positions: Map<string, number>, tableOrder: number[]) {
950
+ this.names = names;
951
+ this.positions = positions;
952
+ this.tableOrder = tableOrder;
953
+ }
954
+ }
955
+
956
+ /** A type with members: object types, unions and intersections. */
957
+ export class StructuredType extends Type {
958
+ membersValue: SymbolTable | undefined;
959
+ propertiesValue: Symbol[];
960
+ /** Set while the member symbols of an instantiated type are not instantiated yet. */
961
+ pendingMembers: PendingMembers | undefined;
962
+ callSignatures: Signature[];
963
+ constructSignatures: Signature[];
964
+ indexInfos: IndexInfo[];
965
+
966
+ constructor(flags: TypeFlags, objectFlags: ObjectFlags, id: number, symbol: Symbol | undefined) {
967
+ super(flags, objectFlags, id, symbol);
968
+ this.membersValue = undefined;
969
+ this.propertiesValue = emptySymbols;
970
+ this.pendingMembers = undefined;
971
+ this.callSignatures = emptySignatures;
972
+ this.constructSignatures = emptySignatures;
973
+ this.indexInfos = emptyIndexInfos;
974
+ }
975
+
976
+ get objectTypeWithoutAbstractConstructSignatures(): Type | undefined {
977
+ const extra = this.extra;
978
+ return extra !== undefined ? extra.objectTypeWithoutAbstractConstructSignatures : undefined;
979
+ }
980
+
981
+ set objectTypeWithoutAbstractConstructSignatures(t: Type | undefined) {
982
+ if (t !== undefined || this.extra !== undefined) typeExtra(this).objectTypeWithoutAbstractConstructSignatures = t;
983
+ }
984
+
985
+ get members(): SymbolTable | undefined {
986
+ const pending = this.pendingMembers;
987
+ if (pending !== undefined) pending.materializeTable(this);
988
+ return this.membersValue;
989
+ }
990
+
991
+ set members(members: SymbolTable | undefined) {
992
+ this.membersValue = members;
993
+ }
994
+
995
+ get properties(): Symbol[] {
996
+ const pending = this.pendingMembers;
997
+ if (pending !== undefined && pending.materializedProperties === undefined) pending.materialize(this);
998
+ return this.propertiesValue;
999
+ }
1000
+
1001
+ set properties(properties: Symbol[]) {
1002
+ this.propertiesValue = properties;
1003
+ }
1004
+ }
1005
+
1006
+ export class ObjectType extends StructuredType {
1007
+ /** The generic type this one instantiates. */
1008
+ target: Type | undefined;
1009
+ mapper: TypeMapper | undefined;
1010
+
1011
+ constructor(objectFlags: ObjectFlags, id: number, symbol: Symbol | undefined) {
1012
+ super(TypeFlags.Object, objectFlags, id, symbol);
1013
+ this.target = undefined;
1014
+ this.mapper = undefined;
1015
+ }
1016
+
1017
+ get instantiations(): TypeListCache<Type> | undefined {
1018
+ const extra = this.extra;
1019
+ return extra !== undefined ? extra.instantiations : undefined;
1020
+ }
1021
+
1022
+ set instantiations(instantiations: TypeListCache<Type> | undefined) {
1023
+ if (instantiations !== undefined || this.extra !== undefined) typeExtra(this).instantiations = instantiations;
1024
+ }
1025
+ }
1026
+
1027
+ /** An instantiation of a generic class, interface or tuple type. */
1028
+ export class TypeReference extends ObjectType {
1029
+ resolvedTypeArguments: Type[] | undefined;
1030
+
1031
+ constructor(objectFlags: ObjectFlags, id: number, symbol: Symbol | undefined) {
1032
+ super(objectFlags, id, symbol);
1033
+ this.resolvedTypeArguments = undefined;
1034
+ }
1035
+
1036
+ /** The type node of a deferred reference, else undefined. */
1037
+ get node(): Node | undefined {
1038
+ const extra = this.extra;
1039
+ return extra !== undefined ? extra.node : undefined;
1040
+ }
1041
+
1042
+ set node(node: Node | undefined) {
1043
+ if (node !== undefined || this.extra !== undefined) typeExtra(this).node = node;
1044
+ }
1045
+ }
1046
+
1047
+ /** A class or interface; when generic, also the reference to itself instantiated with its own type parameters. */
1048
+ export class InterfaceType extends TypeReference {
1049
+ /** Outer, then local type parameters, then the `this` type. */
1050
+ allTypeParameters: Type[];
1051
+ outerTypeParameterCount: number;
1052
+ thisType: Type | undefined;
1053
+ baseTypesResolved: boolean;
1054
+ declaredMembersResolved: boolean;
1055
+ resolvedBaseConstructorType: Type | undefined;
1056
+ resolvedBaseTypes: Type[];
1057
+ declaredMembers: SymbolTable | undefined;
1058
+ declaredCallSignatures: Signature[];
1059
+ declaredConstructSignatures: Signature[];
1060
+ declaredIndexInfos: IndexInfo[];
1061
+ /** Positions of the declared members by name, for lazily instantiated members of instantiations. */
1062
+ declaredMemberPositions: Map<string, number> | undefined;
1063
+ /** The member states of the last pending instantiation of the type's members (`sharedStates`). */
1064
+ lastMemberStates: number[] | undefined;
1065
+ /** The property names of the last instantiation whose members table is built on demand. */
1066
+ lastMemberNames: MemberNames | undefined;
1067
+ /** The references to a generic class, interface or tuple type, by their type arguments. */
1068
+ references: ReferenceCache | undefined;
1069
+ /** The checker that created the type, for `getBaseTypes()`. */
1070
+ checking: TypeChecking | undefined;
1071
+
1072
+ constructor(objectFlags: ObjectFlags, id: number, symbol: Symbol | undefined) {
1073
+ super(objectFlags, id, symbol);
1074
+ this.references = undefined;
1075
+ this.checking = undefined;
1076
+ this.declaredMemberPositions = undefined;
1077
+ this.lastMemberStates = undefined;
1078
+ this.lastMemberNames = undefined;
1079
+ this.allTypeParameters = emptyTypes;
1080
+ this.outerTypeParameterCount = 0;
1081
+ this.thisType = undefined;
1082
+ this.baseTypesResolved = false;
1083
+ this.declaredMembersResolved = false;
1084
+ this.resolvedBaseConstructorType = undefined;
1085
+ this.resolvedBaseTypes = emptyTypes;
1086
+ this.declaredMembers = undefined;
1087
+ this.declaredCallSignatures = emptySignatures;
1088
+ this.declaredConstructSignatures = emptySignatures;
1089
+ this.declaredIndexInfos = emptyIndexInfos;
1090
+ }
1091
+
1092
+ outerTypeParameters(): Type[] {
1093
+ return this.allTypeParameters.length === 0
1094
+ ? emptyTypes
1095
+ : this.allTypeParameters.slice(0, this.outerTypeParameterCount);
1096
+ }
1097
+
1098
+ localTypeParameters(): Type[] {
1099
+ const all = this.allTypeParameters;
1100
+ return all.length === 0 ? emptyTypes : all.slice(this.outerTypeParameterCount, all.length - 1);
1101
+ }
1102
+
1103
+ typeParameters(): Type[] {
1104
+ const all = this.allTypeParameters;
1105
+ return all.length === 0 ? emptyTypes : all.slice(0, all.length - 1);
1106
+ }
1107
+
1108
+ /** `typeParameters().length`, without copying them. */
1109
+ typeParameterCount(): number {
1110
+ const count = this.allTypeParameters.length;
1111
+ return count === 0 ? 0 : count - 1;
1112
+ }
1113
+ }
1114
+
1115
+ export class TupleElementInfo {
1116
+ readonly flags: ElementFlags;
1117
+ /** A NamedTupleMember or ParameterDeclaration, if labeled. */
1118
+ readonly labeledDeclaration: Node | undefined;
1119
+
1120
+ constructor(flags: ElementFlags, labeledDeclaration: Node | undefined) {
1121
+ this.flags = flags;
1122
+ this.labeledDeclaration = labeledDeclaration;
1123
+ }
1124
+ }
1125
+
1126
+ export class TupleType extends InterfaceType {
1127
+ elementInfos: TupleElementInfo[];
1128
+ /** Required or variadic elements. */
1129
+ minLength: number;
1130
+ /** Leading required or optional elements. */
1131
+ fixedLength: number;
1132
+ combinedFlags: ElementFlags;
1133
+ readonly: boolean;
1134
+
1135
+ constructor(objectFlags: ObjectFlags, id: number) {
1136
+ super(objectFlags, id, undefined);
1137
+ this.elementInfos = [];
1138
+ this.minLength = 0;
1139
+ this.fixedLength = 0;
1140
+ this.combinedFlags = ElementFlags.None;
1141
+ this.readonly = false;
1142
+ }
1143
+
1144
+ /** The flags of each element (TypeScript 7's API). */
1145
+ get elementFlags(): ElementFlags[] {
1146
+ return this.elementInfos.map((info) => info.flags);
1147
+ }
1148
+ }
1149
+
1150
+ export class InstantiationExpressionType extends ObjectType {
1151
+ node: Node | undefined;
1152
+
1153
+ constructor(objectFlags: ObjectFlags, id: number, symbol: Symbol | undefined) {
1154
+ super(objectFlags, id, symbol);
1155
+ this.node = undefined;
1156
+ }
1157
+ }
1158
+
1159
+ export class MappedType extends ObjectType {
1160
+ declaration: Node | undefined;
1161
+ typeParameter: Type | undefined;
1162
+ constraintType: Type | undefined;
1163
+ nameType: Type | undefined;
1164
+ templateType: Type | undefined;
1165
+ modifiersType: Type | undefined;
1166
+ resolvedApparentType: Type | undefined;
1167
+ containsError: boolean;
1168
+
1169
+ constructor(objectFlags: ObjectFlags, id: number, symbol: Symbol | undefined) {
1170
+ super(objectFlags, id, symbol);
1171
+ this.declaration = undefined;
1172
+ this.typeParameter = undefined;
1173
+ this.constraintType = undefined;
1174
+ this.nameType = undefined;
1175
+ this.templateType = undefined;
1176
+ this.modifiersType = undefined;
1177
+ this.resolvedApparentType = undefined;
1178
+ this.containsError = false;
1179
+ }
1180
+ }
1181
+
1182
+ export class ReverseMappedType extends ObjectType {
1183
+ source: Type | undefined;
1184
+ mappedType: Type | undefined;
1185
+ constraintType: Type | undefined;
1186
+
1187
+ constructor(objectFlags: ObjectFlags, id: number) {
1188
+ super(objectFlags, id, undefined);
1189
+ this.source = undefined;
1190
+ this.mappedType = undefined;
1191
+ this.constraintType = undefined;
1192
+ }
1193
+ }
1194
+
1195
+ export class EvolvingArrayType extends ObjectType {
1196
+ elementType: Type | undefined;
1197
+ finalArrayType: Type | undefined;
1198
+
1199
+ constructor(objectFlags: ObjectFlags, id: number) {
1200
+ super(objectFlags, id, undefined);
1201
+ this.elementType = undefined;
1202
+ this.finalArrayType = undefined;
1203
+ }
1204
+ }
1205
+
1206
+ /**
1207
+ * A union or intersection. Few have their members resolved or their properties cached, so those
1208
+ * live in `membersOf` (`UnionOrIntersectionMembers`), which is created when they are first written.
1209
+ */
1210
+ export class UnionOrIntersectionType extends Type {
1211
+ readonly types: Type[];
1212
+ membersOf: UnionOrIntersectionMembers | undefined;
1213
+
1214
+ constructor(flags: TypeFlags, objectFlags: ObjectFlags, id: number, types: Type[]) {
1215
+ super(flags, objectFlags, id, undefined);
1216
+ this.types = types;
1217
+ this.membersOf = undefined;
1218
+ }
1219
+ }
1220
+
1221
+ /**
1222
+ * The resolved members of a union or intersection (`membersHolder`) and the caches of its
1223
+ * properties, created on first use.
1224
+ */
1225
+ export class UnionOrIntersectionMembers extends StructuredType {
1226
+ propertyCache: SymbolTable | undefined;
1227
+ propertyCacheWithoutFunctionPropertyAugment: SymbolTable | undefined;
1228
+ resolvedProperties: Symbol[] | undefined;
1229
+
1230
+ constructor(flags: TypeFlags, id: number) {
1231
+ super(flags, ObjectFlags.None, id, undefined);
1232
+ this.propertyCache = undefined;
1233
+ this.propertyCacheWithoutFunctionPropertyAugment = undefined;
1234
+ this.resolvedProperties = undefined;
1235
+ }
1236
+ }
1237
+
1238
+ /** The members holder of a union or intersection, created if it has none yet. */
1239
+ export function unionOrIntersectionMembers(t: UnionOrIntersectionType): UnionOrIntersectionMembers {
1240
+ let members = t.membersOf;
1241
+ if (members === undefined) {
1242
+ members = new UnionOrIntersectionMembers(t.flags, t.id);
1243
+ t.membersOf = members;
1244
+ }
1245
+ return members;
1246
+ }
1247
+
1248
+ /** A union; all of its own fields are rarely set and live in `extra`. */
1249
+ export class UnionType extends UnionOrIntersectionType {
1250
+ constructor(objectFlags: ObjectFlags, id: number, types: Type[]) {
1251
+ super(TypeFlags.Union, objectFlags, id, types);
1252
+ }
1253
+
1254
+ get resolvedReducedType(): Type | undefined {
1255
+ const extra = this.extra;
1256
+ return extra !== undefined ? extra.resolvedReducedType : undefined;
1257
+ }
1258
+
1259
+ set resolvedReducedType(t: Type | undefined) {
1260
+ if (t !== undefined || this.extra !== undefined) typeExtra(this).resolvedReducedType = t;
1261
+ }
1262
+
1263
+ get regularType(): Type | undefined {
1264
+ const extra = this.extra;
1265
+ return extra !== undefined ? extra.regularType : undefined;
1266
+ }
1267
+
1268
+ set regularType(t: Type | undefined) {
1269
+ if (t !== undefined || this.extra !== undefined) typeExtra(this).regularType = t;
1270
+ }
1271
+
1272
+ /** The denormalized union, intersection or index type the union came from. */
1273
+ get origin(): Type | undefined {
1274
+ const extra = this.extra;
1275
+ return extra !== undefined ? extra.origin : undefined;
1276
+ }
1277
+
1278
+ set origin(t: Type | undefined) {
1279
+ if (t !== undefined || this.extra !== undefined) typeExtra(this).origin = t;
1280
+ }
1281
+
1282
+ /** A property with a unique unit type in every object of the union; '' if not computed, '\0' if none. */
1283
+ get keyPropertyName(): string {
1284
+ const extra = this.extra;
1285
+ return extra !== undefined ? extra.keyPropertyName : '';
1286
+ }
1287
+
1288
+ set keyPropertyName(name: string) {
1289
+ if (name !== '' || this.extra !== undefined) typeExtra(this).keyPropertyName = name;
1290
+ }
1291
+
1292
+ get constituentMap(): Map<Type, Type> | undefined {
1293
+ const extra = this.extra;
1294
+ return extra !== undefined ? extra.constituentMap : undefined;
1295
+ }
1296
+
1297
+ set constituentMap(map: Map<Type, Type> | undefined) {
1298
+ if (map !== undefined || this.extra !== undefined) typeExtra(this).constituentMap = map;
1299
+ }
1300
+
1301
+ /**
1302
+ * A hash table of the ids of a large union's constituents, for membership tests; created on the
1303
+ * second test (`constituentTable`). About eight bytes a constituent, where a set of them took
1304
+ * about five times that.
1305
+ */
1306
+ get constituentIds(): Int32Array | undefined {
1307
+ const extra = this.extra;
1308
+ return extra !== undefined ? extra.constituentIds : undefined;
1309
+ }
1310
+
1311
+ set constituentIds(ids: Int32Array | undefined) {
1312
+ if (ids !== undefined || this.extra !== undefined) typeExtra(this).constituentIds = ids;
1313
+ }
1314
+
1315
+ get membershipTests(): number {
1316
+ const extra = this.extra;
1317
+ return extra !== undefined ? extra.membershipTests : 0;
1318
+ }
1319
+
1320
+ set membershipTests(tests: number) {
1321
+ if (tests !== 0 || this.extra !== undefined) typeExtra(this).membershipTests = tests;
1322
+ }
1323
+ }
1324
+
1325
+ export class IntersectionType extends UnionOrIntersectionType {
1326
+ resolvedApparentType: Type | undefined;
1327
+
1328
+ constructor(objectFlags: ObjectFlags, id: number, types: Type[]) {
1329
+ super(TypeFlags.Intersection, objectFlags, id, types);
1330
+ this.resolvedApparentType = undefined;
1331
+ }
1332
+
1333
+ get uniqueLiteralFilledInstantiation(): Type | undefined {
1334
+ const extra = this.extra;
1335
+ return extra !== undefined ? extra.uniqueLiteralFilledInstantiation : undefined;
1336
+ }
1337
+
1338
+ set uniqueLiteralFilledInstantiation(t: Type | undefined) {
1339
+ if (t !== undefined || this.extra !== undefined) typeExtra(this).uniqueLiteralFilledInstantiation = t;
1340
+ }
1341
+ }
1342
+
1343
+ export class TypeParameter extends Type {
1344
+ constraint: Type | undefined;
1345
+ target: Type | undefined;
1346
+ mapper: TypeMapper | undefined;
1347
+ isThisType: boolean;
1348
+ resolvedDefaultType: Type | undefined;
1349
+
1350
+ constructor(id: number, symbol: Symbol | undefined) {
1351
+ super(TypeFlags.TypeParameter, ObjectFlags.None, id, symbol);
1352
+ this.constraint = undefined;
1353
+ this.target = undefined;
1354
+ this.mapper = undefined;
1355
+ this.isThisType = false;
1356
+ this.resolvedDefaultType = undefined;
1357
+ }
1358
+ }
1359
+
1360
+ /** `keyof T`. */
1361
+ export class IndexType extends Type {
1362
+ readonly target: Type;
1363
+ readonly indexFlags: IndexFlags;
1364
+
1365
+ constructor(id: number, target: Type, indexFlags: IndexFlags) {
1366
+ super(TypeFlags.Index, ObjectFlags.None, id, undefined);
1367
+ this.target = target;
1368
+ this.indexFlags = indexFlags;
1369
+ }
1370
+ }
1371
+
1372
+ /** `T[K]`. */
1373
+ export class IndexedAccessType extends Type {
1374
+ readonly objectType: Type;
1375
+ readonly indexType: Type;
1376
+ /** Only AccessFlags.Persistent. */
1377
+ readonly accessFlags: AccessFlags;
1378
+
1379
+ constructor(id: number, objectType: Type, indexType: Type, accessFlags: AccessFlags) {
1380
+ super(TypeFlags.IndexedAccess, ObjectFlags.None, id, undefined);
1381
+ this.objectType = objectType;
1382
+ this.indexType = indexType;
1383
+ this.accessFlags = accessFlags;
1384
+ }
1385
+ }
1386
+
1387
+ export class TemplateLiteralType extends Type {
1388
+ /** One longer than `types`. */
1389
+ readonly texts: string[];
1390
+ readonly types: Type[];
1391
+
1392
+ constructor(id: number, texts: string[], types: Type[]) {
1393
+ super(TypeFlags.TemplateLiteral, ObjectFlags.None, id, undefined);
1394
+ this.texts = texts;
1395
+ this.types = types;
1396
+ }
1397
+ }
1398
+
1399
+ /** `Uppercase<T>` and friends. */
1400
+ export class StringMappingType extends Type {
1401
+ readonly target: Type;
1402
+
1403
+ constructor(id: number, symbol: Symbol, target: Type) {
1404
+ super(TypeFlags.StringMapping, ObjectFlags.None, id, symbol);
1405
+ this.target = target;
1406
+ }
1407
+ }
1408
+
1409
+ export class SubstitutionType extends Type {
1410
+ readonly baseType: Type;
1411
+ /** What the base type is known to satisfy. */
1412
+ readonly constraint: Type;
1413
+
1414
+ constructor(id: number, baseType: Type, constraint: Type) {
1415
+ super(TypeFlags.Substitution, ObjectFlags.None, id, undefined);
1416
+ this.baseType = baseType;
1417
+ this.constraint = constraint;
1418
+ }
1419
+ }
1420
+
1421
+ export class ConditionalRoot {
1422
+ readonly node: Node;
1423
+ readonly checkType: Type;
1424
+ readonly extendsType: Type;
1425
+ readonly isDistributive: boolean;
1426
+ readonly inferTypeParameters: Type[];
1427
+ readonly outerTypeParameters: Type[];
1428
+ readonly instantiations: TypeListCache<Type>;
1429
+ readonly alias: TypeAlias | undefined;
1430
+ /**
1431
+ * The type arguments of an extends type that is a reference to a class or interface; null for
1432
+ * other extends types, undefined until computed.
1433
+ */
1434
+ referenceArgs: ReferenceArgs | null | undefined;
1435
+
1436
+ constructor(
1437
+ node: Node,
1438
+ checkType: Type,
1439
+ extendsType: Type,
1440
+ isDistributive: boolean,
1441
+ inferTypeParameters: Type[],
1442
+ outerTypeParameters: Type[],
1443
+ alias: TypeAlias | undefined,
1444
+ ) {
1445
+ this.node = node;
1446
+ this.checkType = checkType;
1447
+ this.extendsType = extendsType;
1448
+ this.isDistributive = isDistributive;
1449
+ this.inferTypeParameters = inferTypeParameters;
1450
+ this.outerTypeParameters = outerTypeParameters;
1451
+ this.instantiations = new TypeListCache<Type>();
1452
+ this.alias = alias;
1453
+ this.referenceArgs = undefined;
1454
+ }
1455
+ }
1456
+
1457
+ /** What each type argument of a conditional type's extends type is, for `isFalseForEveryInference`. */
1458
+ export class ReferenceArgs {
1459
+ readonly kinds: ReferenceArgKind[];
1460
+ /** The `infer` type parameter of each `ReferenceArgKind.Infer` type argument. */
1461
+ readonly inferTypeParameters: (Type | undefined)[];
1462
+
1463
+ constructor(kinds: ReferenceArgKind[], inferTypeParameters: (Type | undefined)[]) {
1464
+ this.kinds = kinds;
1465
+ this.inferTypeParameters = inferTypeParameters;
1466
+ }
1467
+ }
1468
+
1469
+ export const enum ReferenceArgKind {
1470
+ /** Has no `infer` type parameters, so inference doesn't change it. */
1471
+ Fixed,
1472
+ /** Just an `infer` type parameter that occurs nowhere else in the extends type. */
1473
+ Infer,
1474
+ /** An object type with `infer` type parameters: an instantiation of it is an object type. */
1475
+ Object,
1476
+ Other,
1477
+ }
1478
+
1479
+ export class ConditionalType extends Type {
1480
+ readonly root: ConditionalRoot;
1481
+ readonly checkType: Type;
1482
+ readonly extendsType: Type;
1483
+ resolvedTrueType: Type | undefined;
1484
+ resolvedFalseType: Type | undefined;
1485
+ /** The true and false types, as one list (getBranchTypesFromConditionalType). */
1486
+ resolvedBranchTypes: Type[] | undefined;
1487
+ resolvedInferredTrueType: Type | undefined;
1488
+ resolvedDefaultConstraint: Type | undefined;
1489
+ resolvedConstraintOfDistributive: Type | undefined;
1490
+ readonly mapper: TypeMapper | undefined;
1491
+ readonly combinedMapper: TypeMapper | undefined;
1492
+ /** The checker that created the type, for `getTrueType()` and `getFalseType()`. */
1493
+ checking: TypeChecking | undefined;
1494
+
1495
+ constructor(
1496
+ id: number,
1497
+ root: ConditionalRoot,
1498
+ checkType: Type,
1499
+ extendsType: Type,
1500
+ mapper: TypeMapper | undefined,
1501
+ combinedMapper: TypeMapper | undefined,
1502
+ ) {
1503
+ super(TypeFlags.Conditional, ObjectFlags.None, id, undefined);
1504
+ this.root = root;
1505
+ this.checkType = checkType;
1506
+ this.extendsType = extendsType;
1507
+ this.resolvedTrueType = undefined;
1508
+ this.resolvedFalseType = undefined;
1509
+ this.resolvedBranchTypes = undefined;
1510
+ this.resolvedInferredTrueType = undefined;
1511
+ this.resolvedDefaultConstraint = undefined;
1512
+ this.resolvedConstraintOfDistributive = undefined;
1513
+ this.mapper = mapper;
1514
+ this.combinedMapper = combinedMapper;
1515
+ this.checking = undefined;
1516
+ }
1517
+ }
1518
+
1519
+ // ---- Signatures and index infos
1520
+
1521
+ export class TypePredicate {
1522
+ readonly kind: TypePredicateKind;
1523
+ readonly parameterIndex: number;
1524
+ readonly parameterName: string;
1525
+ readonly type: Type | undefined;
1526
+
1527
+ constructor(kind: TypePredicateKind, parameterName: string, parameterIndex: number, type: Type | undefined) {
1528
+ this.kind = kind;
1529
+ this.parameterIndex = parameterIndex;
1530
+ this.parameterName = parameterName;
1531
+ this.type = type;
1532
+ }
1533
+ }
1534
+
1535
+ export class CompositeSignature {
1536
+ /** False for an intersection. */
1537
+ readonly isUnion: boolean;
1538
+ readonly signatures: Signature[];
1539
+
1540
+ constructor(isUnion: boolean, signatures: Signature[]) {
1541
+ this.isUnion = isUnion;
1542
+ this.signatures = signatures;
1543
+ }
1544
+ }
1545
+
1546
+ /**
1547
+ * Fields that few signatures set, kept out of line in `Signature.extra` (see TypeExtra): the `this`
1548
+ * parameter, composite signatures and the caches of derived signatures.
1549
+ */
1550
+ export class SignatureExtra implements ProgramLifetime {
1551
+ thisParameter: Symbol | undefined;
1552
+ isolatedSignatureType: Type | undefined;
1553
+ composite: CompositeSignature | undefined;
1554
+ erasedSignatureCache: Signature | undefined;
1555
+ canonicalSignatureCache: Signature | undefined;
1556
+ baseSignatureCache: Signature | undefined;
1557
+ optionalCallSignatureCache: Signature | undefined;
1558
+ instantiations: TypeListCache<Signature> | undefined;
1559
+
1560
+ constructor() {
1561
+ this.thisParameter = undefined;
1562
+ this.isolatedSignatureType = undefined;
1563
+ this.composite = undefined;
1564
+ this.erasedSignatureCache = undefined;
1565
+ this.canonicalSignatureCache = undefined;
1566
+ this.baseSignatureCache = undefined;
1567
+ this.optionalCallSignatureCache = undefined;
1568
+ this.instantiations = undefined;
1569
+ }
1570
+ }
1571
+
1572
+ /** The extra fields of `s`, created if it has none yet. */
1573
+ export function signatureExtra(s: Signature): SignatureExtra {
1574
+ let extra = s.extra;
1575
+ if (extra === undefined) {
1576
+ extra = new SignatureExtra();
1577
+ s.extra = extra;
1578
+ }
1579
+ return extra;
1580
+ }
1581
+
1582
+ export class Signature implements ProgramLifetime {
1583
+ readonly id: number;
1584
+ flags: SignatureFlags;
1585
+ minArgumentCount: number;
1586
+ /** -1 until computed. */
1587
+ resolvedMinArgumentCount: number;
1588
+ declaration: Node | undefined;
1589
+ typeParameters: Type[];
1590
+ parameters: Symbol[];
1591
+ resolvedReturnType: Type | undefined;
1592
+ resolvedTypePredicate: TypePredicate | undefined;
1593
+ target: Signature | undefined;
1594
+ mapper: TypeMapper | undefined;
1595
+ /** Rarely set fields; undefined while all of them have their defaults. */
1596
+ extra: SignatureExtra | undefined;
1597
+
1598
+ constructor(
1599
+ id: number,
1600
+ flags: SignatureFlags,
1601
+ declaration: Node | undefined,
1602
+ typeParameters: Type[],
1603
+ thisParameter: Symbol | undefined,
1604
+ parameters: Symbol[],
1605
+ resolvedReturnType: Type | undefined,
1606
+ resolvedTypePredicate: TypePredicate | undefined,
1607
+ minArgumentCount: number,
1608
+ ) {
1609
+ this.id = id | 0;
1610
+ this.flags = sideStateForAll ? flags | SignatureFlags.SideState : flags;
1611
+ this.minArgumentCount = minArgumentCount | 0;
1612
+ this.resolvedMinArgumentCount = -1;
1613
+ this.declaration = declaration;
1614
+ this.typeParameters = typeParameters;
1615
+ this.parameters = parameters;
1616
+ this.resolvedReturnType = resolvedReturnType;
1617
+ this.resolvedTypePredicate = resolvedTypePredicate;
1618
+ this.target = undefined;
1619
+ this.mapper = undefined;
1620
+ this.extra = undefined;
1621
+ if (thisParameter !== undefined) signatureExtra(this).thisParameter = thisParameter;
1622
+ }
1623
+
1624
+ get thisParameter(): Symbol | undefined {
1625
+ const extra = this.extra;
1626
+ return extra !== undefined ? extra.thisParameter : undefined;
1627
+ }
1628
+
1629
+ set thisParameter(symbol: Symbol | undefined) {
1630
+ if (symbol !== undefined || this.extra !== undefined) signatureExtra(this).thisParameter = symbol;
1631
+ }
1632
+
1633
+ // TypeScript 7's API (tsc-ts/api).
1634
+
1635
+ getTypeParameters(): readonly Type[] {
1636
+ return this.typeParameters.slice();
1637
+ }
1638
+
1639
+ getParameters(): readonly Symbol[] {
1640
+ for (const parameter of this.parameters) getSymbolId(parameter);
1641
+ return this.parameters.slice();
1642
+ }
1643
+
1644
+ getThisParameter(): Symbol | undefined {
1645
+ return withId(this.thisParameter);
1646
+ }
1647
+
1648
+ /** The signature this one was instantiated from. */
1649
+ getTarget(): Signature | undefined {
1650
+ return this.target;
1651
+ }
1652
+
1653
+ get isolatedSignatureType(): Type | undefined {
1654
+ const extra = this.extra;
1655
+ return extra !== undefined ? extra.isolatedSignatureType : undefined;
1656
+ }
1657
+
1658
+ set isolatedSignatureType(t: Type | undefined) {
1659
+ if (t !== undefined || this.extra !== undefined) signatureExtra(this).isolatedSignatureType = t;
1660
+ }
1661
+
1662
+ get composite(): CompositeSignature | undefined {
1663
+ const extra = this.extra;
1664
+ return extra !== undefined ? extra.composite : undefined;
1665
+ }
1666
+
1667
+ set composite(composite: CompositeSignature | undefined) {
1668
+ if (composite !== undefined || this.extra !== undefined) signatureExtra(this).composite = composite;
1669
+ }
1670
+
1671
+ /** Caches of derived signatures. */
1672
+ get erasedSignatureCache(): Signature | undefined {
1673
+ const extra = this.extra;
1674
+ return extra !== undefined ? extra.erasedSignatureCache : undefined;
1675
+ }
1676
+
1677
+ set erasedSignatureCache(s: Signature | undefined) {
1678
+ if (s !== undefined || this.extra !== undefined) signatureExtra(this).erasedSignatureCache = s;
1679
+ }
1680
+
1681
+ get canonicalSignatureCache(): Signature | undefined {
1682
+ const extra = this.extra;
1683
+ return extra !== undefined ? extra.canonicalSignatureCache : undefined;
1684
+ }
1685
+
1686
+ set canonicalSignatureCache(s: Signature | undefined) {
1687
+ if (s !== undefined || this.extra !== undefined) signatureExtra(this).canonicalSignatureCache = s;
1688
+ }
1689
+
1690
+ get baseSignatureCache(): Signature | undefined {
1691
+ const extra = this.extra;
1692
+ return extra !== undefined ? extra.baseSignatureCache : undefined;
1693
+ }
1694
+
1695
+ set baseSignatureCache(s: Signature | undefined) {
1696
+ if (s !== undefined || this.extra !== undefined) signatureExtra(this).baseSignatureCache = s;
1697
+ }
1698
+
1699
+ get optionalCallSignatureCache(): Signature | undefined {
1700
+ const extra = this.extra;
1701
+ return extra !== undefined ? extra.optionalCallSignatureCache : undefined;
1702
+ }
1703
+
1704
+ set optionalCallSignatureCache(s: Signature | undefined) {
1705
+ if (s !== undefined || this.extra !== undefined) signatureExtra(this).optionalCallSignatureCache = s;
1706
+ }
1707
+
1708
+ get instantiations(): TypeListCache<Signature> | undefined {
1709
+ const extra = this.extra;
1710
+ return extra !== undefined ? extra.instantiations : undefined;
1711
+ }
1712
+
1713
+ set instantiations(instantiations: TypeListCache<Signature> | undefined) {
1714
+ if (instantiations !== undefined || this.extra !== undefined) signatureExtra(this).instantiations = instantiations;
1715
+ }
1716
+
1717
+ hasRestParameter(): boolean {
1718
+ return (this.flags & SignatureFlags.HasRestParameter) !== 0;
1719
+ }
1720
+ }
1721
+
1722
+ export class IndexInfo implements ProgramLifetime {
1723
+ readonly keyType: Type;
1724
+ readonly valueType: Type;
1725
+ readonly isReadonly: boolean;
1726
+ /** The IndexSignatureDeclaration. */
1727
+ readonly declaration: Node | undefined;
1728
+ /** Elements with computed property names that make up the index signature. */
1729
+ readonly components: Node[];
1730
+ indexSymbol: Symbol | undefined;
1731
+
1732
+ constructor(keyType: Type, valueType: Type, isReadonly: boolean, declaration: Node | undefined, components: Node[]) {
1733
+ this.keyType = keyType;
1734
+ this.valueType = valueType;
1735
+ this.isReadonly = isReadonly;
1736
+ this.declaration = declaration;
1737
+ this.components = components;
1738
+ this.indexSymbol = undefined;
1739
+ }
1740
+
1741
+ /** The value type (TypeScript 7's API). */
1742
+ get type(): Type {
1743
+ return this.valueType;
1744
+ }
1745
+ }
1746
+
1747
+ // Shared empty lists; never mutated.
1748
+ export const emptyTypes: Type[] = [];
1749
+ export const emptySymbols: Symbol[] = [];
1750
+ export const emptySignatures: Signature[] = [];
1751
+ export const emptyIndexInfos: IndexInfo[] = [];
1752
+
1753
+ // ---- Mappers
1754
+
1755
+ export const enum TypeMapperKind {
1756
+ Unknown = 0,
1757
+ Simple = 1,
1758
+ Array = 2,
1759
+ Merged = 3,
1760
+ }
1761
+
1762
+ /** Maps type parameters to types. Subclasses replace tsgo's function mappers. */
1763
+ export abstract class TypeMapper {
1764
+ abstract map(type: Type): Type;
1765
+
1766
+ kind(): TypeMapperKind {
1767
+ return TypeMapperKind.Unknown;
1768
+ }
1769
+
1770
+ /** Whether the mapper only maps a `this` type parameter. */
1771
+ mapsThisOnly(): boolean {
1772
+ return false;
1773
+ }
1774
+ }
1775
+
1776
+ function isThisTypeParameter(type: Type): boolean {
1777
+ return (type.flags & TypeFlags.TypeParameter) !== 0 && (type as TypeParameter).isThisType;
1778
+ }
1779
+
1780
+ export class SimpleTypeMapper extends TypeMapper {
1781
+ readonly source: Type;
1782
+ readonly target: Type;
1783
+
1784
+ constructor(source: Type, target: Type) {
1785
+ super();
1786
+ this.source = source;
1787
+ this.target = target;
1788
+ }
1789
+
1790
+ map(type: Type): Type {
1791
+ return type === this.source ? this.target : type;
1792
+ }
1793
+
1794
+ kind(): TypeMapperKind {
1795
+ return TypeMapperKind.Simple;
1796
+ }
1797
+
1798
+ mapsThisOnly(): boolean {
1799
+ return isThisTypeParameter(this.source);
1800
+ }
1801
+ }
1802
+
1803
+ export class ArrayTypeMapper extends TypeMapper {
1804
+ readonly sources: Type[];
1805
+ readonly targets: Type[];
1806
+
1807
+ constructor(sources: Type[], targets: Type[]) {
1808
+ super();
1809
+ this.sources = sources;
1810
+ this.targets = targets;
1811
+ }
1812
+
1813
+ map(type: Type): Type {
1814
+ const sources = this.sources;
1815
+ for (let i = 0; i < sources.length; i++) if (type === sources[i]!) return this.targets[i]!;
1816
+ return type;
1817
+ }
1818
+
1819
+ kind(): TypeMapperKind {
1820
+ return TypeMapperKind.Array;
1821
+ }
1822
+
1823
+ mapsThisOnly(): boolean {
1824
+ return this.sources.length === 1 && isThisTypeParameter(this.sources[0]!);
1825
+ }
1826
+
1827
+ /** The number of targets, one per source. */
1828
+ targetCount(): number {
1829
+ return this.targets.length;
1830
+ }
1831
+
1832
+ /** The target of the source at `index`. */
1833
+ targetAt(index: number): Type {
1834
+ return this.targets[index]!;
1835
+ }
1836
+ }
1837
+
1838
+ /**
1839
+ * The mapper of a type reference's members: its type arguments, then the reference itself for the
1840
+ * last source, the class or interface's `this` type. `targets` holds the type arguments only, so the
1841
+ * reference's own list serves without a copy that adds the reference.
1842
+ */
1843
+ export class ThisArgumentTypeMapper extends ArrayTypeMapper {
1844
+ readonly thisTarget: Type;
1845
+
1846
+ constructor(sources: Type[], typeArguments: Type[], thisTarget: Type) {
1847
+ super(sources, typeArguments);
1848
+ this.thisTarget = thisTarget;
1849
+ }
1850
+
1851
+ map(type: Type): Type {
1852
+ const sources = this.sources;
1853
+ const last = sources.length - 1;
1854
+ for (let i = 0; i < last; i++) if (type === sources[i]!) return this.targets[i]!;
1855
+ return type === sources[last]! ? this.thisTarget : type;
1856
+ }
1857
+
1858
+ targetCount(): number {
1859
+ return this.targets.length + 1;
1860
+ }
1861
+
1862
+ targetAt(index: number): Type {
1863
+ return index < this.targets.length ? this.targets[index]! : this.thisTarget;
1864
+ }
1865
+ }
1866
+
1867
+ /**
1868
+ * The number of sources from which a mapper looks types up in an index. A tuple reference with thousands of
1869
+ * elements maps one type parameter per element, and searching them all for each element was quadratic in the
1870
+ * tuple's length.
1871
+ */
1872
+ const indexedTypeMapperThreshold = 64;
1873
+
1874
+ /** An ArrayTypeMapper that looks its sources up in an index, built on its first lookup. */
1875
+ export class IndexedArrayTypeMapper extends ArrayTypeMapper {
1876
+ /** The index of each source's first occurrence. */
1877
+ index: Map<Type, number> | undefined = undefined;
1878
+ /** The number of sources `index` was built from. */
1879
+ indexedLength = 0;
1880
+
1881
+ map(type: Type): Type {
1882
+ const sources = this.sources;
1883
+ let index = this.index;
1884
+ if (index === undefined || this.indexedLength !== sources.length) {
1885
+ index = new Map<Type, number>();
1886
+ for (let i = 0; i < sources.length; i++) if (!index.has(sources[i]!)) index.set(sources[i]!, i);
1887
+ this.index = index;
1888
+ this.indexedLength = sources.length;
1889
+ }
1890
+ const i = index.get(type);
1891
+ return i !== undefined ? this.targets[i]! : type;
1892
+ }
1893
+ }
1894
+
1895
+ /** Maps each of `sources` to one target. */
1896
+ export class ArrayToSingleTypeMapper extends TypeMapper {
1897
+ readonly sources: Type[];
1898
+ readonly target: Type;
1899
+
1900
+ constructor(sources: Type[], target: Type) {
1901
+ super();
1902
+ this.sources = sources;
1903
+ this.target = target;
1904
+ }
1905
+
1906
+ map(type: Type): Type {
1907
+ return this.sources.includes(type) ? this.target : type;
1908
+ }
1909
+
1910
+ mapsThisOnly(): boolean {
1911
+ return this.sources.length === 1 && isThisTypeParameter(this.sources[0]!);
1912
+ }
1913
+ }
1914
+
1915
+ /** Applies `m1`, then `m2`. */
1916
+ export class MergedTypeMapper extends TypeMapper {
1917
+ readonly m1: TypeMapper;
1918
+ readonly m2: TypeMapper;
1919
+
1920
+ constructor(m1: TypeMapper, m2: TypeMapper) {
1921
+ super();
1922
+ this.m1 = m1;
1923
+ this.m2 = m2;
1924
+ }
1925
+
1926
+ map(type: Type): Type {
1927
+ return this.m2.map(this.m1.map(type));
1928
+ }
1929
+
1930
+ kind(): TypeMapperKind {
1931
+ return TypeMapperKind.Merged;
1932
+ }
1933
+ }
1934
+
1935
+ export function newTypeMapper(sources: Type[], targets: Type[]): TypeMapper {
1936
+ if (sources.length === 1) return new SimpleTypeMapper(sources[0]!, targets[0]!);
1937
+ return sources.length >= indexedTypeMapperThreshold
1938
+ ? new IndexedArrayTypeMapper(sources, targets)
1939
+ : new ArrayTypeMapper(sources, targets);
1940
+ }
1941
+
1942
+ /** `newTypeMapper(sources, [...typeArguments, thisTarget])`, without building that list where it can. */
1943
+ export function newThisArgumentTypeMapper(sources: Type[], typeArguments: Type[], thisTarget: Type): TypeMapper {
1944
+ if (sources.length === 1) return new SimpleTypeMapper(sources[0]!, thisTarget);
1945
+ if (sources.length >= indexedTypeMapperThreshold) {
1946
+ const targets: Type[] = [];
1947
+ for (const t of typeArguments) targets.push(t);
1948
+ targets.push(thisTarget);
1949
+ return new IndexedArrayTypeMapper(sources, targets);
1950
+ }
1951
+ return new ThisArgumentTypeMapper(sources, typeArguments, thisTarget);
1952
+ }
1953
+
1954
+ export function mergeTypeMappers(m1: TypeMapper | undefined, m2: TypeMapper): TypeMapper {
1955
+ return m1 !== undefined ? new MergedTypeMapper(m1, m2) : m2;
1956
+ }
1957
+
1958
+ export function prependTypeMapping(source: Type, target: Type, mapper: TypeMapper | undefined): TypeMapper {
1959
+ const simple = new SimpleTypeMapper(source, target);
1960
+ return mapper === undefined ? simple : new MergedTypeMapper(simple, mapper);
1961
+ }
1962
+
1963
+ export function appendTypeMapping(mapper: TypeMapper | undefined, source: Type, target: Type): TypeMapper {
1964
+ const simple = new SimpleTypeMapper(source, target);
1965
+ return mapper === undefined ? simple : new MergedTypeMapper(mapper, simple);
1966
+ }
1967
+
1968
+ // ---- Links
1969
+
1970
+ /**
1971
+ * What the checker caches per symbol and rarely sets. Common values (the type, target, mapper, name type
1972
+ * and others) are columns of `Checker` instead; see link-tables.ts. The fields most links objects have
1973
+ * are fields of this class; the others are in a RareSymbolLinks object, created on the first write of
1974
+ * one of them, behind accessors.
1975
+ */
1976
+ export class SymbolLinks implements ProgramLifetime {
1977
+ /** Constituents of a deferred union/intersection property type. */
1978
+ deferralParent: Type | undefined;
1979
+ deferralConstituents: Type[] | undefined;
1980
+ immediateTarget: Symbol | undefined;
1981
+ aliasTarget: Symbol | undefined;
1982
+ resolvedExports: SymbolTable | undefined;
1983
+ resolvedMembers: SymbolTable | undefined;
1984
+ declaredType: Type | undefined;
1985
+ /** The other links, created on first write. */
1986
+ private rareLinks: RareSymbolLinks | undefined;
1987
+ functionOrConstructorChecked: boolean;
1988
+ aliasReferenced: boolean;
1989
+
1990
+ constructor() {
1991
+ this.deferralParent = undefined;
1992
+ this.deferralConstituents = undefined;
1993
+ this.functionOrConstructorChecked = false;
1994
+ this.immediateTarget = undefined;
1995
+ this.aliasTarget = undefined;
1996
+ this.aliasReferenced = false;
1997
+ this.resolvedExports = undefined;
1998
+ this.resolvedMembers = undefined;
1999
+ this.declaredType = undefined;
2000
+ this.rareLinks = undefined;
2001
+ }
2002
+
2003
+ private rare(): RareSymbolLinks {
2004
+ let rare = this.rareLinks;
2005
+ if (rare === undefined) {
2006
+ rare = new RareSymbolLinks();
2007
+ this.rareLinks = rare;
2008
+ }
2009
+ return rare;
2010
+ }
2011
+
2012
+ get writeType(): Type | undefined {
2013
+ const rare = this.rareLinks;
2014
+ return rare === undefined ? undefined : rare.writeType;
2015
+ }
2016
+
2017
+ set writeType(value: Type | undefined) {
2018
+ if (value === undefined && this.rareLinks === undefined) return;
2019
+ this.rare().writeType = value;
2020
+ }
2021
+
2022
+ get deferralWriteConstituents(): Type[] | undefined {
2023
+ const rare = this.rareLinks;
2024
+ return rare === undefined ? undefined : rare.deferralWriteConstituents;
2025
+ }
2026
+
2027
+ set deferralWriteConstituents(value: Type[] | undefined) {
2028
+ if (value === undefined && this.rareLinks === undefined) return;
2029
+ this.rare().deferralWriteConstituents = value;
2030
+ }
2031
+
2032
+ get typeOnlyDeclaration(): Node | undefined {
2033
+ const rare = this.rareLinks;
2034
+ return rare === undefined ? undefined : rare.typeOnlyDeclaration;
2035
+ }
2036
+
2037
+ set typeOnlyDeclaration(value: Node | undefined) {
2038
+ if (value === undefined && this.rareLinks === undefined) return;
2039
+ this.rare().typeOnlyDeclaration = value;
2040
+ }
2041
+
2042
+ get typeOnlyExportStarMap(): Map<string, Node> | undefined {
2043
+ const rare = this.rareLinks;
2044
+ return rare === undefined ? undefined : rare.typeOnlyExportStarMap;
2045
+ }
2046
+
2047
+ set typeOnlyExportStarMap(value: Map<string, Node> | undefined) {
2048
+ if (value === undefined && this.rareLinks === undefined) return;
2049
+ this.rare().typeOnlyExportStarMap = value;
2050
+ }
2051
+
2052
+ get exportsChecked(): boolean {
2053
+ const rare = this.rareLinks;
2054
+ return rare === undefined ? false : rare.exportsChecked;
2055
+ }
2056
+
2057
+ set exportsChecked(value: boolean) {
2058
+ if (value === false && this.rareLinks === undefined) return;
2059
+ this.rare().exportsChecked = value;
2060
+ }
2061
+
2062
+ get lateSymbol(): Symbol | undefined {
2063
+ const rare = this.rareLinks;
2064
+ return rare === undefined ? undefined : rare.lateSymbol;
2065
+ }
2066
+
2067
+ set lateSymbol(value: Symbol | undefined) {
2068
+ if (value === undefined && this.rareLinks === undefined) return;
2069
+ this.rare().lateSymbol = value;
2070
+ }
2071
+
2072
+ get typeParameters(): Type[] | undefined {
2073
+ const rare = this.rareLinks;
2074
+ return rare === undefined ? undefined : rare.typeParameters;
2075
+ }
2076
+
2077
+ set typeParameters(value: Type[] | undefined) {
2078
+ if (value === undefined && this.rareLinks === undefined) return;
2079
+ this.rare().typeParameters = value;
2080
+ }
2081
+
2082
+ get instantiations(): Map<string, Type> | undefined {
2083
+ const rare = this.rareLinks;
2084
+ return rare === undefined ? undefined : rare.instantiations;
2085
+ }
2086
+
2087
+ set instantiations(value: Map<string, Type> | undefined) {
2088
+ if (value === undefined && this.rareLinks === undefined) return;
2089
+ this.rare().instantiations = value;
2090
+ }
2091
+
2092
+ get interfaceChecked(): boolean {
2093
+ const rare = this.rareLinks;
2094
+ return rare === undefined ? false : rare.interfaceChecked;
2095
+ }
2096
+
2097
+ set interfaceChecked(value: boolean) {
2098
+ if (value === false && this.rareLinks === undefined) return;
2099
+ this.rare().interfaceChecked = value;
2100
+ }
2101
+
2102
+ get indexSignaturesChecked(): boolean {
2103
+ const rare = this.rareLinks;
2104
+ return rare === undefined ? false : rare.indexSignaturesChecked;
2105
+ }
2106
+
2107
+ set indexSignaturesChecked(value: boolean) {
2108
+ if (value === false && this.rareLinks === undefined) return;
2109
+ this.rare().indexSignaturesChecked = value;
2110
+ }
2111
+
2112
+ get typeParametersChecked(): boolean {
2113
+ const rare = this.rareLinks;
2114
+ return rare === undefined ? false : rare.typeParametersChecked;
2115
+ }
2116
+
2117
+ set typeParametersChecked(value: boolean) {
2118
+ if (value === false && this.rareLinks === undefined) return;
2119
+ this.rare().typeParametersChecked = value;
2120
+ }
2121
+
2122
+ get enumChecked(): boolean {
2123
+ const rare = this.rareLinks;
2124
+ return rare === undefined ? false : rare.enumChecked;
2125
+ }
2126
+
2127
+ set enumChecked(value: boolean) {
2128
+ if (value === false && this.rareLinks === undefined) return;
2129
+ this.rare().enumChecked = value;
2130
+ }
2131
+
2132
+ get variances(): VarianceFlags[] | undefined {
2133
+ const rare = this.rareLinks;
2134
+ return rare === undefined ? undefined : rare.variances;
2135
+ }
2136
+
2137
+ set variances(value: VarianceFlags[] | undefined) {
2138
+ if (value === undefined && this.rareLinks === undefined) return;
2139
+ this.rare().variances = value;
2140
+ }
2141
+
2142
+ get lastAssignmentPos(): number {
2143
+ const rare = this.rareLinks;
2144
+ return rare === undefined ? 0 : rare.lastAssignmentPos;
2145
+ }
2146
+
2147
+ set lastAssignmentPos(value: number) {
2148
+ if (value === 0 && this.rareLinks === undefined) return;
2149
+ this.rare().lastAssignmentPos = value;
2150
+ }
2151
+
2152
+ get hasDefiniteAssignment(): boolean {
2153
+ const rare = this.rareLinks;
2154
+ return rare === undefined ? false : rare.hasDefiniteAssignment;
2155
+ }
2156
+
2157
+ set hasDefiniteAssignment(value: boolean) {
2158
+ if (value === false && this.rareLinks === undefined) return;
2159
+ this.rare().hasDefiniteAssignment = value;
2160
+ }
2161
+
2162
+ get isConstructorDeclaredProperty(): boolean {
2163
+ const rare = this.rareLinks;
2164
+ return rare === undefined ? false : rare.isConstructorDeclaredProperty;
2165
+ }
2166
+
2167
+ set isConstructorDeclaredProperty(value: boolean) {
2168
+ if (value === false && this.rareLinks === undefined) return;
2169
+ this.rare().isConstructorDeclaredProperty = value;
2170
+ }
2171
+
2172
+ get thisAssignmentKind(): number {
2173
+ const rare = this.rareLinks;
2174
+ return rare === undefined ? 0 : rare.thisAssignmentKind;
2175
+ }
2176
+
2177
+ set thisAssignmentKind(value: number) {
2178
+ if (value === 0 && this.rareLinks === undefined) return;
2179
+ this.rare().thisAssignmentKind = value;
2180
+ }
2181
+
2182
+ get thisAssignmentLocation(): Node | undefined {
2183
+ const rare = this.rareLinks;
2184
+ return rare === undefined ? undefined : rare.thisAssignmentLocation;
2185
+ }
2186
+
2187
+ set thisAssignmentLocation(value: Node | undefined) {
2188
+ if (value === undefined && this.rareLinks === undefined) return;
2189
+ this.rare().thisAssignmentLocation = value;
2190
+ }
2191
+
2192
+ get reverseMappedPropertyType(): Type | undefined {
2193
+ const rare = this.rareLinks;
2194
+ return rare === undefined ? undefined : rare.reverseMappedPropertyType;
2195
+ }
2196
+
2197
+ set reverseMappedPropertyType(value: Type | undefined) {
2198
+ if (value === undefined && this.rareLinks === undefined) return;
2199
+ this.rare().reverseMappedPropertyType = value;
2200
+ }
2201
+
2202
+ get reverseMappedMappedType(): Type | undefined {
2203
+ const rare = this.rareLinks;
2204
+ return rare === undefined ? undefined : rare.reverseMappedMappedType;
2205
+ }
2206
+
2207
+ set reverseMappedMappedType(value: Type | undefined) {
2208
+ if (value === undefined && this.rareLinks === undefined) return;
2209
+ this.rare().reverseMappedMappedType = value;
2210
+ }
2211
+
2212
+ get reverseMappedConstraintType(): Type | undefined {
2213
+ const rare = this.rareLinks;
2214
+ return rare === undefined ? undefined : rare.reverseMappedConstraintType;
2215
+ }
2216
+
2217
+ set reverseMappedConstraintType(value: Type | undefined) {
2218
+ if (value === undefined && this.rareLinks === undefined) return;
2219
+ this.rare().reverseMappedConstraintType = value;
2220
+ }
2221
+ }
2222
+
2223
+ /** The links of a symbol that few symbols have (SymbolLinks). */
2224
+ export class RareSymbolLinks implements ProgramLifetime {
2225
+ // Values
2226
+ writeType: Type | undefined;
2227
+ deferralWriteConstituents: Type[] | undefined;
2228
+ typeOnlyDeclaration: Node | undefined;
2229
+ /** Exports reached only through `export type *`, by name. */
2230
+ typeOnlyExportStarMap: Map<string, Node> | undefined;
2231
+ exportsChecked: boolean;
2232
+ lateSymbol: Symbol | undefined;
2233
+ /** Type parameters of a type alias. */
2234
+ typeParameters: Type[] | undefined;
2235
+ /** Instantiations of a generic type alias. */
2236
+ instantiations: Map<string, Type> | undefined;
2237
+ interfaceChecked: boolean;
2238
+ indexSignaturesChecked: boolean;
2239
+ typeParametersChecked: boolean;
2240
+ enumChecked: boolean;
2241
+ variances: VarianceFlags[] | undefined;
2242
+ // Assignment tracking
2243
+ lastAssignmentPos: number;
2244
+ hasDefiniteAssignment: boolean;
2245
+ isConstructorDeclaredProperty: boolean;
2246
+ // JavaScript `this.x` assignment declarations
2247
+ /** A `ThisAssignmentKind` plus one; zero until computed. */
2248
+ thisAssignmentKind: number;
2249
+ thisAssignmentLocation: Node | undefined;
2250
+ // Reverse mapped properties
2251
+ reverseMappedPropertyType: Type | undefined;
2252
+ reverseMappedMappedType: Type | undefined;
2253
+ reverseMappedConstraintType: Type | undefined;
2254
+
2255
+ constructor() {
2256
+ this.writeType = undefined;
2257
+ this.deferralWriteConstituents = undefined;
2258
+ this.typeOnlyDeclaration = undefined;
2259
+ this.typeOnlyExportStarMap = undefined;
2260
+ this.exportsChecked = false;
2261
+ this.lateSymbol = undefined;
2262
+ this.typeParameters = undefined;
2263
+ this.instantiations = undefined;
2264
+ this.interfaceChecked = false;
2265
+ this.indexSignaturesChecked = false;
2266
+ this.typeParametersChecked = false;
2267
+ this.enumChecked = false;
2268
+ this.variances = undefined;
2269
+ this.lastAssignmentPos = 0;
2270
+ this.hasDefiniteAssignment = false;
2271
+ this.isConstructorDeclaredProperty = false;
2272
+ this.thisAssignmentKind = 0;
2273
+ this.thisAssignmentLocation = undefined;
2274
+ this.reverseMappedPropertyType = undefined;
2275
+ this.reverseMappedMappedType = undefined;
2276
+ this.reverseMappedConstraintType = undefined;
2277
+ }
2278
+ }
2279
+
2280
+ /**
2281
+ * What the checker caches per node and rarely sets. The resolved symbol, type and signature are columns of
2282
+ * `Checker` instead; see link-tables.ts. As in SymbolLinks, the fields few links objects have are in a
2283
+ * RareNodeLinks object behind accessors.
2284
+ */
2285
+ export class NodeLinks implements ProgramLifetime {
2286
+ /** Outer type parameters of an anonymous object type node. */
2287
+ outerTypeParameters: Type[] | undefined;
2288
+ effectsSignature: Signature | undefined;
2289
+ /** Type of an assertion's operand. */
2290
+ assertionExpressionType: Type | undefined;
2291
+ /** The other links, created on first write. */
2292
+ private rareLinks: RareNodeLinks | undefined;
2293
+ flags: NodeCheckFlags;
2294
+
2295
+ constructor() {
2296
+ this.flags = NodeCheckFlags.None;
2297
+ this.outerTypeParameters = undefined;
2298
+ this.effectsSignature = undefined;
2299
+ this.assertionExpressionType = undefined;
2300
+ this.rareLinks = undefined;
2301
+ }
2302
+
2303
+ private rare(): RareNodeLinks {
2304
+ let rare = this.rareLinks;
2305
+ if (rare === undefined) {
2306
+ rare = new RareNodeLinks();
2307
+ this.rareLinks = rare;
2308
+ }
2309
+ return rare;
2310
+ }
2311
+
2312
+ get contextFreeType(): Type | undefined {
2313
+ const rare = this.rareLinks;
2314
+ return rare === undefined ? undefined : rare.contextFreeType;
2315
+ }
2316
+
2317
+ set contextFreeType(value: Type | undefined) {
2318
+ if (value === undefined && this.rareLinks === undefined) return;
2319
+ this.rare().contextFreeType = value;
2320
+ }
2321
+
2322
+ get enumStringValue(): string {
2323
+ const rare = this.rareLinks;
2324
+ return rare === undefined ? '' : rare.enumStringValue;
2325
+ }
2326
+
2327
+ set enumStringValue(value: string) {
2328
+ if (value === '' && this.rareLinks === undefined) return;
2329
+ this.rare().enumStringValue = value;
2330
+ }
2331
+
2332
+ get enumNumberValue(): number {
2333
+ const rare = this.rareLinks;
2334
+ return rare === undefined ? 0 : rare.enumNumberValue;
2335
+ }
2336
+
2337
+ set enumNumberValue(value: number) {
2338
+ if (value === 0 && this.rareLinks === undefined) return;
2339
+ this.rare().enumNumberValue = value;
2340
+ }
2341
+
2342
+ get enumValueKind(): number {
2343
+ const rare = this.rareLinks;
2344
+ return rare === undefined ? 0 : rare.enumValueKind;
2345
+ }
2346
+
2347
+ set enumValueKind(value: number) {
2348
+ if (value === 0 && this.rareLinks === undefined) return;
2349
+ this.rare().enumValueKind = value;
2350
+ }
2351
+
2352
+ get enumValueFlags(): number {
2353
+ const rare = this.rareLinks;
2354
+ return rare === undefined ? 0 : rare.enumValueFlags;
2355
+ }
2356
+
2357
+ set enumValueFlags(value: number) {
2358
+ if (value === 0 && this.rareLinks === undefined) return;
2359
+ this.rare().enumValueFlags = value;
2360
+ }
2361
+
2362
+ get hasReportedStatementInAmbientContext(): boolean {
2363
+ const rare = this.rareLinks;
2364
+ return rare === undefined ? false : rare.hasReportedStatementInAmbientContext;
2365
+ }
2366
+
2367
+ set hasReportedStatementInAmbientContext(value: boolean) {
2368
+ if (value === false && this.rareLinks === undefined) return;
2369
+ this.rare().hasReportedStatementInAmbientContext = value;
2370
+ }
2371
+
2372
+ get declarationRequiresScopeChange(): number {
2373
+ const rare = this.rareLinks;
2374
+ return rare === undefined ? 0 : rare.declarationRequiresScopeChange;
2375
+ }
2376
+
2377
+ set declarationRequiresScopeChange(value: number) {
2378
+ if (value === 0 && this.rareLinks === undefined) return;
2379
+ this.rare().declarationRequiresScopeChange = value;
2380
+ }
2381
+
2382
+ get typeChecked(): boolean {
2383
+ const rare = this.rareLinks;
2384
+ return rare === undefined ? false : rare.typeChecked;
2385
+ }
2386
+
2387
+ set typeChecked(value: boolean) {
2388
+ if (value === false && this.rareLinks === undefined) return;
2389
+ this.rare().typeChecked = value;
2390
+ }
2391
+
2392
+ get deferredNodes(): Node[] | undefined {
2393
+ const rare = this.rareLinks;
2394
+ return rare === undefined ? undefined : rare.deferredNodes;
2395
+ }
2396
+
2397
+ set deferredNodes(value: Node[] | undefined) {
2398
+ if (value === undefined && this.rareLinks === undefined) return;
2399
+ this.rare().deferredNodes = value;
2400
+ }
2401
+
2402
+ get switchTypes(): Type[] | undefined {
2403
+ const rare = this.rareLinks;
2404
+ return rare === undefined ? undefined : rare.switchTypes;
2405
+ }
2406
+
2407
+ set switchTypes(value: Type[] | undefined) {
2408
+ if (value === undefined && this.rareLinks === undefined) return;
2409
+ this.rare().switchTypes = value;
2410
+ }
2411
+
2412
+ get switchWitnesses(): string[] | undefined {
2413
+ const rare = this.rareLinks;
2414
+ return rare === undefined ? undefined : rare.switchWitnesses;
2415
+ }
2416
+
2417
+ set switchWitnesses(value: string[] | undefined) {
2418
+ if (value === undefined && this.rareLinks === undefined) return;
2419
+ this.rare().switchWitnesses = value;
2420
+ }
2421
+
2422
+ get switchWitnessesValid(): boolean {
2423
+ const rare = this.rareLinks;
2424
+ return rare === undefined ? false : rare.switchWitnessesValid;
2425
+ }
2426
+
2427
+ set switchWitnessesValid(value: boolean) {
2428
+ if (value === false && this.rareLinks === undefined) return;
2429
+ this.rare().switchWitnessesValid = value;
2430
+ }
2431
+
2432
+ get exhaustiveState(): number {
2433
+ const rare = this.rareLinks;
2434
+ return rare === undefined ? 0 : rare.exhaustiveState;
2435
+ }
2436
+
2437
+ set exhaustiveState(value: number) {
2438
+ if (value === 0 && this.rareLinks === undefined) return;
2439
+ this.rare().exhaustiveState = value;
2440
+ }
2441
+
2442
+ get decoratorSignature(): Signature | undefined {
2443
+ const rare = this.rareLinks;
2444
+ return rare === undefined ? undefined : rare.decoratorSignature;
2445
+ }
2446
+
2447
+ set decoratorSignature(value: Signature | undefined) {
2448
+ if (value === undefined && this.rareLinks === undefined) return;
2449
+ this.rare().decoratorSignature = value;
2450
+ }
2451
+
2452
+ get containsArgumentsReference(): number {
2453
+ const rare = this.rareLinks;
2454
+ return rare === undefined ? 0 : rare.containsArgumentsReference;
2455
+ }
2456
+
2457
+ set containsArgumentsReference(value: number) {
2458
+ if (value === 0 && this.rareLinks === undefined) return;
2459
+ this.rare().containsArgumentsReference = value;
2460
+ }
2461
+
2462
+ get mentionsArguments(): number {
2463
+ const rare = this.rareLinks;
2464
+ return rare === undefined ? 0 : rare.mentionsArguments;
2465
+ }
2466
+
2467
+ set mentionsArguments(value: number) {
2468
+ if (value === 0 && this.rareLinks === undefined) return;
2469
+ this.rare().mentionsArguments = value;
2470
+ }
2471
+ }
2472
+
2473
+ /** The links of a node that few nodes have (NodeLinks). */
2474
+ export class RareNodeLinks implements ProgramLifetime {
2475
+ /** Context-free type of an expression. */
2476
+ contextFreeType: Type | undefined;
2477
+ /** Enum member value: a string, or a number when `enumValueIsNumber`. */
2478
+ enumStringValue: string;
2479
+ enumNumberValue: number;
2480
+ enumValueKind: number;
2481
+ /** EvaluatedFlags of the enum member value. */
2482
+ enumValueFlags: number;
2483
+ hasReportedStatementInAmbientContext: boolean;
2484
+ declarationRequiresScopeChange: number;
2485
+ /** For source files: whether the file has been checked, and its nodes waiting for a deferred check. */
2486
+ typeChecked: boolean;
2487
+ deferredNodes: Node[] | undefined;
2488
+ /** Case clause types of a switch statement. */
2489
+ switchTypes: Type[] | undefined;
2490
+ /** `typeof` case texts of a switch statement; '' for default and duplicates. */
2491
+ switchWitnesses: string[] | undefined;
2492
+ switchWitnessesValid: boolean;
2493
+ /** 0 unknown, 1 computing, 2 not exhaustive, 3 exhaustive. */
2494
+ exhaustiveState: number;
2495
+ /** The signature the runtime calls a decorator of this declaration with. */
2496
+ decoratorSignature: Signature | undefined;
2497
+ /** Whether a function body references `arguments`: 0 until computed, 1 for no, 2 for yes. */
2498
+ containsArgumentsReference: number;
2499
+ /** For source files: whether the file has an identifier `arguments`: 0 until computed, 1 for no, 2 for yes. */
2500
+ mentionsArguments: number;
2501
+
2502
+ constructor() {
2503
+ this.contextFreeType = undefined;
2504
+ this.enumStringValue = '';
2505
+ this.enumNumberValue = 0;
2506
+ this.enumValueKind = 0;
2507
+ this.enumValueFlags = 0;
2508
+ this.hasReportedStatementInAmbientContext = false;
2509
+ this.declarationRequiresScopeChange = 0;
2510
+ this.typeChecked = false;
2511
+ this.deferredNodes = undefined;
2512
+ this.switchTypes = undefined;
2513
+ this.switchWitnesses = undefined;
2514
+ this.switchWitnessesValid = false;
2515
+ this.exhaustiveState = 0;
2516
+ this.decoratorSignature = undefined;
2517
+ this.containsArgumentsReference = 0;
2518
+ this.mentionsArguments = 0;
2519
+ }
2520
+ }