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,955 @@
1
+ // Types of value symbols: variables, parameters, properties, accessors, functions, classes,
2
+ // enums, modules and aliases; optionality and widening.
3
+ import { checkJsxAttribute } from './checker-jsx.js';
4
+ import { getTargetOfAliasDeclaration, resolveExternalModuleSymbol } from './checker-modules.js';
5
+ import { cachedTypeKey } from './checker-types.js';
6
+ import { getArguments, getInitializer, getName, getParameters, getType, getBody, getSymbol, getMembers, getDotDotDotToken, getElements, getExpression, getPostfixToken, getQuestionToken, getText, } from './ast.js';
7
+ import { declarationNameToString, findConstructorDeclaration, getCombinedModifierFlags, getCombinedNodeFlags, getNameOfDeclaration, getRootDeclaration, getSourceFileOfNode, hasStaticModifier, hasSyntacticModifier, isCatchClauseVariableDeclarationOrBindingElement, isJsonSourceFile, isTypeNodeKind, } from './binder-utilities.js';
8
+ import { identifierToKeywordKind } from './scanner.js';
9
+ import { createDiagnosticForNode } from './checker.js';
10
+ import { IndexInfo, } from './checker-types.js';
11
+ import { createAnonymousType, createTypeReference, getIntersectionType, getUnionType, getUnionTypeEx, getWidenedLiteralType, isArrayOrTupleType, isEmptyObjectType, newObjectType, removeType, filterType, typesOf, getTypeArguments, } from './checker-type-factory.js';
12
+ import { getDeclarationOfAliasSymbol, getParentOfSymbol, getSymbolFlags, getSymbolOfDeclaration, popTypeResolution, pushTypeResolution, reportCircularityError, resolveAlias, getGlobalTypeAliasSymbol, resolveName, getGlobalSymbol, } from './checker-symbols.js';
13
+ import { getBaseConstructorTypeOfClass, getDeclaredTypeOfClassOrInterface, getDeclaredTypeOfEnumMember, getDeclaredTypeOfSymbol, } from './checker-declared-types.js';
14
+ import { getESSymbolLikeTypeForNode, getTypeFromTypeNode, getTypeAliasInstantiation } from './checker-type-nodes.js';
15
+ import { getFlowTypeInConstructor, getFlowTypeInStaticBlocks, getTypeOfPropertyInBaseClass, } from './checker-classes.js';
16
+ import { instantiateType } from './instantiation.js';
17
+ import { getIndexInfosOfType, getPropertiesOfObjectType, getPropertiesOfType, getPropertyOfObjectType, isObjectLiteralType, keepPropertiesOnly, scannedLiteralPropertiesLimit, } from './checker-members.js';
18
+ import { typeToString, symbolToString } from './type-printer.js';
19
+ import { getTypeOfMappedSymbol, getIndexType } from './checker-type-operators.js';
20
+ import { getReturnTypeOfSignature, getSignatureFromDeclaration, getTypeOfParameter as getTypeOfParameterOfSignature, } from './checker-signatures.js';
21
+ import { getReturnTypeFromBody, getTypeOfObjectLiteralMethod, shouldReportErrorsFromWideningWithContextualSignature, } from './checker-functions.js';
22
+ import { getTypeOfReverseMappedSymbol } from './checker-inference.js';
23
+ import { checkDeclarationInitializer, getContextuallyTypedParameterType, getContextualThisParameterType, checkExpressionCached, checkExpressionEx, } from './checker-expressions.js';
24
+ import { checkPropertyAssignment, checkShorthandPropertyAssignment } from './checker-object-literals.js';
25
+ import { getTypeForBindingElement, getTypeFromBindingPattern } from './checker-destructuring.js';
26
+ import { checkRightHandSideOfForOf } from './checker-statements.js';
27
+ import { getTypeWithFacts, hasTypeFacts, getNonNullableType } from './checker-flow.js';
28
+ import { getTypeOfModuleExportsSymbol, getWidenedTypeForAssignmentDeclaration } from './checker-javascript.js';
29
+ import { copyDeclarations, getDeclarations, getSymbolId } from './symbol.js';
30
+ export function getTypeOfSymbol(c, symbol) {
31
+ const checkFlags = symbol.checkFlags;
32
+ if ((checkFlags & 65536 /* CheckFlags.DeferredType */) !== 0)
33
+ return getTypeOfSymbolWithDeferredType(c, symbol);
34
+ if ((checkFlags & 1 /* CheckFlags.Instantiated */) !== 0)
35
+ return getTypeOfInstantiatedSymbol(c, symbol);
36
+ if ((checkFlags & 262144 /* CheckFlags.Mapped */) !== 0)
37
+ return getTypeOfMappedSymbol(c, symbol);
38
+ if ((checkFlags & 8192 /* CheckFlags.ReverseMapped */) !== 0)
39
+ return getTypeOfReverseMappedSymbol(c, symbol);
40
+ const flags = symbol.flags;
41
+ if ((flags & 98304 /* SymbolFlags.Accessor */) !== 0)
42
+ return getTypeOfAccessors(c, symbol);
43
+ if ((flags & (3 /* SymbolFlags.Variable */ | 4 /* SymbolFlags.Property */)) !== 0)
44
+ return getTypeOfVariableOrParameterOrProperty(c, symbol);
45
+ if ((flags &
46
+ (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */)) !==
47
+ 0)
48
+ return getTypeOfFuncClassEnumModule(c, symbol);
49
+ if ((flags & 8 /* SymbolFlags.EnumMember */) !== 0)
50
+ return getTypeOfEnumMember(c, symbol);
51
+ if ((flags & 2097152 /* SymbolFlags.Alias */) !== 0)
52
+ return getTypeOfAlias(c, symbol);
53
+ return c.errorType;
54
+ }
55
+ export function getTypeOfParameter(c, symbol) {
56
+ return getTypeOfParameterOfSignature(c, symbol);
57
+ }
58
+ export function getNonMissingTypeOfSymbol(c, symbol) {
59
+ return removeMissingType(c, getTypeOfSymbol(c, symbol), (symbol.flags & 16777216 /* SymbolFlags.Optional */) !== 0);
60
+ }
61
+ function getTypeOfSymbolWithDeferredType(c, symbol) {
62
+ const links = c.symbolLinks(symbol);
63
+ const id = symbol.id;
64
+ if (c.symbolTypes.get(id) === undefined) {
65
+ const constituents = links.deferralConstituents;
66
+ c.symbolTypes.set(id, (links.deferralParent.flags & 134217728 /* TypeFlags.Union */) !== 0
67
+ ? getUnionType(c, constituents)
68
+ : getIntersectionType(c, constituents));
69
+ }
70
+ return c.symbolTypes.get(id);
71
+ }
72
+ function getWriteTypeOfSymbolWithDeferredType(c, symbol) {
73
+ const links = c.symbolLinks(symbol);
74
+ if (links.writeType === undefined) {
75
+ const constituents = links.deferralWriteConstituents;
76
+ if (constituents === undefined)
77
+ links.writeType = getTypeOfSymbolWithDeferredType(c, symbol);
78
+ else
79
+ links.writeType =
80
+ (links.deferralParent.flags & 134217728 /* TypeFlags.Union */) !== 0
81
+ ? getUnionType(c, constituents)
82
+ : getIntersectionType(c, constituents);
83
+ }
84
+ return links.writeType;
85
+ }
86
+ function getTypeOfInstantiatedSymbol(c, symbol) {
87
+ const id = getSymbolId(symbol);
88
+ let type = c.symbolTypes.get(id);
89
+ if (type === undefined) {
90
+ type = instantiateType(c, getTypeOfSymbol(c, c.symbolTargets.get(id)), c.symbolMappers.get(id));
91
+ c.symbolTypes.set(id, type);
92
+ }
93
+ return type;
94
+ }
95
+ export function getWriteTypeOfSymbol(c, symbol) {
96
+ if ((symbol.checkFlags & 2 /* CheckFlags.SyntheticProperty */) !== 0) {
97
+ if ((symbol.checkFlags & 65536 /* CheckFlags.DeferredType */) !== 0)
98
+ return getWriteTypeOfSymbolWithDeferredType(c, symbol);
99
+ const id = getSymbolId(symbol);
100
+ return c.symbolLinkTable.get(id)?.writeType ?? c.symbolTypes.get(id) ?? getTypeOfSymbol(c, symbol);
101
+ }
102
+ if ((symbol.flags & 4 /* SymbolFlags.Property */) !== 0)
103
+ return removeMissingType(c, getTypeOfSymbol(c, symbol), (symbol.flags & 16777216 /* SymbolFlags.Optional */) !== 0);
104
+ if ((symbol.flags & 98304 /* SymbolFlags.Accessor */) !== 0) {
105
+ if ((symbol.checkFlags & 1 /* CheckFlags.Instantiated */) !== 0) {
106
+ const links = c.symbolLinks(symbol);
107
+ const symbolId = symbol.id;
108
+ if (links.writeType === undefined)
109
+ links.writeType = instantiateType(c, getWriteTypeOfSymbol(c, c.symbolTargets.get(symbolId)), c.symbolMappers.get(symbolId));
110
+ return links.writeType;
111
+ }
112
+ return getWriteTypeOfAccessors(c, symbol);
113
+ }
114
+ return getTypeOfSymbol(c, symbol);
115
+ }
116
+ // ---- Variables, parameters and properties
117
+ function getTypeOfVariableOrParameterOrProperty(c, symbol) {
118
+ const id = getSymbolId(symbol);
119
+ const cached = c.symbolTypes.get(id);
120
+ if (cached !== undefined)
121
+ return cached;
122
+ const t = getTypeOfVariableOrParameterOrPropertyWorker(c, symbol);
123
+ // Contextually typed parameters may get their type later; don't cache theirs.
124
+ if (c.symbolTypes.get(id) === undefined && !isParameterOfContextSensitiveSignature(c, symbol))
125
+ c.symbolTypes.set(id, t);
126
+ return t;
127
+ }
128
+ function isParameterOfContextSensitiveSignature(c, symbol) {
129
+ let decl = symbol.valueDeclaration;
130
+ if (decl === undefined)
131
+ return false;
132
+ if (decl.kind === 209 /* SyntaxKind.BindingElement */)
133
+ decl = getRootDeclaration(decl);
134
+ return decl.kind === 170 /* SyntaxKind.Parameter */ && isContextSensitiveFunctionLikeLazy(c, decl.parent);
135
+ }
136
+ import { isContextSensitiveFunctionOrObjectLiteralMethod as isContextSensitiveFunctionLikeLazy } from './checker-expressions.js';
137
+ function getTypeOfVariableOrParameterOrPropertyWorker(c, symbol) {
138
+ if ((symbol.flags & 4194304 /* SymbolFlags.Prototype */) !== 0)
139
+ return getTypeOfPrototypeProperty(c, symbol);
140
+ if (symbol === c.requireSymbol)
141
+ return c.anyType;
142
+ const declaration = symbol.valueDeclaration;
143
+ if (declaration === undefined)
144
+ return c.errorType;
145
+ // The `export=` symbol of a JSON file has the type of its value.
146
+ if (declaration.kind === 307 /* SyntaxKind.SourceFile */ && isJsonSourceFile(declaration)) {
147
+ const statements = declaration.statements.nodes;
148
+ if (statements.length === 0)
149
+ return c.emptyObjectType;
150
+ return getWidenedType(c, getWidenedLiteralType(c, checkExpression(c, getExpression(statements[0]))));
151
+ }
152
+ if (!pushTypeResolution(c, symbol, 0 /* TypeSystemPropertyName.Type */))
153
+ return reportCircularityError(c, symbol);
154
+ // Like tsgo, the type resolution stays pushed: until popped by an enclosing resolution, its cached
155
+ // type ends cycle detection there, so aliases like `module.exports.b = module.exports.a` resolve.
156
+ if ((symbol.flags & 134217728 /* SymbolFlags.ModuleExports */) !== 0)
157
+ return getTypeOfModuleExportsSymbol(c, symbol);
158
+ let result;
159
+ switch (declaration.kind) {
160
+ case 170 /* SyntaxKind.Parameter */:
161
+ case 173 /* SyntaxKind.PropertyDeclaration */:
162
+ case 172 /* SyntaxKind.PropertySignature */:
163
+ case 261 /* SyntaxKind.VariableDeclaration */:
164
+ case 209 /* SyntaxKind.BindingElement */:
165
+ result = getWidenedTypeForVariableLikeDeclaration(c, declaration, true);
166
+ break;
167
+ case 303 /* SyntaxKind.PropertyAssignment */:
168
+ case 304 /* SyntaxKind.ShorthandPropertyAssignment */:
169
+ case 175 /* SyntaxKind.MethodDeclaration */:
170
+ // The declared symbol of an object literal member, as opposed to the checked literal's property.
171
+ if (declaration.kind === 303 /* SyntaxKind.PropertyAssignment */)
172
+ result = checkPropertyAssignment(c, declaration, 0 /* CheckMode.Normal */);
173
+ else if (declaration.kind === 304 /* SyntaxKind.ShorthandPropertyAssignment */)
174
+ result = checkShorthandPropertyAssignment(c, declaration, true, 0 /* CheckMode.Normal */);
175
+ else
176
+ result = getTypeOfObjectLiteralMethod(c, declaration, 0 /* CheckMode.Normal */);
177
+ break;
178
+ case 292 /* SyntaxKind.JsxAttribute */:
179
+ result = checkJsxAttribute(c, declaration, 0 /* CheckMode.Normal */);
180
+ break;
181
+ case 278 /* SyntaxKind.ExportAssignment */: {
182
+ const typeNode = getType(declaration);
183
+ result =
184
+ typeNode !== undefined
185
+ ? getTypeFromTypeNode(c, typeNode)
186
+ : widenTypeForVariableLikeDeclaration(c, checkExpressionCached(c, getExpression(declaration)), declaration, false);
187
+ break;
188
+ }
189
+ case 306 /* SyntaxKind.EnumMember */:
190
+ result = getTypeOfEnumMember(c, symbol);
191
+ break;
192
+ case 227 /* SyntaxKind.BinaryExpression */:
193
+ case 214 /* SyntaxKind.CallExpression */:
194
+ result = getWidenedTypeForAssignmentDeclaration(c, symbol);
195
+ break;
196
+ default:
197
+ result = c.anyType;
198
+ }
199
+ if (!popTypeResolution(c))
200
+ return reportCircularityError(c, symbol);
201
+ return result;
202
+ }
203
+ export function getWidenedTypeForVariableLikeDeclaration(c, declaration, reportErrors) {
204
+ return widenTypeForVariableLikeDeclaration(c, getTypeForVariableLikeDeclaration(c, declaration, true), declaration, reportErrors);
205
+ }
206
+ /** Whether a parameter, property or method is declared with `?`. */
207
+ export function isOptionalDeclaration(node) {
208
+ if (getQuestionToken(node) !== undefined)
209
+ return true;
210
+ // Properties and methods mark optionality with a `?` postfix token.
211
+ const postfix = getPostfixToken(node);
212
+ return postfix !== undefined && postfix.kind === 57 /* SyntaxKind.QuestionToken */;
213
+ }
214
+ function isEmptyArrayLiteral(node) {
215
+ return node.kind === 210 /* SyntaxKind.ArrayLiteralExpression */ && getElements(node).nodes.length === 0;
216
+ }
217
+ function isNullOrUndefined(node) {
218
+ let n = node;
219
+ while (n.kind === 218 /* SyntaxKind.ParenthesizedExpression */)
220
+ n = getExpression(n);
221
+ return n.kind === 105 /* SyntaxKind.NullKeyword */ || (n.kind === 79 /* SyntaxKind.Identifier */ && getText(n) === 'undefined');
222
+ }
223
+ function isBindingPattern(node) {
224
+ return (node !== undefined &&
225
+ (node.kind === 207 /* SyntaxKind.ObjectBindingPattern */ || node.kind === 208 /* SyntaxKind.ArrayBindingPattern */));
226
+ }
227
+ /** The declared or inferred type of a variable-like declaration; undefined when nothing can be inferred. */
228
+ export function getTypeForVariableLikeDeclaration(c, declaration, includeOptionality, checkMode = 0 /* CheckMode.Normal */) {
229
+ if (declaration.kind === 261 /* SyntaxKind.VariableDeclaration */) {
230
+ const grandParent = declaration.parent.parent;
231
+ if (grandParent.kind === 250 /* SyntaxKind.ForInStatement */) {
232
+ // `for (k in x)` declares k as string, or keyof T for generic x.
233
+ let objectType = checkExpressionEx(c, getExpression(grandParent), checkMode);
234
+ if (hasTypeFacts(c, objectType, 50331648 /* TypeFacts.IsUndefinedOrNull */))
235
+ objectType = getNonNullableType(c, objectType);
236
+ const indexType = getIndexType(c, objectType);
237
+ return (indexType.flags & (524288 /* TypeFlags.TypeParameter */ | 2097152 /* TypeFlags.Index */)) !== 0
238
+ ? getExtractStringType(c, indexType)
239
+ : c.stringType;
240
+ }
241
+ if (grandParent.kind === 251 /* SyntaxKind.ForOfStatement */)
242
+ return checkRightHandSideOfForOf(c, grandParent);
243
+ }
244
+ else if (declaration.kind === 209 /* SyntaxKind.BindingElement */)
245
+ return getTypeForBindingElement(c, declaration);
246
+ const isProperty = (declaration.kind === 173 /* SyntaxKind.PropertyDeclaration */ &&
247
+ (getCombinedModifierFlags(declaration) & 512 /* ModifierFlags.Accessor */) === 0) ||
248
+ declaration.kind === 172 /* SyntaxKind.PropertySignature */;
249
+ const isOptional = includeOptionality && isOptionalDeclaration(declaration);
250
+ const typeNode = getType(declaration);
251
+ const declaredType = typeNode !== undefined ? getTypeFromTypeNode(c, typeNode) : undefined;
252
+ if (isCatchClauseVariableDeclarationOrBindingElement(declaration)) {
253
+ if (declaredType !== undefined)
254
+ return (declaredType.flags & 3 /* TypeFlags.AnyOrUnknown */) !== 0 ? declaredType : c.errorType;
255
+ return c.useUnknownInCatchVariables ? c.unknownType : c.anyType;
256
+ }
257
+ if (declaredType !== undefined)
258
+ return addOptionality(c, declaredType, isProperty, isOptional);
259
+ if (c.noImplicitAny &&
260
+ declaration.kind === 261 /* SyntaxKind.VariableDeclaration */ &&
261
+ !isBindingPattern(getName(declaration)) &&
262
+ (getCombinedModifierFlags(declaration) & 32 /* ModifierFlags.Export */) === 0 &&
263
+ (declaration.flags & 8388608 /* NodeFlags.Ambient */) === 0) {
264
+ // Control-flow typed `any` for uninitialized or null/undefined-initialized let and var.
265
+ const initializer = getInitializer(declaration);
266
+ if ((getCombinedNodeFlags(declaration) & 6 /* NodeFlags.Constant */) === 0 &&
267
+ (initializer === undefined || isNullOrUndefined(initializer)))
268
+ return c.autoType;
269
+ if (initializer !== undefined && isEmptyArrayLiteral(initializer))
270
+ return c.autoArrayType;
271
+ }
272
+ if (declaration.kind === 170 /* SyntaxKind.Parameter */) {
273
+ if (getSymbol(declaration) === undefined)
274
+ return undefined;
275
+ const fn = declaration.parent;
276
+ // A set accessor parameter takes the getter's type.
277
+ if (fn.kind === 179 /* SyntaxKind.SetAccessor */) {
278
+ const fnSymbol = getSymbolOfDeclaration(c, fn);
279
+ const getter = fnSymbol !== undefined ? getDeclarations(fnSymbol).find((d) => d.kind === 178 /* SyntaxKind.GetAccessor */) : undefined;
280
+ if (getter !== undefined) {
281
+ const getterSignature = getSignatureFromDeclaration(c, getter);
282
+ // An unannotated `this` of a setter takes the getter's `this` type.
283
+ const params = getParameters(fn).nodes;
284
+ if (params.length === 2 && params[0] === declaration && getSymbol(declaration).name === 'this')
285
+ return getterSignature.thisParameter !== undefined
286
+ ? getTypeOfSymbol(c, getterSignature.thisParameter)
287
+ : c.anyType;
288
+ return getReturnTypeOfSignature(c, getterSignature);
289
+ }
290
+ }
291
+ const fullSignatureType = getParameterTypeOfFullSignature(c, fn, declaration);
292
+ if (fullSignatureType !== undefined)
293
+ return fullSignatureType;
294
+ const t = getSymbol(declaration).name === 'this'
295
+ ? getContextualThisParameterType(c, fn)
296
+ : getContextuallyTypedParameterType(c, declaration);
297
+ if (t !== undefined)
298
+ return addOptionality(c, t, false, isOptional);
299
+ }
300
+ const initializer = getInitializer(declaration);
301
+ if (initializer !== undefined) {
302
+ const t = widenTypeInferredFromInitializer(c, declaration, checkDeclarationInitializer(c, declaration, checkMode));
303
+ return addOptionality(c, t, isProperty, isOptional);
304
+ }
305
+ if (c.noImplicitAny && declaration.kind === 173 /* SyntaxKind.PropertyDeclaration */) {
306
+ // Without an annotation or initializer, the type comes from `this` assignments in the
307
+ // constructor or static blocks.
308
+ const symbol = getSymbol(declaration);
309
+ const isAmbient = hasSyntacticModifier(declaration, 128 /* ModifierFlags.Ambient */);
310
+ let t;
311
+ if (!hasStaticModifier(declaration)) {
312
+ const constructor = findConstructorDeclaration(declaration.parent);
313
+ if (constructor !== undefined)
314
+ t = getFlowTypeInConstructor(c, symbol, constructor);
315
+ else if (isAmbient)
316
+ t = getTypeOfPropertyInBaseClass(c, symbol);
317
+ }
318
+ else {
319
+ const staticBlocks = [];
320
+ for (const member of getMembers(declaration.parent).nodes)
321
+ if (member.kind === 176 /* SyntaxKind.ClassStaticBlockDeclaration */)
322
+ staticBlocks.push(member);
323
+ if (staticBlocks.length !== 0)
324
+ t = getFlowTypeInStaticBlocks(c, symbol, staticBlocks);
325
+ else if (isAmbient)
326
+ t = getTypeOfPropertyInBaseClass(c, symbol);
327
+ }
328
+ return t !== undefined ? addOptionality(c, t, true, isOptional) : undefined;
329
+ }
330
+ if (declaration.kind === 292 /* SyntaxKind.JsxAttribute */)
331
+ return c.trueType;
332
+ if (isBindingPattern(getName(declaration)))
333
+ return getTypeFromBindingPattern(c, getName(declaration), false, true);
334
+ return undefined;
335
+ }
336
+ export function widenTypeInferredFromInitializer(c, declaration, t) {
337
+ const widened = getWidenedLiteralTypeForInitializer(c, declaration, t);
338
+ // `null`, `undefined` and `[]` initializers in JavaScript are implicitly `any` and `any[]`.
339
+ if (isInJSFile(declaration)) {
340
+ if (widened === (c.strictNullChecks ? c.implicitNeverType : c.undefinedWideningType)) {
341
+ reportImplicitAny(c, declaration, c.anyType);
342
+ return c.anyType;
343
+ }
344
+ if (isEmptyArrayLiteralType(c, widened)) {
345
+ reportImplicitAny(c, declaration, c.anyArrayType);
346
+ return c.anyArrayType;
347
+ }
348
+ }
349
+ return widened;
350
+ }
351
+ export function getWidenedLiteralTypeForInitializer(c, declaration, t) {
352
+ if ((getCombinedNodeFlags(declaration) & 6 /* NodeFlags.Constant */) !== 0 || isDeclarationReadonly(declaration))
353
+ return t;
354
+ return getWidenedLiteralType(c, t);
355
+ }
356
+ function isDeclarationReadonly(declaration) {
357
+ return ((getCombinedModifierFlags(declaration) & 8 /* ModifierFlags.Readonly */) !== 0 && declaration.kind !== 170 /* SyntaxKind.Parameter */);
358
+ }
359
+ function isGlobalSymbolConstructor(c, node) {
360
+ const symbol = getSymbolOfDeclaration(c, node);
361
+ return symbol !== undefined && symbol === getGlobalSymbol(c, 'SymbolConstructor', 788968 /* SymbolFlags.Type */, undefined);
362
+ }
363
+ export function widenTypeForVariableLikeDeclaration(c, t, declaration, reportErrors) {
364
+ if (t !== undefined) {
365
+ // `symbol` properties merged into the global SymbolConstructor are unique symbols, as libraries
366
+ // that predate `unique symbol` declare them.
367
+ if ((t.flags & 512 /* TypeFlags.ESSymbol */) !== 0 && isGlobalSymbolConstructor(c, declaration.parent))
368
+ t = getESSymbolLikeTypeForNode(c, declaration);
369
+ if (reportErrors)
370
+ reportErrorsFromWidening(c, declaration, t, 0 /* WideningKind.Normal */);
371
+ // A unique symbol type from another declaration widens.
372
+ if ((t.flags & 16384 /* TypeFlags.UniqueESSymbol */) !== 0 &&
373
+ (declaration.kind === 209 /* SyntaxKind.BindingElement */ || getType(declaration) === undefined) &&
374
+ t.symbol !== getSymbolOfDeclaration(c, declaration))
375
+ t = c.esSymbolType;
376
+ return getWidenedType(c, t);
377
+ }
378
+ // Rest parameters default to any[], others to any.
379
+ const isRest = declaration.kind === 170 /* SyntaxKind.Parameter */ && getDotDotDotToken(declaration) !== undefined;
380
+ const result = isRest ? c.anyArrayType : c.anyType;
381
+ if (reportErrors && !declarationBelongsToPrivateAmbientMember(declaration))
382
+ reportImplicitAny(c, declaration, result);
383
+ return result;
384
+ }
385
+ export function declarationBelongsToPrivateAmbientMember(declaration) {
386
+ const root = getRootDeclaration(declaration);
387
+ const member = root.kind === 170 /* SyntaxKind.Parameter */ ? root.parent : root;
388
+ return isPrivateWithinAmbient(member);
389
+ }
390
+ export function isPrivateWithinAmbient(node) {
391
+ return (((getCombinedModifierFlags(node) & 2 /* ModifierFlags.Private */) !== 0 || isPrivateIdentifierClassElement(node)) &&
392
+ (node.flags & 8388608 /* NodeFlags.Ambient */) !== 0);
393
+ }
394
+ function isPrivateIdentifierClassElement(node) {
395
+ const name = getName(node);
396
+ return name !== undefined && name.kind === 80 /* SyntaxKind.PrivateIdentifier */;
397
+ }
398
+ /**
399
+ * Implicit-any widening of null/undefined, which strictNullChecks avoids. A function's inferred
400
+ * types report it only without a contextual signature, or when the contextual type is generic.
401
+ */
402
+ export function reportErrorsFromWidening(c, declaration, t, wideningKind) {
403
+ if (!c.noImplicitAny || (t.objectFlags & 65536 /* ObjectFlags.ContainsWideningType */) === 0)
404
+ return;
405
+ if (wideningKind !== 0 /* WideningKind.Normal */ &&
406
+ !(isFunctionLikeDeclarationKind(declaration.kind) &&
407
+ shouldReportErrorsFromWideningWithContextualSignature(c, declaration, wideningKind)))
408
+ return;
409
+ // Implicit any errors are reported within the type where possible, else on the declaration.
410
+ if (!reportWideningErrorsInType(c, t))
411
+ reportImplicitAny(c, declaration, t, wideningKind);
412
+ }
413
+ function reportWideningErrorsInType(c, t) {
414
+ let errorReported = false;
415
+ if ((t.objectFlags & 65536 /* ObjectFlags.ContainsWideningType */) === 0)
416
+ return false;
417
+ if ((t.flags & 134217728 /* TypeFlags.Union */) !== 0) {
418
+ if (someEmptyObjectType(c, typesOf(t)))
419
+ errorReported = true;
420
+ else
421
+ for (const s of typesOf(t))
422
+ errorReported = errorReported || reportWideningErrorsInType(c, s);
423
+ }
424
+ else if (isArrayOrTupleType(c, t)) {
425
+ for (const s of getTypeArguments(c, t))
426
+ errorReported = errorReported || reportWideningErrorsInType(c, s);
427
+ }
428
+ else if (isObjectLiteralType(t)) {
429
+ for (const p of getPropertiesOfObjectType(c, t)) {
430
+ const s = getTypeOfSymbol(c, p);
431
+ if ((s.objectFlags & 65536 /* ObjectFlags.ContainsWideningType */) === 0)
432
+ continue;
433
+ errorReported = reportWideningErrorsInType(c, s);
434
+ if (errorReported)
435
+ continue;
436
+ // Property types can come from object literal normalization in unions.
437
+ let valueDeclaration;
438
+ for (const d of getDeclarations(p)) {
439
+ const v = getSymbol(d)?.valueDeclaration;
440
+ if (v !== undefined && v.parent === t.symbol?.valueDeclaration) {
441
+ valueDeclaration = d;
442
+ break;
443
+ }
444
+ }
445
+ if (valueDeclaration !== undefined) {
446
+ c.error(valueDeclaration, 1690 /* Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type */, symbolToString(c, p), typeToString(c, getWidenedType(c, s)));
447
+ errorReported = true;
448
+ }
449
+ }
450
+ }
451
+ return errorReported;
452
+ }
453
+ export function reportImplicitAny(c, declaration, t, wideningKind = 0 /* WideningKind.Normal */) {
454
+ const file = getSourceFileOfNode(declaration);
455
+ // Only TypeScript files and checked JavaScript files report implicit `any`.
456
+ if (isInJSFile(declaration) && !isCheckJsEnabledForFile(file, c.compilerOptions))
457
+ return;
458
+ const typeAsString = typeToString(c, getWidenedType(c, t));
459
+ let message;
460
+ switch (declaration.kind) {
461
+ case 227 /* SyntaxKind.BinaryExpression */:
462
+ case 173 /* SyntaxKind.PropertyDeclaration */:
463
+ case 172 /* SyntaxKind.PropertySignature */:
464
+ message = c.noImplicitAny
465
+ ? 1680 /* Diagnostics.Member_0_implicitly_has_an_1_type */
466
+ : 1716 /* Diagnostics.Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage */;
467
+ break;
468
+ case 170 /* SyntaxKind.Parameter */: {
469
+ const isRest = getDotDotDotToken(declaration) !== undefined;
470
+ // `(string) => void` most likely meant a parameter of type `string`.
471
+ const name = getName(declaration);
472
+ const parent = declaration.parent;
473
+ if (name !== undefined &&
474
+ name.kind === 79 /* SyntaxKind.Identifier */ &&
475
+ (parent.kind === 180 /* SyntaxKind.CallSignature */ ||
476
+ parent.kind === 174 /* SyntaxKind.MethodSignature */ ||
477
+ parent.kind === 185 /* SyntaxKind.FunctionType */)) {
478
+ const index = getParameters(parent).nodes.indexOf(declaration);
479
+ const text = getText(name);
480
+ if (index >= 0 &&
481
+ (isTypeNodeKind(identifierToKeywordKind(text)) ||
482
+ resolveName(c, declaration, text, 788968 /* SymbolFlags.Type */, undefined, true, false) !== undefined)) {
483
+ c.addErrorOrSuggestion(c.noImplicitAny, createDiagnosticForNode(declaration, 1722 /* Diagnostics.Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1 */, [
484
+ 'arg' + index,
485
+ declarationNameToString(file, name) + (isRest ? '[]' : ''),
486
+ ]));
487
+ return;
488
+ }
489
+ }
490
+ if (isRest)
491
+ message = c.noImplicitAny
492
+ ? 1691 /* Diagnostics.Rest_parameter_0_implicitly_has_an_any_type */
493
+ : 1718 /* Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage */;
494
+ else
495
+ message = c.noImplicitAny
496
+ ? 1679 /* Diagnostics.Parameter_0_implicitly_has_an_1_type */
497
+ : 1715 /* Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage */;
498
+ break;
499
+ }
500
+ case 209 /* SyntaxKind.BindingElement */:
501
+ if (!c.noImplicitAny)
502
+ return;
503
+ message = 1702 /* Diagnostics.Binding_element_0_implicitly_has_an_1_type */;
504
+ break;
505
+ case 263 /* SyntaxKind.FunctionDeclaration */:
506
+ case 175 /* SyntaxKind.MethodDeclaration */:
507
+ case 174 /* SyntaxKind.MethodSignature */:
508
+ case 178 /* SyntaxKind.GetAccessor */:
509
+ case 179 /* SyntaxKind.SetAccessor */:
510
+ case 219 /* SyntaxKind.FunctionExpression */:
511
+ case 220 /* SyntaxKind.ArrowFunction */:
512
+ if (c.noImplicitAny && getName(declaration) === undefined) {
513
+ c.error(declaration, wideningKind === 3 /* WideningKind.GeneratorYield */
514
+ ? 1696 /* Diagnostics.Generator_implicitly_has_yield_type_0_Consider_supplying_a_return_type_annotation */
515
+ : 1683 /* Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type */, typeAsString);
516
+ return;
517
+ }
518
+ if (c.noImplicitAny && (declaration.flags & 8 /* NodeFlags.Reparsed */) !== 0) {
519
+ c.error(declaration, 1684 /* Diagnostics.This_overload_implicitly_returns_the_type_0_because_it_lacks_a_return_type_annotation */, typeAsString);
520
+ return;
521
+ }
522
+ if (!c.noImplicitAny)
523
+ message = 1721 /* Diagnostics.X_0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage */;
524
+ else if (wideningKind === 3 /* WideningKind.GeneratorYield */)
525
+ message = 1726 /* Diagnostics.X_0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type */;
526
+ else
527
+ message = 1682 /* Diagnostics.X_0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type */;
528
+ break;
529
+ case 201 /* SyntaxKind.MappedType */:
530
+ if (c.noImplicitAny)
531
+ c.error(declaration, 1710 /* Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type */);
532
+ return;
533
+ default:
534
+ message = c.noImplicitAny
535
+ ? 1678 /* Diagnostics.Variable_0_implicitly_has_an_1_type */
536
+ : 1714 /* Diagnostics.Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage */;
537
+ }
538
+ const name = getNameOfDeclaration(declaration);
539
+ c.addErrorOrSuggestion(c.noImplicitAny, createDiagnosticForNode(declaration, message, [declarationNameToString(file, name), typeAsString]));
540
+ }
541
+ // ---- Widening
542
+ export function getWidenedType(c, t) {
543
+ return getWidenedTypeWithContext(c, t, undefined);
544
+ }
545
+ /** Widening state for the constituents of a union: object literals get each other's missing properties. */
546
+ class WideningContext {
547
+ parent;
548
+ propertyName;
549
+ siblings;
550
+ resolvedProperties = undefined;
551
+ /** The contexts of the properties, by name, shared by the object literals widened in this one. */
552
+ childContexts = undefined;
553
+ /** The widened types of the object literals widened in this context, for child contexts. */
554
+ widenedTypes = undefined;
555
+ constructor(parent, propertyName, siblings) {
556
+ this.parent = parent;
557
+ this.propertyName = propertyName;
558
+ this.siblings = siblings;
559
+ }
560
+ getChildContext(propertyName) {
561
+ this.childContexts ??= new Map();
562
+ let result = this.childContexts.get(propertyName);
563
+ if (result === undefined) {
564
+ result = new WideningContext(this, propertyName, undefined);
565
+ this.childContexts.set(propertyName, result);
566
+ }
567
+ return result;
568
+ }
569
+ }
570
+ function getWidenedTypeWithContext(c, t, context) {
571
+ if ((t.objectFlags & 196608 /* ObjectFlags.RequiresWidening */) === 0)
572
+ return t;
573
+ const key = cachedTypeKey(13 /* CachedTypeKind.Widened */, t.id);
574
+ if (context === undefined) {
575
+ const cached = c.cachedTypesById.get(key);
576
+ if (cached !== undefined)
577
+ return cached;
578
+ }
579
+ let result;
580
+ if ((t.flags & (1 /* TypeFlags.Any */ | 12 /* TypeFlags.Nullable */)) !== 0)
581
+ result = c.anyType;
582
+ else if ((t.objectFlags & 128 /* ObjectFlags.ObjectLiteral */) !== 0 && (t.flags & 1048576 /* TypeFlags.Object */) !== 0)
583
+ result = getWidenedTypeOfObjectLiteral(c, t, context);
584
+ else if ((t.flags & 134217728 /* TypeFlags.Union */) !== 0) {
585
+ const unionContext = context ?? new WideningContext(undefined, '', typesOf(t));
586
+ const widened = [];
587
+ for (const u of typesOf(t))
588
+ widened.push((u.flags & 12 /* TypeFlags.Nullable */) !== 0 ? u : getWidenedTypeWithContext(c, u, unionContext));
589
+ // Widened empty object literals reduce subtypes, e.g. {} | string to {}.
590
+ result = getUnionTypeEx(c, widened, someEmptyObjectType(c, widened) ? 2 /* UnionReduction.Subtype */ : 1 /* UnionReduction.Literal */, undefined, undefined);
591
+ }
592
+ else if ((t.flags & 268435456 /* TypeFlags.Intersection */) !== 0)
593
+ result = getIntersectionType(c, getWidenedTypes(c, typesOf(t)));
594
+ else if (isArrayOrTupleType(c, t))
595
+ result = createTypeReference(c, t.target, getWidenedTypes(c, getTypeArguments(c, t)));
596
+ if (result !== undefined && context === undefined)
597
+ c.cachedTypesById.set(key, result);
598
+ return result ?? t;
599
+ }
600
+ function getWidenedTypes(c, types) {
601
+ const result = [];
602
+ for (const t of types)
603
+ result.push(getWidenedType(c, t));
604
+ return result;
605
+ }
606
+ function someEmptyObjectType(c, types) {
607
+ for (const t of types)
608
+ if (isEmptyObjectType(c, t))
609
+ return true;
610
+ return false;
611
+ }
612
+ function getWidenedTypeOfObjectLiteral(c, t, context) {
613
+ const cached = context?.widenedTypes?.get(t);
614
+ if (cached !== undefined)
615
+ return cached;
616
+ const members = new Map();
617
+ for (const prop of getPropertiesOfObjectType(c, t))
618
+ members.set(prop.name, getWidenedProperty(c, prop, context));
619
+ if (context !== undefined)
620
+ for (const prop of getPropertiesOfContext(c, context))
621
+ if (!members.has(prop.name))
622
+ members.set(prop.name, getUndefinedProperty(c, prop));
623
+ const infos = getIndexInfosOfType(c, t).map((info) => new IndexInfo(info.keyType, getWidenedType(c, info.valueType), info.isReadonly, info.declaration, info.components));
624
+ const result = createAnonymousType(c, t.symbol, members, [], [], infos);
625
+ keepPropertiesOnly(c, result, members, scannedLiteralPropertiesLimit);
626
+ result.objectFlags |= t.objectFlags & (4096 /* ObjectFlags.JSLiteral */ | 262144 /* ObjectFlags.NonInferrableType */);
627
+ // The root context widens each object literal once; a property's context may widen one literal
628
+ // for several siblings.
629
+ if (context !== undefined && context.parent !== undefined) {
630
+ context.widenedTypes ??= new Map();
631
+ context.widenedTypes.set(t, result);
632
+ }
633
+ return result;
634
+ }
635
+ function getWidenedProperty(c, prop, context) {
636
+ if ((prop.flags & 4 /* SymbolFlags.Property */) === 0)
637
+ return prop;
638
+ const original = getTypeOfSymbol(c, prop);
639
+ const propContext = context?.getChildContext(prop.name);
640
+ const widened = getWidenedTypeWithContext(c, original, propContext);
641
+ if (widened === original)
642
+ return prop;
643
+ return createSymbolWithWidenedType(c, prop, widened);
644
+ }
645
+ function createSymbolWithWidenedType(c, prop, t) {
646
+ const result = c.newSymbolWithCheckFlags(prop.flags, prop.name, prop.checkFlags & 8 /* CheckFlags.Readonly */);
647
+ copyDeclarations(result, prop);
648
+ result.parent = prop.parent;
649
+ result.valueDeclaration = prop.valueDeclaration;
650
+ const id = getSymbolId(result);
651
+ c.symbolTypes.set(id, t);
652
+ c.symbolTargets.set(id, prop);
653
+ c.symbolNameTypes.set(id, c.symbolNameTypes.get(getSymbolId(prop)));
654
+ return result;
655
+ }
656
+ /**
657
+ * An optional `undefined` property standing in for `prop`, a property of a sibling object literal
658
+ * (getPropertiesOfContext), one per property. It carries the declarations of `prop`, which order it
659
+ * among the members when they are printed.
660
+ */
661
+ function getUndefinedProperty(c, prop) {
662
+ const key = getSymbolId(prop);
663
+ const cached = c.undefinedProperties.get(key);
664
+ if (cached !== undefined)
665
+ return cached;
666
+ const result = createSymbolWithWidenedType(c, prop, c.undefinedOrMissingType);
667
+ result.flags |= 16777216 /* SymbolFlags.Optional */;
668
+ c.undefinedProperties.set(key, result);
669
+ return result;
670
+ }
671
+ function getPropertiesOfContext(c, context) {
672
+ if (context.resolvedProperties === undefined) {
673
+ const names = new Map();
674
+ for (const t of getSiblingsOfContext(c, context))
675
+ if ((t.objectFlags & 128 /* ObjectFlags.ObjectLiteral */) !== 0 &&
676
+ (t.flags & 1048576 /* TypeFlags.Object */) !== 0 &&
677
+ (t.objectFlags & 4194304 /* ObjectFlags.ContainsSpread */) === 0)
678
+ for (const prop of getPropertiesOfType(c, t))
679
+ names.set(prop.name, prop);
680
+ context.resolvedProperties = [...names.values()];
681
+ }
682
+ return context.resolvedProperties;
683
+ }
684
+ function getSiblingsOfContext(c, context) {
685
+ if (context.siblings === undefined) {
686
+ const siblings = [];
687
+ for (const t of getSiblingsOfContext(c, context.parent))
688
+ if ((t.objectFlags & 128 /* ObjectFlags.ObjectLiteral */) !== 0 && (t.flags & 1048576 /* TypeFlags.Object */) !== 0) {
689
+ const prop = getPropertyOfObjectType(c, t, context.propertyName);
690
+ if (prop !== undefined) {
691
+ const propType = getTypeOfSymbol(c, prop);
692
+ if ((propType.flags & 134217728 /* TypeFlags.Union */) !== 0)
693
+ for (const u of typesOf(propType))
694
+ siblings.push(u);
695
+ else
696
+ siblings.push(propType);
697
+ }
698
+ }
699
+ context.siblings = siblings;
700
+ }
701
+ return context.siblings;
702
+ }
703
+ // ---- Optionality
704
+ export function addOptionality(c, t, isProperty, isOptional) {
705
+ return c.strictNullChecks && isOptional ? getOptionalType(c, t, isProperty) : t;
706
+ }
707
+ export function getOptionalType(c, t, isProperty) {
708
+ const missingOrUndefined = isProperty ? c.undefinedOrMissingType : c.undefinedType;
709
+ if (t === missingOrUndefined || ((t.flags & 134217728 /* TypeFlags.Union */) !== 0 && typesOf(t)[0] === missingOrUndefined))
710
+ return t;
711
+ const key = cachedTypeKey(isProperty ? 17 /* CachedTypeKind.OptionalProperty */ : 16 /* CachedTypeKind.Optional */, t.id);
712
+ let result = c.cachedTypesById.get(key);
713
+ if (result === undefined) {
714
+ result = getUnionType(c, [t, missingOrUndefined]);
715
+ c.cachedTypesById.set(key, result);
716
+ }
717
+ return result;
718
+ }
719
+ export function addOptionalTypeMarker(c, t) {
720
+ return c.strictNullChecks ? getUnionType(c, [t, c.optionalType]) : t;
721
+ }
722
+ export function removeOptionalTypeMarker(c, t) {
723
+ return c.strictNullChecks ? removeType(c, t, c.optionalType) : t;
724
+ }
725
+ export function removeMissingType(c, t, isOptional) {
726
+ return c.exactOptionalPropertyTypes && isOptional ? removeType(c, t, c.missingType) : t;
727
+ }
728
+ export function removeMissingOrUndefinedType(c, t) {
729
+ return c.exactOptionalPropertyTypes ? removeType(c, t, c.missingType) : getTypeWithFacts(c, t, 524288 /* TypeFacts.NEUndefined */);
730
+ }
731
+ export function getNullableType(c, t, flags) {
732
+ const missing = flags & ~t.flags & (4 /* TypeFlags.Undefined */ | 8 /* TypeFlags.Null */);
733
+ if (missing === 0)
734
+ return t;
735
+ if (missing === 4 /* TypeFlags.Undefined */)
736
+ return getUnionType(c, [t, c.undefinedType]);
737
+ if (missing === 8 /* TypeFlags.Null */)
738
+ return getUnionType(c, [t, c.nullType]);
739
+ return getUnionType(c, [t, c.undefinedType, c.nullType]);
740
+ }
741
+ // ---- Readonly
742
+ export function isReadonlySymbol(c, symbol) {
743
+ // Readonly properties, const variables, getters without setters and enum members.
744
+ return ((symbol.checkFlags & 8 /* CheckFlags.Readonly */) !== 0 ||
745
+ ((symbol.flags & 4 /* SymbolFlags.Property */) !== 0 &&
746
+ (getDeclarationModifierFlags(c, symbol) & 8 /* ModifierFlags.Readonly */) !== 0) ||
747
+ ((symbol.flags & 3 /* SymbolFlags.Variable */) !== 0 &&
748
+ (getDeclarationNodeFlagsFromSymbol(symbol) & 6 /* NodeFlags.Constant */) !== 0) ||
749
+ ((symbol.flags & 98304 /* SymbolFlags.Accessor */) !== 0 && (symbol.flags & 65536 /* SymbolFlags.SetAccessor */) === 0) ||
750
+ (symbol.flags & 8 /* SymbolFlags.EnumMember */) !== 0 ||
751
+ someReadonlyAssignmentDeclaration(c, getDeclarations(symbol)));
752
+ }
753
+ function someReadonlyAssignmentDeclaration(c, declarations) {
754
+ for (const d of declarations)
755
+ if (isReadonlyAssignmentDeclaration(c, d))
756
+ return true;
757
+ return false;
758
+ }
759
+ /** An `Object.defineProperty` call with a value and no `writable: true`, or without a setter. */
760
+ function isReadonlyAssignmentDeclaration(c, node) {
761
+ if (node.kind !== 214 /* SyntaxKind.CallExpression */)
762
+ return false;
763
+ const args = getArguments(node);
764
+ if (args === undefined || args.nodes.length < 3)
765
+ return false;
766
+ const descriptorType = checkExpressionCached(c, args.nodes[2]);
767
+ if (getTypeOfPropertyOfType(c, descriptorType, 'value') !== undefined) {
768
+ const writable = getPropertyOfType(c, descriptorType, 'writable');
769
+ if (writable === undefined)
770
+ return true;
771
+ const declaration = writable.valueDeclaration;
772
+ const writableType = declaration !== undefined && declaration.kind === 303 /* SyntaxKind.PropertyAssignment */
773
+ ? checkExpression(c, getInitializer(declaration))
774
+ : getTypeOfSymbol(c, writable);
775
+ return writableType === c.falseType || writableType === c.regularFalseType;
776
+ }
777
+ return getTypeOfPropertyOfType(c, descriptorType, 'set') === undefined;
778
+ }
779
+ import { getDeclarationModifierFlagsFromSymbol, getPropertyOfType, getTypeOfPropertyOfType, } from './checker-members.js';
780
+ import { checkExpression } from './checker-expressions.js';
781
+ import { getParameterTypeOfFullSignature } from './checker-jsdoc.js';
782
+ import { isFunctionLikeDeclarationKind, isInJSFile } from './ast-utilities.js';
783
+ import { isEmptyArrayLiteralType } from './relations.js';
784
+ import { isCheckJsEnabledForFile } from './program-utilities.js';
785
+ function getDeclarationModifierFlags(c, symbol) {
786
+ return getDeclarationModifierFlagsFromSymbol(c, symbol, false);
787
+ }
788
+ function getDeclarationNodeFlagsFromSymbol(symbol) {
789
+ return symbol.valueDeclaration !== undefined ? getCombinedNodeFlags(symbol.valueDeclaration) : 0;
790
+ }
791
+ // ---- Accessors
792
+ export function getAnnotatedAccessorTypeNode(accessor) {
793
+ if (accessor === undefined)
794
+ return undefined;
795
+ if (accessor.kind === 178 /* SyntaxKind.GetAccessor */ || accessor.kind === 173 /* SyntaxKind.PropertyDeclaration */)
796
+ return getType(accessor);
797
+ if (accessor.kind === 179 /* SyntaxKind.SetAccessor */) {
798
+ const params = getParameters(accessor)?.nodes ?? [];
799
+ if (params.length === 0)
800
+ return undefined;
801
+ return getType(params.length === 2 ? params[1] : params[0]);
802
+ }
803
+ return undefined;
804
+ }
805
+ function getAnnotatedAccessorType(c, accessor) {
806
+ const node = getAnnotatedAccessorTypeNode(accessor);
807
+ return node !== undefined ? getTypeFromTypeNode(c, node) : undefined;
808
+ }
809
+ /** The `accessor` property declaration of `symbol`, if any. */
810
+ function getAutoAccessorDeclaration(symbol) {
811
+ for (const d of getDeclarations(symbol))
812
+ if (d.kind === 173 /* SyntaxKind.PropertyDeclaration */ && (getCombinedModifierFlags(d) & 512 /* ModifierFlags.Accessor */) !== 0)
813
+ return d;
814
+ return undefined;
815
+ }
816
+ function getTypeOfAccessors(c, symbol) {
817
+ const id = getSymbolId(symbol);
818
+ const type = c.symbolTypes.get(id);
819
+ if (type !== undefined)
820
+ return type;
821
+ if (!pushTypeResolution(c, symbol, 0 /* TypeSystemPropertyName.Type */))
822
+ return c.errorType;
823
+ const getter = getDeclarations(symbol).find((d) => d.kind === 178 /* SyntaxKind.GetAccessor */);
824
+ const setter = getDeclarations(symbol).find((d) => d.kind === 179 /* SyntaxKind.SetAccessor */);
825
+ const accessor = getAutoAccessorDeclaration(symbol);
826
+ // Getter annotation, setter annotation, accessor annotation, then getter body.
827
+ let t = getAnnotatedAccessorType(c, getter) ?? getAnnotatedAccessorType(c, setter) ?? getAnnotatedAccessorType(c, accessor);
828
+ if (t === undefined && getter !== undefined && getBody(getter) !== undefined)
829
+ t = getReturnTypeFromBody(c, getter);
830
+ if (t === undefined && accessor !== undefined)
831
+ t = getWidenedTypeForVariableLikeDeclaration(c, accessor, true);
832
+ if (t === undefined) {
833
+ if (setter !== undefined && !isPrivateWithinAmbient(setter))
834
+ c.addErrorOrSuggestion(c.noImplicitAny, createDiagnosticForNode(setter, 1703 /* Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation */, [symbolToString(c, symbol)]));
835
+ else if (getter !== undefined && !isPrivateWithinAmbient(getter))
836
+ c.addErrorOrSuggestion(c.noImplicitAny, createDiagnosticForNode(getter, 1704 /* Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation */, [symbolToString(c, symbol)]));
837
+ t = c.anyType;
838
+ }
839
+ if (!popTypeResolution(c)) {
840
+ if (getAnnotatedAccessorTypeNode(getter) !== undefined)
841
+ c.error(getter, 662 /* Diagnostics.X_0_is_referenced_directly_or_indirectly_in_its_own_type_annotation */, symbolToString(c, symbol));
842
+ else if (getAnnotatedAccessorTypeNode(setter) !== undefined)
843
+ c.error(setter, 662 /* Diagnostics.X_0_is_referenced_directly_or_indirectly_in_its_own_type_annotation */, symbolToString(c, symbol));
844
+ else if (getter !== undefined && c.noImplicitAny)
845
+ c.error(getter, 1694 /* Diagnostics.X_0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions */, symbolToString(c, symbol));
846
+ t = c.anyType;
847
+ }
848
+ let cached = c.symbolTypes.get(id);
849
+ if (cached === undefined) {
850
+ cached = t;
851
+ c.symbolTypes.set(id, cached);
852
+ }
853
+ return cached;
854
+ }
855
+ export function getWriteTypeOfAccessors(c, symbol) {
856
+ const links = c.symbolLinks(symbol);
857
+ if (links.writeType !== undefined)
858
+ return links.writeType;
859
+ if (!pushTypeResolution(c, symbol, 7 /* TypeSystemPropertyName.WriteType */))
860
+ return c.errorType;
861
+ const setter = getDeclarations(symbol).find((d) => d.kind === 179 /* SyntaxKind.SetAccessor */) ?? getAutoAccessorDeclaration(symbol);
862
+ let writeType = getAnnotatedAccessorType(c, setter);
863
+ if (!popTypeResolution(c)) {
864
+ if (getAnnotatedAccessorTypeNode(setter) !== undefined)
865
+ c.error(setter, 662 /* Diagnostics.X_0_is_referenced_directly_or_indirectly_in_its_own_type_annotation */, symbolToString(c, symbol));
866
+ writeType = c.anyType;
867
+ }
868
+ // Without a setter annotation, the write type is the read type.
869
+ if (links.writeType === undefined)
870
+ links.writeType = writeType ?? getTypeOfAccessors(c, symbol);
871
+ return links.writeType;
872
+ }
873
+ // ---- Functions, classes, enums, modules and aliases
874
+ function getTypeOfFuncClassEnumModule(c, symbol) {
875
+ const id = getSymbolId(symbol);
876
+ let type = c.symbolTypes.get(id);
877
+ if (type === undefined) {
878
+ type = getTypeOfFuncClassEnumModuleWorker(c, symbol);
879
+ c.symbolTypes.set(id, type);
880
+ }
881
+ return type;
882
+ }
883
+ function getTypeOfFuncClassEnumModuleWorker(c, symbol) {
884
+ if ((symbol.flags & 1536 /* SymbolFlags.Module */) !== 0 && isShorthandAmbientModuleSymbol(symbol))
885
+ return c.anyType;
886
+ if ((symbol.flags & 512 /* SymbolFlags.ValueModule */) !== 0 &&
887
+ symbol.valueDeclaration !== undefined &&
888
+ symbol.valueDeclaration.kind === 307 /* SyntaxKind.SourceFile */) {
889
+ const resolvedModule = resolveExternalModuleSymbol(c, symbol, false);
890
+ if (resolvedModule !== undefined && resolvedModule !== symbol)
891
+ return getTypeOfSymbol(c, resolvedModule);
892
+ }
893
+ const t = newObjectType(c, 16 /* ObjectFlags.Anonymous */, symbol);
894
+ if ((symbol.flags & 32 /* SymbolFlags.Class */) !== 0) {
895
+ const baseTypeVariable = getBaseTypeVariableOfClass(c, symbol);
896
+ return baseTypeVariable !== undefined ? getIntersectionType(c, [t, baseTypeVariable]) : t;
897
+ }
898
+ if (c.strictNullChecks && (symbol.flags & 16777216 /* SymbolFlags.Optional */) !== 0)
899
+ return getOptionalType(c, t, true);
900
+ return t;
901
+ }
902
+ function isShorthandAmbientModuleSymbol(symbol) {
903
+ const d = symbol.valueDeclaration;
904
+ return d !== undefined && d.kind === 268 /* SyntaxKind.ModuleDeclaration */ && getBody(d) === undefined;
905
+ }
906
+ export function getBaseTypeVariableOfClass(c, symbol) {
907
+ const baseConstructorType = getBaseConstructorTypeOfClass(c, getDeclaredTypeOfClassOrInterface(c, symbol));
908
+ if ((baseConstructorType.flags & 34078720 /* TypeFlags.TypeVariable */) !== 0)
909
+ return baseConstructorType;
910
+ if ((baseConstructorType.flags & 268435456 /* TypeFlags.Intersection */) !== 0)
911
+ return typesOf(baseConstructorType).find((t) => (t.flags & 34078720 /* TypeFlags.TypeVariable */) !== 0);
912
+ return undefined;
913
+ }
914
+ function getTypeOfEnumMember(c, symbol) {
915
+ const id = getSymbolId(symbol);
916
+ let type = c.symbolTypes.get(id);
917
+ if (type === undefined) {
918
+ type = getDeclaredTypeOfEnumMember(c, symbol);
919
+ c.symbolTypes.set(id, type);
920
+ }
921
+ return type;
922
+ }
923
+ function getTypeOfAlias(c, symbol) {
924
+ const id = getSymbolId(symbol);
925
+ const type = c.symbolTypes.get(id);
926
+ if (type !== undefined)
927
+ return type;
928
+ if (!pushTypeResolution(c, symbol, 0 /* TypeSystemPropertyName.Type */))
929
+ return c.errorType;
930
+ const targetSymbol = resolveAlias(c, symbol);
931
+ const exportSymbol = getTargetOfAliasDeclaration(c, getDeclarationOfAliasSymbol(symbol));
932
+ // Only values have types.
933
+ if (c.symbolTypes.get(id) === undefined)
934
+ c.symbolTypes.set(id, (getSymbolFlags(c, targetSymbol) & 111551 /* SymbolFlags.Value */) !== 0 ? getTypeOfSymbol(c, targetSymbol) : c.errorType);
935
+ if (!popTypeResolution(c)) {
936
+ reportCircularityError(c, exportSymbol ?? symbol);
937
+ if (c.symbolTypes.get(id) === undefined)
938
+ c.symbolTypes.set(id, c.errorType);
939
+ }
940
+ return c.symbolTypes.get(id);
941
+ }
942
+ function getTypeOfPrototypeProperty(c, prototype) {
943
+ // Every class has a `prototype` of its instance type with `any` type arguments.
944
+ const classType = getDeclaredTypeOfSymbol(c, getParentOfSymbol(c, prototype));
945
+ const typeParameters = classType.typeParameters();
946
+ return typeParameters.length !== 0
947
+ ? createTypeReference(c, classType, typeParameters.map(() => c.anyType))
948
+ : classType;
949
+ }
950
+ export { getDeclarationOfAliasSymbol, filterType, hasStaticModifier };
951
+ /** `Extract<t, string>`, or string without the global `Extract`. */
952
+ export function getExtractStringType(c, t) {
953
+ const extract = getGlobalTypeAliasSymbol(c, 'Extract', 2, true);
954
+ return extract !== undefined ? getTypeAliasInstantiation(c, extract, [t, c.stringType], undefined) : c.stringType;
955
+ }