tsc-ts 0.0.10 → 0.1.1

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 (379) hide show
  1. package/README.md +1 -1
  2. package/bin/tsc-ts.js +70 -1
  3. package/dist/api/compiler/ast-utilities.d.ts +19 -1
  4. package/dist/api/compiler/ast-utilities.js +180 -95
  5. package/dist/api/compiler/ast.d.ts +29 -18
  6. package/dist/api/compiler/ast.js +1040 -1007
  7. package/dist/api/compiler/astnav.js +15 -15
  8. package/dist/api/compiler/binder-utilities.js +186 -186
  9. package/dist/api/compiler/binder.js +290 -263
  10. package/dist/api/compiler/character-codes.js +2 -2
  11. package/dist/api/compiler/checker-calls.js +173 -123
  12. package/dist/api/compiler/checker-classes.d.ts +14 -3
  13. package/dist/api/compiler/checker-classes.js +136 -91
  14. package/dist/api/compiler/checker-contextual.d.ts +20 -0
  15. package/dist/api/compiler/checker-contextual.js +175 -62
  16. package/dist/api/compiler/checker-declaration-order.js +79 -79
  17. package/dist/api/compiler/checker-declarations.d.ts +1 -0
  18. package/dist/api/compiler/checker-declarations.js +160 -136
  19. package/dist/api/compiler/checker-declared-types.js +67 -65
  20. package/dist/api/compiler/checker-decorators.js +77 -77
  21. package/dist/api/compiler/checker-deprecation.d.ts +8 -3
  22. package/dist/api/compiler/checker-deprecation.js +76 -55
  23. package/dist/api/compiler/checker-destructuring.js +47 -45
  24. package/dist/api/compiler/checker-elaboration.js +24 -24
  25. package/dist/api/compiler/checker-emit-helpers.js +4 -4
  26. package/dist/api/compiler/checker-emit-resolver.d.ts +4 -2
  27. package/dist/api/compiler/checker-emit-resolver.js +25 -13
  28. package/dist/api/compiler/checker-evaluator.js +9 -9
  29. package/dist/api/compiler/checker-expressions.js +258 -212
  30. package/dist/api/compiler/checker-functions.js +113 -107
  31. package/dist/api/compiler/checker-generated-code.d.ts +0 -11
  32. package/dist/api/compiler/checker-generated-code.js +28 -52
  33. package/dist/api/compiler/checker-grammar.d.ts +1 -0
  34. package/dist/api/compiler/checker-grammar.js +469 -438
  35. package/dist/api/compiler/checker-heritage.js +91 -93
  36. package/dist/api/compiler/checker-inference.d.ts +77 -5
  37. package/dist/api/compiler/checker-inference.js +487 -113
  38. package/dist/api/compiler/checker-iteration.d.ts +0 -10
  39. package/dist/api/compiler/checker-iteration.js +35 -52
  40. package/dist/api/compiler/checker-javascript.js +14 -14
  41. package/dist/api/compiler/checker-jsdoc.d.ts +8 -10
  42. package/dist/api/compiler/checker-jsdoc.js +67 -58
  43. package/dist/api/compiler/checker-jsx.js +107 -89
  44. package/dist/api/compiler/checker-members.d.ts +9 -2
  45. package/dist/api/compiler/checker-members.js +210 -74
  46. package/dist/api/compiler/checker-modules.d.ts +15 -6
  47. package/dist/api/compiler/checker-modules.js +469 -309
  48. package/dist/api/compiler/checker-narrowing.js +273 -189
  49. package/dist/api/compiler/checker-object-literals.js +25 -22
  50. package/dist/api/compiler/checker-operators.js +126 -118
  51. package/dist/api/compiler/checker-overloads.js +27 -27
  52. package/dist/api/compiler/checker-property-access.js +59 -55
  53. package/dist/api/compiler/checker-services.d.ts +1 -0
  54. package/dist/api/compiler/checker-services.js +222 -210
  55. package/dist/api/compiler/checker-signatures.js +65 -49
  56. package/dist/api/compiler/checker-source-file.d.ts +5 -0
  57. package/dist/api/compiler/checker-source-file.js +154 -130
  58. package/dist/api/compiler/checker-statements.js +33 -32
  59. package/dist/api/compiler/checker-super.js +50 -50
  60. package/dist/api/compiler/checker-symbol-types.js +109 -93
  61. package/dist/api/compiler/checker-symbols.d.ts +13 -1
  62. package/dist/api/compiler/checker-symbols.js +264 -149
  63. package/dist/api/compiler/checker-type-factory.d.ts +5 -0
  64. package/dist/api/compiler/checker-type-factory.js +190 -46
  65. package/dist/api/compiler/checker-type-nodes.d.ts +1 -0
  66. package/dist/api/compiler/checker-type-nodes.js +179 -141
  67. package/dist/api/compiler/checker-type-operators.d.ts +2 -0
  68. package/dist/api/compiler/checker-type-operators.js +110 -63
  69. package/dist/api/compiler/checker-types.d.ts +80 -3
  70. package/dist/api/compiler/checker-types.js +121 -2
  71. package/dist/api/compiler/checker-unused.js +114 -118
  72. package/dist/api/compiler/checker-utilities.js +11 -11
  73. package/dist/api/compiler/checker.d.ts +97 -31
  74. package/dist/api/compiler/checker.js +149 -35
  75. package/dist/api/compiler/command-line.d.ts +1 -3
  76. package/dist/api/compiler/command-line.js +47 -44
  77. package/dist/api/compiler/compile-program.d.ts +24 -4
  78. package/dist/api/compiler/compile-program.js +53 -26
  79. package/dist/api/compiler/diagnostic-messages.d.ts +1849 -1774
  80. package/dist/api/compiler/diagnostic-messages.js +128 -122
  81. package/dist/api/compiler/diagnostics.js +7 -7
  82. package/dist/api/compiler/emitter.d.ts +7 -1
  83. package/dist/api/compiler/emitter.js +53 -11
  84. package/dist/api/compiler/expr-record.d.ts +11 -0
  85. package/dist/api/compiler/expr-record.js +53 -0
  86. package/dist/api/compiler/file-include.d.ts +2 -1
  87. package/dist/api/compiler/file-include.js +11 -7
  88. package/dist/api/compiler/file-loader.d.ts +10 -0
  89. package/dist/api/compiler/file-loader.js +138 -41
  90. package/dist/api/compiler/identifier-name.d.ts +9 -0
  91. package/dist/api/compiler/identifier-name.js +10 -0
  92. package/dist/api/compiler/instantiation.d.ts +7 -0
  93. package/dist/api/compiler/instantiation.js +101 -49
  94. package/dist/api/compiler/jsdoc.js +27 -25
  95. package/dist/api/compiler/link-tables.d.ts +48 -18
  96. package/dist/api/compiler/link-tables.js +80 -37
  97. package/dist/api/compiler/locales/cs-CZ.d.ts +1 -1
  98. package/dist/api/compiler/locales/cs-CZ.js +1 -1
  99. package/dist/api/compiler/locales/de-DE.d.ts +1 -1
  100. package/dist/api/compiler/locales/de-DE.js +1 -1
  101. package/dist/api/compiler/locales/es-ES.d.ts +1 -1
  102. package/dist/api/compiler/locales/es-ES.js +1 -1
  103. package/dist/api/compiler/locales/fr-FR.d.ts +1 -1
  104. package/dist/api/compiler/locales/fr-FR.js +1 -1
  105. package/dist/api/compiler/locales/it-IT.d.ts +1 -1
  106. package/dist/api/compiler/locales/it-IT.js +1 -1
  107. package/dist/api/compiler/locales/ja-JP.d.ts +1 -1
  108. package/dist/api/compiler/locales/ja-JP.js +1 -1
  109. package/dist/api/compiler/locales/ko-KR.d.ts +1 -1
  110. package/dist/api/compiler/locales/ko-KR.js +1 -1
  111. package/dist/api/compiler/locales/pl-PL.d.ts +1 -1
  112. package/dist/api/compiler/locales/pl-PL.js +1 -1
  113. package/dist/api/compiler/locales/pt-BR.d.ts +1 -1
  114. package/dist/api/compiler/locales/pt-BR.js +1 -1
  115. package/dist/api/compiler/locales/ru-RU.d.ts +1 -1
  116. package/dist/api/compiler/locales/ru-RU.js +1 -1
  117. package/dist/api/compiler/locales/tr-TR.d.ts +1 -1
  118. package/dist/api/compiler/locales/tr-TR.js +1 -1
  119. package/dist/api/compiler/locales/zh-CN.d.ts +1 -1
  120. package/dist/api/compiler/locales/zh-CN.js +1 -1
  121. package/dist/api/compiler/locales/zh-TW.d.ts +1 -1
  122. package/dist/api/compiler/locales/zh-TW.js +1 -1
  123. package/dist/api/compiler/module-resolution-types.js +6 -6
  124. package/dist/api/compiler/module-resolution.d.ts +10 -1
  125. package/dist/api/compiler/module-resolution.js +115 -84
  126. package/dist/api/compiler/module-specifiers.d.ts +15 -0
  127. package/dist/api/compiler/module-specifiers.js +24 -18
  128. package/dist/api/compiler/name-resolver.js +74 -65
  129. package/dist/api/compiler/node-builder-names.d.ts +11 -3
  130. package/dist/api/compiler/node-builder-names.js +210 -90
  131. package/dist/api/compiler/node-builder-pseudo.js +29 -31
  132. package/dist/api/compiler/node-builder-reuse.js +23 -22
  133. package/dist/api/compiler/node-builder.d.ts +18 -1
  134. package/dist/api/compiler/node-builder.js +191 -102
  135. package/dist/api/compiler/option-declarations.d.ts +2 -6
  136. package/dist/api/compiler/option-declarations.js +315 -375
  137. package/dist/api/compiler/options.d.ts +15 -33
  138. package/dist/api/compiler/options.js +21 -54
  139. package/dist/api/compiler/output-paths.d.ts +4 -1
  140. package/dist/api/compiler/output-paths.js +6 -11
  141. package/dist/api/compiler/package-json.d.ts +3 -3
  142. package/dist/api/compiler/package-json.js +11 -10
  143. package/dist/api/compiler/parser.d.ts +42 -20
  144. package/dist/api/compiler/parser.js +318 -224
  145. package/dist/api/compiler/path.d.ts +9 -0
  146. package/dist/api/compiler/path.js +20 -3
  147. package/dist/api/compiler/printer/emit-context.d.ts +3 -1
  148. package/dist/api/compiler/printer/emit-context.js +16 -1
  149. package/dist/api/compiler/printer/factory-base.d.ts +2 -2
  150. package/dist/api/compiler/printer/factory-base.js +7 -3
  151. package/dist/api/compiler/printer/factory.js +6 -3
  152. package/dist/api/compiler/printer/helpers.js +10 -1
  153. package/dist/api/compiler/printer/name-generator.d.ts +1 -1
  154. package/dist/api/compiler/printer/name-generator.js +35 -16
  155. package/dist/api/compiler/printer/printer.d.ts +1 -0
  156. package/dist/api/compiler/printer/printer.js +306 -283
  157. package/dist/api/compiler/printer/utilities.js +149 -147
  158. package/dist/api/compiler/program-checker.d.ts +8 -2
  159. package/dist/api/compiler/program-checker.js +84 -34
  160. package/dist/api/compiler/program-utilities.d.ts +3 -1
  161. package/dist/api/compiler/program-utilities.js +28 -15
  162. package/dist/api/compiler/program.d.ts +2 -0
  163. package/dist/api/compiler/program.js +69 -57
  164. package/dist/api/compiler/pseudo-bigint.d.ts +2 -0
  165. package/dist/api/compiler/pseudo-bigint.js +18 -0
  166. package/dist/api/compiler/regexp-checker.d.ts +1 -1
  167. package/dist/api/compiler/regexp-checker.js +93 -76
  168. package/dist/api/compiler/relations.d.ts +27 -4
  169. package/dist/api/compiler/relations.js +337 -180
  170. package/dist/api/compiler/reparser.js +64 -59
  171. package/dist/api/compiler/scanner.d.ts +27 -2
  172. package/dist/api/compiler/scanner.js +181 -150
  173. package/dist/api/compiler/shared-results.d.ts +696 -0
  174. package/dist/api/compiler/shared-results.js +2905 -0
  175. package/dist/api/compiler/sourcemap.js +2 -2
  176. package/dist/api/compiler/symbol-accessibility.js +87 -74
  177. package/dist/api/compiler/symbol.d.ts +22 -13
  178. package/dist/api/compiler/symbol.js +15 -1
  179. package/dist/api/compiler/syntax-kind.d.ts +198 -197
  180. package/dist/api/compiler/transformers/alias-references.js +247 -139
  181. package/dist/api/compiler/transformers/async-utilities.js +25 -25
  182. package/dist/api/compiler/transformers/async.d.ts +0 -1
  183. package/dist/api/compiler/transformers/async.js +64 -77
  184. package/dist/api/compiler/transformers/class-fields.d.ts +1 -0
  185. package/dist/api/compiler/transformers/class-fields.js +81 -78
  186. package/dist/api/compiler/transformers/commonjs-module.js +18 -15
  187. package/dist/api/compiler/transformers/const-enum-inliner.js +1 -1
  188. package/dist/api/compiler/transformers/declarations-diagnostics.js +247 -244
  189. package/dist/api/compiler/transformers/declarations-pseudo.js +100 -100
  190. package/dist/api/compiler/transformers/declarations-resolver.d.ts +0 -3
  191. package/dist/api/compiler/transformers/declarations-syntactic.d.ts +1 -2
  192. package/dist/api/compiler/transformers/declarations-syntactic.js +134 -156
  193. package/dist/api/compiler/transformers/declarations-tracker.js +18 -18
  194. package/dist/api/compiler/transformers/declarations.d.ts +4 -1
  195. package/dist/api/compiler/transformers/declarations.js +307 -239
  196. package/dist/api/compiler/transformers/decorator-metadata.d.ts +1 -1
  197. package/dist/api/compiler/transformers/decorator-metadata.js +53 -45
  198. package/dist/api/compiler/transformers/decorator-utilities.js +24 -24
  199. package/dist/api/compiler/transformers/destructuring.js +19 -18
  200. package/dist/api/compiler/transformers/emit-resolver.js +1 -1
  201. package/dist/api/compiler/transformers/es-decorators.js +55 -55
  202. package/dist/api/compiler/transformers/external-module-info.js +3 -3
  203. package/dist/api/compiler/transformers/for-await.js +25 -25
  204. package/dist/api/compiler/transformers/import-elision.js +14 -14
  205. package/dist/api/compiler/transformers/jsx.js +12 -12
  206. package/dist/api/compiler/transformers/legacy-decorators.js +17 -17
  207. package/dist/api/compiler/transformers/module.js +8 -8
  208. package/dist/api/compiler/transformers/named-evaluation.js +4 -4
  209. package/dist/api/compiler/transformers/object-rest-spread.js +20 -20
  210. package/dist/api/compiler/transformers/optional-chain.js +10 -10
  211. package/dist/api/compiler/transformers/reference-resolver.d.ts +12 -1
  212. package/dist/api/compiler/transformers/reference-resolver.js +131 -69
  213. package/dist/api/compiler/transformers/runtime-syntax.js +35 -31
  214. package/dist/api/compiler/transformers/subtree-facts.js +47 -47
  215. package/dist/api/compiler/transformers/syntax-facts.js +56 -58
  216. package/dist/api/compiler/transformers/type-eraser.js +73 -66
  217. package/dist/api/compiler/transformers/type-serialization.js +24 -24
  218. package/dist/api/compiler/transformers/using.js +12 -12
  219. package/dist/api/compiler/transformers/utilities.js +77 -77
  220. package/dist/api/compiler/transformers/visitor-base.js +172 -172
  221. package/dist/api/compiler/transformers/visitor-hooks.js +6 -2
  222. package/dist/api/compiler/tsconfig.d.ts +10 -2
  223. package/dist/api/compiler/tsconfig.js +136 -48
  224. package/dist/api/compiler/type-printer.js +40 -3
  225. package/dist/api/compiler/types.d.ts +2 -1
  226. package/dist/api/library/ast.generated.d.ts +42 -39
  227. package/dist/api/library/ast.generated.js +1 -1
  228. package/dist/api/library/compiler-options.generated.d.ts +111 -100
  229. package/dist/api/library/compiler-options.generated.js +1 -1
  230. package/dist/api/library/disk.js +12 -1
  231. package/dist/api/library/enums.generated.d.ts +206 -206
  232. package/dist/api/library/enums.generated.js +206 -206
  233. package/dist/api/library/nodes.js +26 -26
  234. package/package.json +9 -9
  235. package/src/compiler/ast-utilities.ts +99 -7
  236. package/src/compiler/ast.ts +74 -38
  237. package/src/compiler/binder.ts +39 -4
  238. package/src/compiler/cgroup.ts +157 -0
  239. package/src/compiler/character-codes.ts +2 -2
  240. package/src/compiler/checker-calls.ts +76 -8
  241. package/src/compiler/checker-classes.ts +80 -25
  242. package/src/compiler/checker-contextual.ts +110 -1
  243. package/src/compiler/checker-declarations.ts +31 -4
  244. package/src/compiler/checker-declared-types.ts +8 -5
  245. package/src/compiler/checker-decorators.ts +1 -1
  246. package/src/compiler/checker-deprecation.ts +29 -8
  247. package/src/compiler/checker-destructuring.ts +10 -3
  248. package/src/compiler/checker-emit-helpers.ts +1 -0
  249. package/src/compiler/checker-emit-resolver.ts +16 -6
  250. package/src/compiler/checker-expressions.ts +95 -47
  251. package/src/compiler/checker-functions.ts +21 -6
  252. package/src/compiler/checker-generated-code.ts +2 -22
  253. package/src/compiler/checker-grammar.ts +133 -60
  254. package/src/compiler/checker-heritage.ts +22 -21
  255. package/src/compiler/checker-inference.ts +514 -87
  256. package/src/compiler/checker-iteration.ts +18 -31
  257. package/src/compiler/checker-javascript.ts +1 -1
  258. package/src/compiler/checker-jsdoc.ts +50 -27
  259. package/src/compiler/checker-jsx.ts +28 -5
  260. package/src/compiler/checker-members.ts +197 -55
  261. package/src/compiler/checker-modules.ts +332 -65
  262. package/src/compiler/checker-narrowing.ts +98 -19
  263. package/src/compiler/checker-object-literals.ts +3 -0
  264. package/src/compiler/checker-operators.ts +11 -4
  265. package/src/compiler/checker-property-access.ts +7 -2
  266. package/src/compiler/checker-services.ts +39 -12
  267. package/src/compiler/checker-signatures.ts +15 -1
  268. package/src/compiler/checker-source-file.ts +39 -13
  269. package/src/compiler/checker-statements.ts +3 -2
  270. package/src/compiler/checker-symbol-types.ts +29 -6
  271. package/src/compiler/checker-symbols.ts +158 -15
  272. package/src/compiler/checker-type-factory.ts +173 -35
  273. package/src/compiler/checker-type-nodes.ts +46 -3
  274. package/src/compiler/checker-type-operators.ts +83 -26
  275. package/src/compiler/checker-types.ts +147 -4
  276. package/src/compiler/checker-unused.ts +9 -14
  277. package/src/compiler/checker.ts +175 -41
  278. package/src/compiler/command-line.ts +28 -28
  279. package/src/compiler/compile-program.ts +59 -25
  280. package/src/compiler/decoder.ts +15 -5
  281. package/src/compiler/diagnostic-messages.ts +1973 -1892
  282. package/src/compiler/doctor-report.ts +133 -0
  283. package/src/compiler/emitter.ts +57 -8
  284. package/src/compiler/encoder.ts +23 -8
  285. package/src/compiler/expr-record.ts +59 -0
  286. package/src/compiler/file-include.ts +9 -3
  287. package/src/compiler/file-loader.ts +139 -32
  288. package/src/compiler/help.ts +10 -14
  289. package/src/compiler/identifier-name.ts +13 -0
  290. package/src/compiler/incremental.ts +86 -18
  291. package/src/compiler/init.ts +2 -7
  292. package/src/compiler/instantiation.ts +77 -22
  293. package/src/compiler/jsdoc.ts +7 -3
  294. package/src/compiler/link-tables.ts +82 -37
  295. package/src/compiler/locales/cs-CZ.ts +1 -1
  296. package/src/compiler/locales/de-DE.ts +1 -1
  297. package/src/compiler/locales/es-ES.ts +1 -1
  298. package/src/compiler/locales/fr-FR.ts +1 -1
  299. package/src/compiler/locales/it-IT.ts +1 -1
  300. package/src/compiler/locales/ja-JP.ts +1 -1
  301. package/src/compiler/locales/ko-KR.ts +1 -1
  302. package/src/compiler/locales/pl-PL.ts +1 -1
  303. package/src/compiler/locales/pt-BR.ts +1 -1
  304. package/src/compiler/locales/ru-RU.ts +1 -1
  305. package/src/compiler/locales/tr-TR.ts +1 -1
  306. package/src/compiler/locales/zh-CN.ts +1 -1
  307. package/src/compiler/locales/zh-TW.ts +1 -1
  308. package/src/compiler/module-resolution.ts +44 -8
  309. package/src/compiler/module-specifiers.ts +62 -20
  310. package/src/compiler/name-resolver.ts +9 -1
  311. package/src/compiler/node-builder-names.ts +236 -54
  312. package/src/compiler/node-builder-pseudo.ts +4 -7
  313. package/src/compiler/node-builder-reuse.ts +5 -4
  314. package/src/compiler/node-builder.ts +130 -31
  315. package/src/compiler/option-declarations.ts +33 -103
  316. package/src/compiler/options.ts +23 -62
  317. package/src/compiler/output-paths.ts +5 -18
  318. package/src/compiler/package-entrypoints.ts +345 -0
  319. package/src/compiler/package-json.ts +4 -4
  320. package/src/compiler/parallel-check.ts +543 -147
  321. package/src/compiler/parallel-emit.ts +4 -4
  322. package/src/compiler/parser.ts +166 -47
  323. package/src/compiler/path.ts +22 -2
  324. package/src/compiler/printer/emit-context.ts +16 -0
  325. package/src/compiler/printer/factory-base.ts +10 -3
  326. package/src/compiler/printer/factory.ts +7 -3
  327. package/src/compiler/printer/helpers.ts +10 -1
  328. package/src/compiler/printer/name-generator.ts +24 -2
  329. package/src/compiler/printer/printer.ts +39 -16
  330. package/src/compiler/printer/utilities.ts +8 -2
  331. package/src/compiler/program-checker.ts +53 -5
  332. package/src/compiler/program-utilities.ts +23 -10
  333. package/src/compiler/program.ts +13 -1
  334. package/src/compiler/pseudo-bigint.ts +17 -0
  335. package/src/compiler/regexp-checker.ts +63 -30
  336. package/src/compiler/relations.ts +233 -77
  337. package/src/compiler/reparser.ts +14 -5
  338. package/src/compiler/run-config.ts +1383 -0
  339. package/src/compiler/run-record-read.ts +87 -0
  340. package/src/compiler/run-records.ts +575 -0
  341. package/src/compiler/scanner.ts +166 -120
  342. package/src/compiler/shared-results.ts +3144 -0
  343. package/src/compiler/show-config.ts +18 -1
  344. package/src/compiler/sourcemap.ts +2 -2
  345. package/src/compiler/symbol-accessibility.ts +26 -3
  346. package/src/compiler/symbol.ts +31 -14
  347. package/src/compiler/syntax-kind.ts +188 -187
  348. package/src/compiler/thread-entry.ts +22 -3
  349. package/src/compiler/transformers/alias-references.ts +123 -4
  350. package/src/compiler/transformers/async.ts +2 -17
  351. package/src/compiler/transformers/class-fields.ts +13 -12
  352. package/src/compiler/transformers/commonjs-module.ts +11 -7
  353. package/src/compiler/transformers/declarations-diagnostics.ts +5 -3
  354. package/src/compiler/transformers/declarations-pseudo.ts +2 -4
  355. package/src/compiler/transformers/declarations-resolver.ts +0 -3
  356. package/src/compiler/transformers/declarations-syntactic.ts +1 -21
  357. package/src/compiler/transformers/declarations.ts +136 -49
  358. package/src/compiler/transformers/decorator-metadata.ts +9 -1
  359. package/src/compiler/transformers/destructuring.ts +4 -3
  360. package/src/compiler/transformers/external-module-info.ts +1 -1
  361. package/src/compiler/transformers/jsx.ts +2 -1
  362. package/src/compiler/transformers/reference-resolver.ts +83 -19
  363. package/src/compiler/transformers/runtime-syntax.ts +6 -1
  364. package/src/compiler/transformers/syntax-facts.ts +2 -7
  365. package/src/compiler/transformers/type-eraser.ts +10 -1
  366. package/src/compiler/transformers/type-serialization.ts +3 -2
  367. package/src/compiler/transformers/visitor-base.ts +2 -1
  368. package/src/compiler/transformers/visitor-hooks.ts +9 -4
  369. package/src/compiler/tsc-build.ts +67 -6
  370. package/src/compiler/tsc-cli.ts +35 -4
  371. package/src/compiler/tsc-compile.ts +220 -10
  372. package/src/compiler/tsc-watch.ts +97 -47
  373. package/src/compiler/tsconfig.ts +176 -19
  374. package/src/compiler/type-printer.ts +36 -2
  375. package/src/compiler/types.ts +2 -1
  376. package/src/library/ast.generated.ts +57 -41
  377. package/src/library/compiler-options.generated.ts +117 -103
  378. package/src/library/disk.ts +10 -1
  379. package/src/library/enums.generated.ts +196 -196
@@ -50,6 +50,9 @@ import {
50
50
  newTypeMapper,
51
51
  SimpleTypeMapper,
52
52
  type TypeMapper,
53
+ isDistributedTypeParameter,
54
+ type TypeParameter,
55
+ type SymbolLinks,
53
56
  } from './checker-types.js';
54
57
  import { InferenceFlags, InferencePriority, createInferenceContext, inferTypes } from './checker-inference.js';
55
58
  import {
@@ -94,6 +97,7 @@ import {
94
97
  createNormalizedTypeReference,
95
98
  typeListKey,
96
99
  getRegularTypeOfLiteralType,
100
+ compareSymbols,
97
101
  } from './checker-type-factory.js';
98
102
  import {
99
103
  findApplicableIndexInfo,
@@ -236,9 +240,8 @@ export const enum RelationComparisonResult {
236
240
  ReportsUnmeasurable = 1 << 3,
237
241
  ReportsUnreliable = 1 << 4,
238
242
  ComplexityOverflow = 1 << 5,
239
- StackDepthOverflow = 1 << 6,
240
243
  ReportsMask = ReportsUnmeasurable | ReportsUnreliable,
241
- Overflow = ComplexityOverflow | StackDepthOverflow,
244
+ Overflow = ComplexityOverflow,
242
245
  }
243
246
 
244
247
  /**
@@ -263,25 +266,46 @@ export class Relation {
263
266
  }
264
267
  }
265
268
 
266
- set(key: number, result: number): void {
269
+ /** Sets the result of `key`, and returns whether the key is new. */
270
+ set(key: number, result: number): boolean {
267
271
  const keys = this.keys;
268
272
  const mask = keys.length - 1;
269
273
  for (let i = relationSlot(key) & mask; ; i = (i + 1) & mask) {
270
274
  const k = keys[i]!;
271
275
  if (k === key) {
272
276
  this.results[i] = result;
273
- return;
277
+ return false;
274
278
  }
275
279
  if (k === 0) {
276
280
  keys[i] = key;
277
281
  this.results[i] = result;
278
282
  this.count++;
279
283
  if (this.count * 4 > keys.length * 3) this.grow();
280
- return;
284
+ return true;
281
285
  }
282
286
  }
283
287
  }
284
288
 
289
+ /** Removes `key`, moving later entries of its probe run back so lookups still find them. */
290
+ delete(key: number): void {
291
+ const keys = this.keys;
292
+ const results = this.results;
293
+ const mask = keys.length - 1;
294
+ let i = relationSlot(key) & mask;
295
+ for (; keys[i] !== key; i = (i + 1) & mask) if (keys[i] === 0) return;
296
+ for (let j = (i + 1) & mask; keys[j] !== 0; j = (j + 1) & mask) {
297
+ // An entry stays where it is when its home slot is cyclically after the freed slot and at or before it.
298
+ const home = relationSlot(keys[j]!) & mask;
299
+ if (i <= j ? i < home && home <= j : i < home || home <= j) continue;
300
+ keys[i] = keys[j]!;
301
+ results[i] = results[j]!;
302
+ i = j;
303
+ }
304
+ keys[i] = 0;
305
+ results[i] = 0;
306
+ this.count--;
307
+ }
308
+
285
309
  size(): number {
286
310
  return this.count;
287
311
  }
@@ -1010,8 +1034,25 @@ export function checkTypeRelatedTo(
1010
1034
  // Nested checks (from resolving types during the relation) find no spare and allocate their own.
1011
1035
  const r = c.spareRelater ?? new Relater(c, relation, errorNode);
1012
1036
  c.spareRelater = undefined;
1037
+ const relationCount = Math.trunc((16000000 - relation.size()) / 8);
1038
+ if (errorNode !== undefined) {
1039
+ // Relate without reporting first: reporting builds a message for every comparison that fails on the way,
1040
+ // even when the relation holds. When the relation fails, the results this pass added are removed, since
1041
+ // the comparisons it assumed related while comparing would change which failure the report elaborates.
1042
+ r.reset(relation, undefined);
1043
+ r.relationCount = relationCount;
1044
+ const addedKeys: number[] = [];
1045
+ r.addedKeys = addedKeys;
1046
+ const quiet = r.isRelatedToEx(source, target, RecursionFlags.Both, false, undefined, IntersectionState.None);
1047
+ r.addedKeys = undefined;
1048
+ if (quiet !== Ternary.False && !r.overflow) {
1049
+ c.spareRelater = r;
1050
+ return true;
1051
+ }
1052
+ for (const key of addedKeys) relation.delete(key);
1053
+ }
1013
1054
  r.reset(relation, errorNode);
1014
- r.relationCount = Math.trunc((16000000 - relation.size()) / 8);
1055
+ r.relationCount = relationCount;
1015
1056
  const result = r.isRelatedToEx(
1016
1057
  source,
1017
1058
  target,
@@ -1023,20 +1064,13 @@ export function checkTypeRelatedTo(
1023
1064
  if (r.overflow) {
1024
1065
  // Remember the overflow so it isn't attempted again.
1025
1066
  const key = getRelationKey(c, source, target, IntersectionState.None, relation === c.identityRelation, false).key;
1026
- relation.set(
1027
- key,
1028
- RelationComparisonResult.Failed |
1029
- (r.relationCount <= 0
1030
- ? RelationComparisonResult.ComplexityOverflow
1031
- : RelationComparisonResult.StackDepthOverflow),
1032
- );
1033
- const message =
1034
- r.relationCount <= 0
1035
- ? Diagnostics.Excessive_complexity_comparing_types_0_and_1
1036
- : Diagnostics.Excessive_stack_depth_comparing_types_0_and_1;
1067
+ relation.set(key, RelationComparisonResult.Failed | RelationComparisonResult.ComplexityOverflow);
1037
1068
  reportDiagnostic(
1038
1069
  c,
1039
- createDiagnosticForNode(errorNode ?? c.currentNode, message, [typeToString(c, source), typeToString(c, target)]),
1070
+ createDiagnosticForNode(errorNode ?? c.currentNode, Diagnostics.Excessive_complexity_comparing_types_0_and_1, [
1071
+ typeToString(c, source),
1072
+ typeToString(c, target),
1073
+ ]),
1040
1074
  diagnosticOutput,
1041
1075
  );
1042
1076
  } else if (r.errorChain !== undefined) {
@@ -1150,6 +1184,8 @@ export class Relater extends TypeComparer {
1150
1184
  expandingFlags: ExpandingFlags = ExpandingFlags.None;
1151
1185
  overflow = false;
1152
1186
  relationCount = 0;
1187
+ /** The keys this check added to the relation, while relating without reporting first. */
1188
+ addedKeys: number[] | undefined = undefined;
1153
1189
  /** The intersection state passed to `compare` during signature comparisons. */
1154
1190
  signatureIntersectionState: IntersectionState = IntersectionState.None;
1155
1191
  // What `relateVariances` changes in its caller's state when it falls back to structure.
@@ -1681,13 +1717,11 @@ export class Relater extends TypeComparer {
1681
1717
  } else {
1682
1718
  c.reliabilityFlags |=
1683
1719
  entry & (RelationComparisonResult.ReportsUnmeasurable | RelationComparisonResult.ReportsUnreliable);
1684
- if (reportErrors && (entry & RelationComparisonResult.Overflow) !== 0) {
1685
- const message =
1686
- (entry & RelationComparisonResult.ComplexityOverflow) !== 0
1687
- ? Diagnostics.Excessive_complexity_comparing_types_0_and_1
1688
- : Diagnostics.Excessive_stack_depth_comparing_types_0_and_1;
1689
- this.reportError(message, [typeToString(c, source), typeToString(c, target)]);
1690
- }
1720
+ if (reportErrors && (entry & RelationComparisonResult.Overflow) !== 0)
1721
+ this.reportError(Diagnostics.Excessive_complexity_comparing_types_0_and_1, [
1722
+ typeToString(c, source),
1723
+ typeToString(c, target),
1724
+ ]);
1691
1725
  return (entry & RelationComparisonResult.Succeeded) !== 0 ? Ternary.True : Ternary.False;
1692
1726
  }
1693
1727
  }
@@ -1710,10 +1744,9 @@ export class Relater extends TypeComparer {
1710
1744
  }
1711
1745
  const sourceDepth = this.sourceDepth;
1712
1746
  const targetDepth = this.targetDepth;
1713
- if (sourceDepth === 100 || targetDepth === 100) {
1714
- this.overflow = true;
1715
- return Ternary.False;
1716
- }
1747
+ // A backstop for infinite recursion that isDeeplyNestedType misses, which also stops relating the exceedingly
1748
+ // rare types that are truly more than 100 levels deep.
1749
+ if (sourceDepth === 100 || targetDepth === 100) return Ternary.Maybe;
1717
1750
  const maybeStart = this.maybeKeys.length;
1718
1751
  this.maybeKeys.push(id);
1719
1752
  this.maybeKeysSet.add(id);
@@ -1754,18 +1787,22 @@ export class Relater extends TypeComparer {
1754
1787
  }
1755
1788
  } else {
1756
1789
  // False under assumptions is false without them.
1757
- this.relation.set(id, RelationComparisonResult.Failed | propagatingVarianceFlags);
1790
+ this.record(id, RelationComparisonResult.Failed | propagatingVarianceFlags);
1758
1791
  this.relationCount--;
1759
1792
  this.resetMaybeStack(maybeStart, propagatingVarianceFlags, false);
1760
1793
  }
1761
1794
  return result;
1762
1795
  }
1763
1796
 
1797
+ record(key: number, result: number): void {
1798
+ if (this.relation.set(key, result) && this.addedKeys !== undefined) this.addedKeys.push(key);
1799
+ }
1800
+
1764
1801
  resetMaybeStack(maybeStart: number, propagatingVarianceFlags: number, markAllAsSucceeded: boolean): void {
1765
1802
  for (let i = maybeStart; i < this.maybeKeys.length; i++) {
1766
1803
  this.maybeKeysSet.delete(this.maybeKeys[i]!);
1767
1804
  if (markAllAsSucceeded) {
1768
- this.relation.set(this.maybeKeys[i]!, RelationComparisonResult.Succeeded | propagatingVarianceFlags);
1805
+ this.record(this.maybeKeys[i]!, RelationComparisonResult.Succeeded | propagatingVarianceFlags);
1769
1806
  this.relationCount--;
1770
1807
  }
1771
1808
  }
@@ -2624,7 +2661,7 @@ export class Relater extends TypeComparer {
2624
2661
  ? this.isRelatedTo(s, t, RecursionFlags.Both, false)
2625
2662
  : compareTypesIdentical(c, s, t);
2626
2663
  else {
2627
- if (c.inVarianceComputation && (varianceFlags & VarianceFlags.Unreliable) !== 0)
2664
+ if (c.varianceStack.length !== 0 && (varianceFlags & VarianceFlags.Unreliable) !== 0)
2628
2665
  instantiateType(c, s, c.reportUnreliableMapper);
2629
2666
  if (variance === VarianceFlags.Covariant)
2630
2667
  related = this.isRelatedToEx(s, t, RecursionFlags.Both, reportErrors, undefined, intersectionState);
@@ -2708,7 +2745,8 @@ export class Relater extends TypeComparer {
2708
2745
  const sourceArity = getTypeReferenceArity(source);
2709
2746
  const targetArity = getTypeReferenceArity(target);
2710
2747
  const sourceRest = isTupleType(source) ? (tupleTargetOf(source).combinedFlags & ElementFlags.Rest) !== 0 : true;
2711
- const targetHasRestElement = (targetTuple.combinedFlags & ElementFlags.Variable) !== 0;
2748
+ const targetHasRestElement = (targetTuple.combinedFlags & ElementFlags.Rest) !== 0;
2749
+ const targetHasVariableElement = (targetTuple.combinedFlags & ElementFlags.Variable) !== 0;
2712
2750
  const sourceMinLength = isTupleType(source) ? tupleTargetOf(source).minLength : 0;
2713
2751
  const targetMinLength = targetTuple.minLength;
2714
2752
  if (!sourceRest && sourceArity < targetMinLength) {
@@ -2719,7 +2757,7 @@ export class Relater extends TypeComparer {
2719
2757
  ]);
2720
2758
  return Ternary.False;
2721
2759
  }
2722
- if (!targetHasRestElement && targetArity < sourceMinLength) {
2760
+ if (!targetHasVariableElement && targetArity < sourceMinLength) {
2723
2761
  if (reportErrors)
2724
2762
  this.reportError(Diagnostics.Source_has_0_element_s_but_target_allows_only_1, [
2725
2763
  String(sourceMinLength),
@@ -2727,7 +2765,7 @@ export class Relater extends TypeComparer {
2727
2765
  ]);
2728
2766
  return Ternary.False;
2729
2767
  }
2730
- if (!targetHasRestElement && (sourceRest || targetArity < sourceArity)) {
2768
+ if (!targetHasVariableElement && (sourceRest || targetArity < sourceArity)) {
2731
2769
  if (reportErrors) {
2732
2770
  if (sourceMinLength < targetMinLength)
2733
2771
  this.reportError(Diagnostics.Target_requires_0_element_s_but_source_may_have_fewer, [
@@ -2750,10 +2788,18 @@ export class Relater extends TypeComparer {
2750
2788
  ? tupleTargetOf(source).elementInfos[sourcePosition]!.flags
2751
2789
  : ElementFlags.Rest;
2752
2790
  const sourcePositionFromEnd = sourceArity - 1 - sourcePosition;
2753
- const targetPosition =
2754
- targetHasRestElement && sourcePosition >= targetStartCount
2755
- ? targetArity - 1 - Math.min(sourcePositionFromEnd, targetEndCount)
2756
- : sourcePosition;
2791
+ const restMapped = targetHasRestElement && sourcePosition >= targetStartCount;
2792
+ // A source element past the target's last element (a target with variadic but no rest elements).
2793
+ if (!restMapped && sourcePosition >= targetArity) {
2794
+ if (reportErrors)
2795
+ this.reportError(Diagnostics.Target_allows_only_0_element_s_but_source_may_have_more, [
2796
+ String(targetArity),
2797
+ ]);
2798
+ return Ternary.False;
2799
+ }
2800
+ const targetPosition = restMapped
2801
+ ? targetArity - 1 - Math.min(sourcePositionFromEnd, targetEndCount)
2802
+ : sourcePosition;
2757
2803
  const targetFlags = targetPosition >= 0 ? targetTuple.elementInfos[targetPosition]!.flags : ElementFlags.None;
2758
2804
  if ((targetFlags & ElementFlags.Variadic) !== 0 && (sourceFlags & ElementFlags.Variadic) === 0) {
2759
2805
  if (reportErrors)
@@ -3557,7 +3603,15 @@ export class Relater extends TypeComparer {
3557
3603
  target !== c.markerSubTypeForCheck
3558
3604
  ) {
3559
3605
  const constraint = getBaseConstraintOfType(c, target);
3560
- if (constraint !== undefined && isTypeAssignableTo(c, generalizedSource, constraint))
3606
+ if (
3607
+ isDistributedTypeParameter(target) &&
3608
+ isTypeAssignableTo(c, generalizedSource, (target as TypeParameter).constraint!)
3609
+ )
3610
+ this.reportError(Diagnostics.X_0_is_only_assignable_to_the_non_distributed_1_but_1_has_been_distributed_here, [
3611
+ generalizedSourceType,
3612
+ targetType,
3613
+ ]);
3614
+ else if (constraint !== undefined && isTypeAssignableTo(c, generalizedSource, constraint))
3561
3615
  this.reportError(
3562
3616
  Diagnostics.X_0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2,
3563
3617
  [generalizedSourceType, targetType, typeToString(c, constraint)],
@@ -3611,7 +3665,6 @@ export class Relater extends TypeComparer {
3611
3665
  case Diagnostics.Object_literal_may_only_specify_known_properties_but_0_does_not_exist_in_type_1_Did_you_mean_to_write_2:
3612
3666
  return;
3613
3667
  case Diagnostics.Excessive_complexity_comparing_types_0_and_1:
3614
- case Diagnostics.Excessive_stack_depth_comparing_types_0_and_1:
3615
3668
  case Diagnostics.The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1:
3616
3669
  if (this.chainArgsMatch(generalizedSourceType, targetType, undefined)) return;
3617
3670
  break;
@@ -4335,14 +4388,12 @@ export function isDeeplyNestedType(
4335
4388
  maxDepth: number,
4336
4389
  ): boolean {
4337
4390
  if (depth < maxDepth) return false;
4338
- if (
4339
- (t.objectFlags & ObjectFlags.InstantiatedMapped) === ObjectFlags.InstantiatedMapped &&
4340
- (t.flags & TypeFlags.Object) !== 0
4341
- )
4342
- t = getMappedTargetWithSymbol(c, t);
4343
- if ((t.flags & TypeFlags.Intersection) !== 0)
4344
- for (const u of typesOf(t)) if (isDeeplyNestedType(c, u, stack, depth, maxDepth)) return true;
4345
- const identity = getRecursionIdentity(t);
4391
+ const target = getRecursionIdentityTarget(c, t);
4392
+ if ((target.flags & TypeFlags.Intersection) !== 0) {
4393
+ for (const u of typesOf(target)) if (isDeeplyNestedType(c, u, stack, depth, maxDepth)) return true;
4394
+ return false;
4395
+ }
4396
+ const identity = getRecursionIdentityFromTarget(target);
4346
4397
  let count = 0;
4347
4398
  let lastTypeId = 0;
4348
4399
  for (let i = 0; i < depth; i++) {
@@ -4358,8 +4409,77 @@ export function isDeeplyNestedType(
4358
4409
  return false;
4359
4410
  }
4360
4411
 
4361
- function getMappedTargetWithSymbol(c: Checker, t: Type): Type {
4412
+ /**
4413
+ * isDeeplyNestedType for the newest entry of `stack[start..end)`, counting only the entries in that range.
4414
+ * `identities` holds the recursion identity of each entry of the range once a check has computed it: 0 before
4415
+ * that, and -1 for an entry whose recursion identity target is an intersection, which is matched by its
4416
+ * constituents each time. Later checks compare the kept identities. The identities are computed when and in the
4417
+ * order isDeeplyNestedType computes them, so the types and symbol ids they create come in the same order.
4418
+ */
4419
+ export function isDeeplyNestedStackEntry(
4420
+ c: Checker,
4421
+ stack: readonly Type[],
4422
+ identities: RecursionId[],
4423
+ start: number,
4424
+ end: number,
4425
+ maxDepth: number,
4426
+ ): boolean {
4427
+ if (end - start < maxDepth) return false;
4428
+ return isDeeplyNestedInRange(c, stack[end - 1]!, true, stack, identities, start, end, maxDepth);
4429
+ }
4430
+
4431
+ function isDeeplyNestedInRange(
4432
+ c: Checker,
4433
+ t: Type,
4434
+ isEntry: boolean,
4435
+ stack: readonly Type[],
4436
+ identities: RecursionId[],
4437
+ start: number,
4438
+ end: number,
4439
+ maxDepth: number,
4440
+ ): boolean {
4441
+ const target = getRecursionIdentityTarget(c, t);
4442
+ if ((target.flags & TypeFlags.Intersection) !== 0) {
4443
+ if (isEntry) identities[end - 1] = -1;
4444
+ for (const u of typesOf(target))
4445
+ if (isDeeplyNestedInRange(c, u, false, stack, identities, start, end, maxDepth)) return true;
4446
+ return false;
4447
+ }
4448
+ const identity = getRecursionIdentityFromTarget(target);
4449
+ if (isEntry) identities[end - 1] = identity;
4450
+ let count = 0;
4451
+ let lastTypeId = 0;
4452
+ for (let i = start; i < end; i++) {
4453
+ const s = stack[i]!;
4454
+ let known = identities[i]!;
4455
+ if (known === 0) {
4456
+ const sourceTarget = getRecursionIdentityTarget(c, s);
4457
+ known = (sourceTarget.flags & TypeFlags.Intersection) !== 0 ? -1 : getRecursionIdentityFromTarget(sourceTarget);
4458
+ identities[i] = known;
4459
+ }
4460
+ if (known >= 0 ? known === identity : hasMatchingRecursionIdentity(c, s, identity)) {
4461
+ if (s.id >= lastTypeId) {
4462
+ count++;
4463
+ if (count >= maxDepth) return true;
4464
+ }
4465
+ lastTypeId = s.id;
4466
+ }
4467
+ }
4468
+ return false;
4469
+ }
4470
+
4471
+ /**
4472
+ * The type whose recursion identity `t` has: the object type of an indexed access (T in T[K]), and for a
4473
+ * homomorphic mapped type the deepest target type that has a symbol. Unwrapping mapped types keeps the identities of
4474
+ * mapped types applied to written object literals unique: in `Mapped<{ x: Mapped<{ x: Mapped<{ x: string }>}>}>`,
4475
+ * each application has the identity of its object literal and does not appear deeply nested.
4476
+ */
4477
+ function getRecursionIdentityTarget(c: Checker, t: Type): Type {
4362
4478
  for (;;) {
4479
+ if ((t.flags & TypeFlags.IndexedAccess) !== 0) {
4480
+ t = (t as IndexedAccessType).objectType;
4481
+ continue;
4482
+ }
4363
4483
  if (
4364
4484
  (t.objectFlags & ObjectFlags.InstantiatedMapped) === ObjectFlags.InstantiatedMapped &&
4365
4485
  (t.flags & TypeFlags.Object) !== 0
@@ -4378,20 +4498,20 @@ function getMappedTargetWithSymbol(c: Checker, t: Type): Type {
4378
4498
  }
4379
4499
 
4380
4500
  function hasMatchingRecursionIdentity(c: Checker, t: Type, identity: RecursionId): boolean {
4381
- if (
4382
- (t.objectFlags & ObjectFlags.InstantiatedMapped) === ObjectFlags.InstantiatedMapped &&
4383
- (t.flags & TypeFlags.Object) !== 0
4384
- )
4385
- t = getMappedTargetWithSymbol(c, t);
4386
- if ((t.flags & TypeFlags.Intersection) !== 0) {
4387
- for (const u of typesOf(t)) if (hasMatchingRecursionIdentity(c, u, identity)) return true;
4501
+ const target = getRecursionIdentityTarget(c, t);
4502
+ if ((target.flags & TypeFlags.Intersection) !== 0) {
4503
+ for (const u of typesOf(target)) if (hasMatchingRecursionIdentity(c, u, identity)) return true;
4388
4504
  return false;
4389
4505
  }
4390
- return getRecursionIdentity(t) === identity;
4506
+ return getRecursionIdentityFromTarget(target) === identity;
4391
4507
  }
4392
4508
 
4393
4509
  /** An identity shared by instantiations of a type, so infinitely expanding instantiations can be detected. */
4394
- export function getRecursionIdentity(t: Type): RecursionId {
4510
+ export function getRecursionIdentity(c: Checker, t: Type): RecursionId {
4511
+ return getRecursionIdentityFromTarget(getRecursionIdentityTarget(c, t));
4512
+ }
4513
+
4514
+ function getRecursionIdentityFromTarget(t: Type): RecursionId {
4395
4515
  if (
4396
4516
  (t.flags & TypeFlags.Object) !== 0 &&
4397
4517
  (t.objectFlags & (ObjectFlags.ObjectLiteral | ObjectFlags.ArrayLiteral)) === 0
@@ -4408,12 +4528,6 @@ export function getRecursionIdentity(t: Type): RecursionId {
4408
4528
  return typeRecursionId((t as TypeReference).target!);
4409
4529
  }
4410
4530
  if ((t.flags & TypeFlags.TypeParameter) !== 0 && t.symbol !== undefined) return symbolRecursionId(t.symbol);
4411
- if ((t.flags & TypeFlags.IndexedAccess) !== 0) {
4412
- let objectType = (t as IndexedAccessType).objectType;
4413
- while ((objectType.flags & TypeFlags.IndexedAccess) !== 0)
4414
- objectType = (objectType as IndexedAccessType).objectType;
4415
- return typeRecursionId(objectType);
4416
- }
4417
4531
  if ((t.flags & TypeFlags.Conditional) !== 0) return nodeRecursionId((t as ConditionalType).root.node);
4418
4532
  return typeRecursionId(t);
4419
4533
  }
@@ -4451,16 +4565,45 @@ export function getAliasVariances(c: Checker, symbol: Symbol): VarianceFlags[] {
4451
4565
  * The measured variance of each type parameter, from relating marker instantiations; empty when
4452
4566
  * requested recursively.
4453
4567
  */
4568
+ /** A generic type whose variances are being computed. */
4569
+ export class VarianceStackEntry {
4570
+ constructor(
4571
+ readonly symbol: Symbol,
4572
+ readonly typeParameters: readonly Type[],
4573
+ ) {}
4574
+ }
4575
+
4454
4576
  function getVariancesWorker(c: Checker, symbol: Symbol, typeParameters: readonly Type[]): VarianceFlags[] {
4455
4577
  const links = c.symbolLinks(symbol);
4456
4578
  if (links.variances !== undefined) return links.variances;
4457
- const oldVarianceComputation = c.inVarianceComputation;
4458
- const saveResolutionStart = c.resolutionStart;
4459
- if (!c.inVarianceComputation) {
4460
- c.inVarianceComputation = true;
4461
- c.resolutionStart = c.resolutionDepth;
4579
+ let stackIndex = -1;
4580
+ for (let i = 0; i < c.varianceStack.length; i++)
4581
+ if (c.varianceStack[i]!.symbol === symbol) {
4582
+ stackIndex = i;
4583
+ break;
4584
+ }
4585
+ if (stackIndex >= 0) {
4586
+ // A circularity. The variances computed can depend on where the circular region is entered, so the
4587
+ // computation restarts from the generic type with the smallest symbol in the region if that is not this one,
4588
+ // which keeps the results of circular generic types stable.
4589
+ let minIndex = stackIndex;
4590
+ for (let i = stackIndex + 1; i < c.varianceStack.length; i++)
4591
+ if (compareSymbols(c, c.varianceStack[i]!.symbol, c.varianceStack[minIndex]!.symbol) < 0) minIndex = i;
4592
+ if (minIndex > stackIndex) {
4593
+ const saveVarianceStack = c.varianceStack;
4594
+ c.varianceStack = [];
4595
+ getVariancesWorker(c, saveVarianceStack[minIndex]!.symbol, saveVarianceStack[minIndex]!.typeParameters);
4596
+ c.varianceStack = saveVarianceStack;
4597
+ }
4598
+ // Variances that cannot be computed: the type parameters are treated as covariant. The computation in
4599
+ // progress stores its results over this.
4600
+ const stored = storedVariances(links);
4601
+ if (stored === undefined || stored.length === 0) links.variances = [];
4602
+ return links.variances!;
4462
4603
  }
4463
- links.variances = [];
4604
+ const saveResolutionStart = c.resolutionStart;
4605
+ if (c.varianceStack.length === 0) c.resolutionStart = c.resolutionDepth;
4606
+ c.varianceStack.push(new VarianceStackEntry(symbol, typeParameters));
4464
4607
  const variances: VarianceFlags[] = [];
4465
4608
  for (const tp of typeParameters) {
4466
4609
  const modifiers = getTypeParameterModifiers(tp);
@@ -4487,14 +4630,22 @@ function getVariancesWorker(c: Checker, symbol: Symbol, typeParameters: readonly
4487
4630
  if ((c.reliabilityFlags & RelationComparisonResult.ReportsUnreliable) !== 0) variance |= VarianceFlags.Unreliable;
4488
4631
  c.reliabilityFlags = saveReliabilityFlags;
4489
4632
  }
4633
+ // A computation restarted because of a circularity may have stored the variances already.
4634
+ const restarted = storedVariances(links);
4635
+ if (restarted !== undefined && restarted.length !== 0) break;
4490
4636
  variances.push(variance);
4491
4637
  }
4492
- if (!oldVarianceComputation) {
4493
- c.inVarianceComputation = false;
4494
- c.resolutionStart = saveResolutionStart;
4495
- }
4496
- links.variances = variances;
4497
- return variances;
4638
+ // Unless a restarted computation stored them.
4639
+ const stored = storedVariances(links);
4640
+ if (stored === undefined || stored.length === 0) links.variances = variances;
4641
+ c.varianceStack.pop();
4642
+ if (c.varianceStack.length === 0) c.resolutionStart = saveResolutionStart;
4643
+ return links.variances!;
4644
+ }
4645
+
4646
+ /** The variances stored in `links`, read again after computations that may have stored them. */
4647
+ function storedVariances(links: SymbolLinks): VarianceFlags[] | undefined {
4648
+ return links.variances;
4498
4649
  }
4499
4650
 
4500
4651
  export function createMarkerType(c: Checker, symbol: Symbol, source: Type, target: Type): Type {
@@ -5138,6 +5289,8 @@ export function isExactOptionalPropertyMismatch(
5138
5289
  }
5139
5290
 
5140
5291
  /** The string literal member of `target` closest to the string literal `source`. */
5292
+ const maxStringLiteralSuggestionCandidates = 1000;
5293
+
5141
5294
  function getSuggestedTypeForNonexistentStringLiteralType(c: Checker, source: Type, target: Type): Type | undefined {
5142
5295
  const value = (source as LiteralType).stringValue;
5143
5296
  const valueCodePoints = new CodePoints();
@@ -5146,8 +5299,11 @@ function getSuggestedTypeForNonexistentStringLiteralType(c: Checker, source: Typ
5146
5299
  let bestDistance = Math.floor(valueCodePoints.length * 0.4) + 0.9;
5147
5300
  let best: Type | undefined = undefined;
5148
5301
  const lowerValue = value.toLowerCase();
5302
+ // A target with more string literal candidates than this gets no suggestion.
5303
+ let candidates = 0;
5149
5304
  for (const t of typesOf(target)) {
5150
5305
  if ((t.flags & TypeFlags.StringLiteral) === 0) continue;
5306
+ if (++candidates > maxStringLiteralSuggestionCandidates) return undefined;
5151
5307
  const name = (t as LiteralType).stringValue;
5152
5308
  const nameLength = utf8Length(name);
5153
5309
  if (name === '' || Math.abs(nameLength - valueCodePoints.length) > maximumLengthDifference || name === value)
@@ -98,6 +98,7 @@ import { Diagnostics } from './diagnostic-messages.js';
98
98
  import type { Parser } from './parser.js';
99
99
  import { SyntaxKind } from './syntax-kind.js';
100
100
  import { TokenFlags } from './types.js';
101
+ import { IdentifierName } from './identifier-name.js';
101
102
 
102
103
  /** Sets the parent of every node in a subtree. */
103
104
  class ParentInChildrenSetter extends NodeVisitor {
@@ -360,7 +361,7 @@ export class Reparser {
360
361
  const param = params[pi]!;
361
362
  let parameter: ParameterDeclaration;
362
363
  if (param instanceof JSDocThisTag) {
363
- const thisIdent = new Identifier('this');
364
+ const thisIdent = new Identifier(new IdentifierName('this'));
364
365
  thisIdent.pos = (param as JSDocThisTag).pos;
365
366
  thisIdent.end = (param as JSDocThisTag).end;
366
367
  thisIdent.flags = p.contextFlags | NodeFlags.Reparsed;
@@ -387,7 +388,10 @@ export class Reparser {
387
388
  let name: Node = (param as JSDocParameterOrPropertyTag).name;
388
389
  if (name instanceof Identifier && !isValidIdentifier((name as Identifier).text)) {
389
390
  // Replace invalid characters with `_`, or use `_N` for an empty name, for a valid parameter name.
390
- name = this.addTransformedReparse(new Identifier(sanitizeIdentifier((name as Identifier).text, pi)), name);
391
+ name = this.addTransformedReparse(
392
+ new Identifier(new IdentifierName(sanitizeIdentifier((name as Identifier).text, pi))),
393
+ name,
394
+ );
391
395
  } else {
392
396
  name = this.addDeepCloneReparse(name);
393
397
  }
@@ -611,7 +615,7 @@ export class Reparser {
611
615
  const thisParam = new ParameterDeclaration(
612
616
  undefined,
613
617
  undefined,
614
- new Identifier('this'),
618
+ new Identifier(new IdentifierName('this')),
615
619
  undefined,
616
620
  undefined,
617
621
  undefined,
@@ -891,11 +895,15 @@ export class Reparser {
891
895
  if ((clause as HeritageClause).types.nodes.length !== 1) return false;
892
896
  const target = (clause as HeritageClause).types.nodes[0]!;
893
897
  const source = tag.className;
898
+ // The tag's type arguments apply to an `extends` clause without any: one naming the same
899
+ // entity, or another expression such as a call (`extends mixin(Base)`), but not `null`.
894
900
  if (
895
901
  target instanceof ExpressionWithTypeArguments &&
896
- hasSamePropertyAccessName((target as ExpressionWithTypeArguments).expression, source.expression) &&
897
902
  (target as ExpressionWithTypeArguments).typeArguments === undefined &&
898
- source.typeArguments !== undefined
903
+ source.typeArguments !== undefined &&
904
+ (target as ExpressionWithTypeArguments).expression.kind !== SyntaxKind.NullKeyword &&
905
+ (!isEntityNameExpression((target as ExpressionWithTypeArguments).expression, false) ||
906
+ hasSamePropertyAccessName((target as ExpressionWithTypeArguments).expression, source.expression))
899
907
  ) {
900
908
  const newArguments: Node[] = [];
901
909
  for (const arg of source.typeArguments.nodes) newArguments.push(this.addDeepCloneReparse(arg));
@@ -966,6 +974,7 @@ export class Reparser {
966
974
  modifiers,
967
975
  SyntaxKind.NamespaceKeyword,
968
976
  this.addDeepCloneReparse((fullName as ModuleDeclaration).name),
977
+ undefined,
969
978
  block,
970
979
  );
971
980
  this.finishReparsedNode(result, fullName);