tsc-ts 0.0.9 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (373) hide show
  1. package/README.md +2 -2
  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 +22 -15
  6. package/dist/api/compiler/ast.js +1026 -995
  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 +178 -124
  12. package/dist/api/compiler/checker-classes.d.ts +14 -3
  13. package/dist/api/compiler/checker-classes.js +134 -90
  14. package/dist/api/compiler/checker-contextual.js +64 -61
  15. package/dist/api/compiler/checker-declaration-order.js +79 -79
  16. package/dist/api/compiler/checker-declarations.d.ts +1 -0
  17. package/dist/api/compiler/checker-declarations.js +160 -136
  18. package/dist/api/compiler/checker-declared-types.js +67 -65
  19. package/dist/api/compiler/checker-decorators.js +77 -77
  20. package/dist/api/compiler/checker-deprecation.d.ts +8 -3
  21. package/dist/api/compiler/checker-deprecation.js +76 -55
  22. package/dist/api/compiler/checker-destructuring.js +47 -45
  23. package/dist/api/compiler/checker-elaboration.js +24 -24
  24. package/dist/api/compiler/checker-emit-helpers.js +4 -4
  25. package/dist/api/compiler/checker-emit-resolver.d.ts +4 -2
  26. package/dist/api/compiler/checker-emit-resolver.js +25 -13
  27. package/dist/api/compiler/checker-evaluator.js +9 -9
  28. package/dist/api/compiler/checker-expressions.js +244 -211
  29. package/dist/api/compiler/checker-functions.js +113 -107
  30. package/dist/api/compiler/checker-generated-code.d.ts +0 -11
  31. package/dist/api/compiler/checker-generated-code.js +28 -52
  32. package/dist/api/compiler/checker-grammar.d.ts +1 -0
  33. package/dist/api/compiler/checker-grammar.js +472 -440
  34. package/dist/api/compiler/checker-heritage.js +91 -93
  35. package/dist/api/compiler/checker-inference.d.ts +77 -5
  36. package/dist/api/compiler/checker-inference.js +487 -107
  37. package/dist/api/compiler/checker-iteration.d.ts +0 -10
  38. package/dist/api/compiler/checker-iteration.js +35 -52
  39. package/dist/api/compiler/checker-javascript.js +14 -14
  40. package/dist/api/compiler/checker-jsdoc.d.ts +8 -10
  41. package/dist/api/compiler/checker-jsdoc.js +67 -58
  42. package/dist/api/compiler/checker-jsx.js +105 -88
  43. package/dist/api/compiler/checker-members.d.ts +9 -2
  44. package/dist/api/compiler/checker-members.js +212 -75
  45. package/dist/api/compiler/checker-modules.d.ts +15 -6
  46. package/dist/api/compiler/checker-modules.js +469 -309
  47. package/dist/api/compiler/checker-narrowing.js +273 -189
  48. package/dist/api/compiler/checker-object-literals.js +25 -22
  49. package/dist/api/compiler/checker-operators.js +126 -118
  50. package/dist/api/compiler/checker-overloads.js +27 -27
  51. package/dist/api/compiler/checker-property-access.js +59 -55
  52. package/dist/api/compiler/checker-services.d.ts +1 -0
  53. package/dist/api/compiler/checker-services.js +222 -210
  54. package/dist/api/compiler/checker-signatures.js +65 -49
  55. package/dist/api/compiler/checker-source-file.d.ts +5 -0
  56. package/dist/api/compiler/checker-source-file.js +154 -130
  57. package/dist/api/compiler/checker-statements.js +33 -32
  58. package/dist/api/compiler/checker-super.js +50 -50
  59. package/dist/api/compiler/checker-symbol-types.js +109 -93
  60. package/dist/api/compiler/checker-symbols.d.ts +13 -1
  61. package/dist/api/compiler/checker-symbols.js +264 -149
  62. package/dist/api/compiler/checker-type-factory.d.ts +5 -0
  63. package/dist/api/compiler/checker-type-factory.js +145 -36
  64. package/dist/api/compiler/checker-type-nodes.d.ts +1 -0
  65. package/dist/api/compiler/checker-type-nodes.js +179 -141
  66. package/dist/api/compiler/checker-type-operators.d.ts +2 -0
  67. package/dist/api/compiler/checker-type-operators.js +110 -63
  68. package/dist/api/compiler/checker-types.d.ts +80 -3
  69. package/dist/api/compiler/checker-types.js +121 -2
  70. package/dist/api/compiler/checker-unused.js +114 -118
  71. package/dist/api/compiler/checker-utilities.js +11 -11
  72. package/dist/api/compiler/checker.d.ts +104 -31
  73. package/dist/api/compiler/checker.js +181 -33
  74. package/dist/api/compiler/command-line.d.ts +1 -3
  75. package/dist/api/compiler/command-line.js +47 -44
  76. package/dist/api/compiler/compile-program.d.ts +42 -3
  77. package/dist/api/compiler/compile-program.js +139 -27
  78. package/dist/api/compiler/diagnostic-messages.d.ts +1849 -1774
  79. package/dist/api/compiler/diagnostic-messages.js +128 -122
  80. package/dist/api/compiler/diagnostics.d.ts +22 -0
  81. package/dist/api/compiler/diagnostics.js +93 -11
  82. package/dist/api/compiler/emitter.d.ts +7 -1
  83. package/dist/api/compiler/emitter.js +53 -11
  84. package/dist/api/compiler/file-include.d.ts +2 -1
  85. package/dist/api/compiler/file-include.js +11 -7
  86. package/dist/api/compiler/file-loader.d.ts +21 -1
  87. package/dist/api/compiler/file-loader.js +201 -48
  88. package/dist/api/compiler/instantiation.d.ts +7 -0
  89. package/dist/api/compiler/instantiation.js +101 -49
  90. package/dist/api/compiler/jsdoc.js +23 -23
  91. package/dist/api/compiler/link-tables.d.ts +48 -18
  92. package/dist/api/compiler/link-tables.js +80 -37
  93. package/dist/api/compiler/locales/cs-CZ.d.ts +1 -1
  94. package/dist/api/compiler/locales/cs-CZ.js +1 -1
  95. package/dist/api/compiler/locales/de-DE.d.ts +1 -1
  96. package/dist/api/compiler/locales/de-DE.js +1 -1
  97. package/dist/api/compiler/locales/es-ES.d.ts +1 -1
  98. package/dist/api/compiler/locales/es-ES.js +1 -1
  99. package/dist/api/compiler/locales/fr-FR.d.ts +1 -1
  100. package/dist/api/compiler/locales/fr-FR.js +1 -1
  101. package/dist/api/compiler/locales/it-IT.d.ts +1 -1
  102. package/dist/api/compiler/locales/it-IT.js +1 -1
  103. package/dist/api/compiler/locales/ja-JP.d.ts +1 -1
  104. package/dist/api/compiler/locales/ja-JP.js +1 -1
  105. package/dist/api/compiler/locales/ko-KR.d.ts +1 -1
  106. package/dist/api/compiler/locales/ko-KR.js +1 -1
  107. package/dist/api/compiler/locales/pl-PL.d.ts +1 -1
  108. package/dist/api/compiler/locales/pl-PL.js +1 -1
  109. package/dist/api/compiler/locales/pt-BR.d.ts +1 -1
  110. package/dist/api/compiler/locales/pt-BR.js +1 -1
  111. package/dist/api/compiler/locales/ru-RU.d.ts +1 -1
  112. package/dist/api/compiler/locales/ru-RU.js +1 -1
  113. package/dist/api/compiler/locales/tr-TR.d.ts +1 -1
  114. package/dist/api/compiler/locales/tr-TR.js +1 -1
  115. package/dist/api/compiler/locales/zh-CN.d.ts +1 -1
  116. package/dist/api/compiler/locales/zh-CN.js +1 -1
  117. package/dist/api/compiler/locales/zh-TW.d.ts +1 -1
  118. package/dist/api/compiler/locales/zh-TW.js +1 -1
  119. package/dist/api/compiler/module-resolution-types.js +6 -6
  120. package/dist/api/compiler/module-resolution.d.ts +10 -1
  121. package/dist/api/compiler/module-resolution.js +115 -84
  122. package/dist/api/compiler/module-specifiers.d.ts +15 -0
  123. package/dist/api/compiler/module-specifiers.js +24 -18
  124. package/dist/api/compiler/name-resolver.js +74 -65
  125. package/dist/api/compiler/node-builder-names.d.ts +11 -3
  126. package/dist/api/compiler/node-builder-names.js +210 -90
  127. package/dist/api/compiler/node-builder-pseudo.js +29 -31
  128. package/dist/api/compiler/node-builder-reuse.js +23 -22
  129. package/dist/api/compiler/node-builder.d.ts +18 -1
  130. package/dist/api/compiler/node-builder.js +191 -102
  131. package/dist/api/compiler/option-declarations.d.ts +2 -6
  132. package/dist/api/compiler/option-declarations.js +315 -375
  133. package/dist/api/compiler/options.d.ts +15 -33
  134. package/dist/api/compiler/options.js +21 -54
  135. package/dist/api/compiler/output-paths.d.ts +4 -1
  136. package/dist/api/compiler/output-paths.js +6 -11
  137. package/dist/api/compiler/package-json.d.ts +3 -3
  138. package/dist/api/compiler/package-json.js +11 -10
  139. package/dist/api/compiler/parallel-parse.d.ts +3 -2
  140. package/dist/api/compiler/parallel-parse.js +17 -5
  141. package/dist/api/compiler/parser.d.ts +40 -19
  142. package/dist/api/compiler/parser.js +308 -216
  143. package/dist/api/compiler/path.d.ts +9 -0
  144. package/dist/api/compiler/path.js +20 -3
  145. package/dist/api/compiler/printer/emit-context.d.ts +5 -1
  146. package/dist/api/compiler/printer/emit-context.js +20 -1
  147. package/dist/api/compiler/printer/factory-base.d.ts +2 -2
  148. package/dist/api/compiler/printer/factory-base.js +7 -3
  149. package/dist/api/compiler/printer/factory.js +3 -1
  150. package/dist/api/compiler/printer/helpers.js +10 -1
  151. package/dist/api/compiler/printer/name-generator.d.ts +1 -1
  152. package/dist/api/compiler/printer/name-generator.js +35 -16
  153. package/dist/api/compiler/printer/printer.d.ts +49 -2
  154. package/dist/api/compiler/printer/printer.js +539 -293
  155. package/dist/api/compiler/printer/utilities.js +149 -147
  156. package/dist/api/compiler/program-checker.d.ts +12 -2
  157. package/dist/api/compiler/program-checker.js +88 -34
  158. package/dist/api/compiler/program-utilities.d.ts +3 -1
  159. package/dist/api/compiler/program-utilities.js +28 -15
  160. package/dist/api/compiler/program.d.ts +4 -6
  161. package/dist/api/compiler/program.js +74 -87
  162. package/dist/api/compiler/pseudo-bigint.d.ts +2 -0
  163. package/dist/api/compiler/pseudo-bigint.js +18 -0
  164. package/dist/api/compiler/regexp-checker.d.ts +1 -1
  165. package/dist/api/compiler/regexp-checker.js +93 -76
  166. package/dist/api/compiler/relations.d.ts +27 -4
  167. package/dist/api/compiler/relations.js +347 -180
  168. package/dist/api/compiler/reparser.js +60 -56
  169. package/dist/api/compiler/scanner.d.ts +19 -2
  170. package/dist/api/compiler/scanner.js +123 -108
  171. package/dist/api/compiler/shared-results.d.ts +463 -0
  172. package/dist/api/compiler/shared-results.js +2128 -0
  173. package/dist/api/compiler/sourcemap.js +2 -2
  174. package/dist/api/compiler/symbol-accessibility.js +87 -74
  175. package/dist/api/compiler/symbol.d.ts +23 -14
  176. package/dist/api/compiler/symbol.js +23 -11
  177. package/dist/api/compiler/syntax-kind.d.ts +198 -197
  178. package/dist/api/compiler/transformers/alias-references.js +247 -139
  179. package/dist/api/compiler/transformers/async-utilities.js +25 -25
  180. package/dist/api/compiler/transformers/async.d.ts +0 -1
  181. package/dist/api/compiler/transformers/async.js +64 -77
  182. package/dist/api/compiler/transformers/class-fields.d.ts +1 -0
  183. package/dist/api/compiler/transformers/class-fields.js +81 -78
  184. package/dist/api/compiler/transformers/commonjs-module.js +18 -15
  185. package/dist/api/compiler/transformers/const-enum-inliner.js +1 -1
  186. package/dist/api/compiler/transformers/declarations-diagnostics.js +247 -244
  187. package/dist/api/compiler/transformers/declarations-pseudo.js +100 -100
  188. package/dist/api/compiler/transformers/declarations-resolver.d.ts +0 -3
  189. package/dist/api/compiler/transformers/declarations-syntactic.d.ts +1 -2
  190. package/dist/api/compiler/transformers/declarations-syntactic.js +134 -156
  191. package/dist/api/compiler/transformers/declarations-tracker.js +18 -18
  192. package/dist/api/compiler/transformers/declarations.d.ts +4 -1
  193. package/dist/api/compiler/transformers/declarations.js +305 -238
  194. package/dist/api/compiler/transformers/decorator-metadata.d.ts +1 -1
  195. package/dist/api/compiler/transformers/decorator-metadata.js +53 -45
  196. package/dist/api/compiler/transformers/decorator-utilities.js +24 -24
  197. package/dist/api/compiler/transformers/destructuring.js +19 -18
  198. package/dist/api/compiler/transformers/emit-resolver.js +1 -1
  199. package/dist/api/compiler/transformers/es-decorators.js +55 -55
  200. package/dist/api/compiler/transformers/external-module-info.js +3 -3
  201. package/dist/api/compiler/transformers/for-await.js +25 -25
  202. package/dist/api/compiler/transformers/import-elision.js +14 -14
  203. package/dist/api/compiler/transformers/jsx.js +12 -12
  204. package/dist/api/compiler/transformers/legacy-decorators.js +17 -17
  205. package/dist/api/compiler/transformers/module.js +8 -8
  206. package/dist/api/compiler/transformers/named-evaluation.js +4 -4
  207. package/dist/api/compiler/transformers/object-rest-spread.js +20 -20
  208. package/dist/api/compiler/transformers/optional-chain.js +10 -10
  209. package/dist/api/compiler/transformers/reference-resolver.d.ts +12 -1
  210. package/dist/api/compiler/transformers/reference-resolver.js +131 -69
  211. package/dist/api/compiler/transformers/runtime-syntax.js +35 -31
  212. package/dist/api/compiler/transformers/subtree-facts.js +47 -47
  213. package/dist/api/compiler/transformers/syntax-facts.js +56 -58
  214. package/dist/api/compiler/transformers/type-eraser.js +73 -66
  215. package/dist/api/compiler/transformers/type-serialization.js +24 -24
  216. package/dist/api/compiler/transformers/using.js +12 -12
  217. package/dist/api/compiler/transformers/utilities.js +77 -77
  218. package/dist/api/compiler/transformers/visitor-base.js +172 -172
  219. package/dist/api/compiler/transformers/visitor-hooks.js +6 -2
  220. package/dist/api/compiler/tsconfig.d.ts +10 -2
  221. package/dist/api/compiler/tsconfig.js +136 -48
  222. package/dist/api/compiler/type-printer.js +40 -3
  223. package/dist/api/compiler/types.d.ts +2 -1
  224. package/dist/api/library/ast.generated.d.ts +42 -39
  225. package/dist/api/library/ast.generated.js +1 -1
  226. package/dist/api/library/compiler-options.generated.d.ts +111 -100
  227. package/dist/api/library/compiler-options.generated.js +1 -1
  228. package/dist/api/library/disk.js +12 -1
  229. package/dist/api/library/enums.generated.d.ts +206 -206
  230. package/dist/api/library/enums.generated.js +206 -206
  231. package/dist/api/library/nodes.js +26 -26
  232. package/package.json +9 -9
  233. package/src/compiler/ast-utilities.ts +99 -7
  234. package/src/compiler/ast.ts +58 -26
  235. package/src/compiler/binder.ts +39 -4
  236. package/src/compiler/character-codes.ts +2 -2
  237. package/src/compiler/checker-calls.ts +79 -9
  238. package/src/compiler/checker-classes.ts +78 -24
  239. package/src/compiler/checker-contextual.ts +6 -1
  240. package/src/compiler/checker-declarations.ts +31 -4
  241. package/src/compiler/checker-declared-types.ts +8 -5
  242. package/src/compiler/checker-decorators.ts +1 -1
  243. package/src/compiler/checker-deprecation.ts +29 -8
  244. package/src/compiler/checker-destructuring.ts +10 -3
  245. package/src/compiler/checker-emit-helpers.ts +1 -0
  246. package/src/compiler/checker-emit-resolver.ts +16 -6
  247. package/src/compiler/checker-expressions.ts +79 -46
  248. package/src/compiler/checker-functions.ts +21 -6
  249. package/src/compiler/checker-generated-code.ts +2 -22
  250. package/src/compiler/checker-grammar.ts +136 -62
  251. package/src/compiler/checker-heritage.ts +22 -21
  252. package/src/compiler/checker-inference.ts +514 -82
  253. package/src/compiler/checker-iteration.ts +18 -31
  254. package/src/compiler/checker-javascript.ts +1 -1
  255. package/src/compiler/checker-jsdoc.ts +50 -27
  256. package/src/compiler/checker-jsx.ts +26 -4
  257. package/src/compiler/checker-members.ts +200 -56
  258. package/src/compiler/checker-modules.ts +332 -65
  259. package/src/compiler/checker-narrowing.ts +98 -19
  260. package/src/compiler/checker-object-literals.ts +3 -0
  261. package/src/compiler/checker-operators.ts +11 -4
  262. package/src/compiler/checker-property-access.ts +7 -2
  263. package/src/compiler/checker-services.ts +39 -12
  264. package/src/compiler/checker-signatures.ts +15 -1
  265. package/src/compiler/checker-source-file.ts +39 -13
  266. package/src/compiler/checker-statements.ts +3 -2
  267. package/src/compiler/checker-symbol-types.ts +29 -6
  268. package/src/compiler/checker-symbols.ts +158 -15
  269. package/src/compiler/checker-type-factory.ts +124 -23
  270. package/src/compiler/checker-type-nodes.ts +46 -3
  271. package/src/compiler/checker-type-operators.ts +83 -26
  272. package/src/compiler/checker-types.ts +147 -4
  273. package/src/compiler/checker-unused.ts +9 -14
  274. package/src/compiler/checker.ts +203 -39
  275. package/src/compiler/command-line.ts +28 -28
  276. package/src/compiler/compile-program.ts +167 -27
  277. package/src/compiler/decoder.ts +13 -4
  278. package/src/compiler/diagnostic-messages.ts +1973 -1892
  279. package/src/compiler/diagnostics.ts +84 -3
  280. package/src/compiler/emitter.ts +57 -8
  281. package/src/compiler/encoder.ts +23 -8
  282. package/src/compiler/file-include.ts +9 -3
  283. package/src/compiler/file-loader.ts +197 -38
  284. package/src/compiler/help.ts +10 -14
  285. package/src/compiler/incremental.ts +165 -30
  286. package/src/compiler/init.ts +2 -7
  287. package/src/compiler/instantiation.ts +77 -22
  288. package/src/compiler/jsdoc.ts +3 -1
  289. package/src/compiler/link-tables.ts +82 -37
  290. package/src/compiler/locales/cs-CZ.ts +1 -1
  291. package/src/compiler/locales/de-DE.ts +1 -1
  292. package/src/compiler/locales/es-ES.ts +1 -1
  293. package/src/compiler/locales/fr-FR.ts +1 -1
  294. package/src/compiler/locales/it-IT.ts +1 -1
  295. package/src/compiler/locales/ja-JP.ts +1 -1
  296. package/src/compiler/locales/ko-KR.ts +1 -1
  297. package/src/compiler/locales/pl-PL.ts +1 -1
  298. package/src/compiler/locales/pt-BR.ts +1 -1
  299. package/src/compiler/locales/ru-RU.ts +1 -1
  300. package/src/compiler/locales/tr-TR.ts +1 -1
  301. package/src/compiler/locales/zh-CN.ts +1 -1
  302. package/src/compiler/locales/zh-TW.ts +1 -1
  303. package/src/compiler/module-resolution.ts +44 -8
  304. package/src/compiler/module-specifiers.ts +62 -20
  305. package/src/compiler/name-resolver.ts +9 -1
  306. package/src/compiler/node-builder-names.ts +236 -54
  307. package/src/compiler/node-builder-pseudo.ts +4 -7
  308. package/src/compiler/node-builder-reuse.ts +5 -4
  309. package/src/compiler/node-builder.ts +130 -31
  310. package/src/compiler/option-declarations.ts +33 -103
  311. package/src/compiler/options.ts +23 -62
  312. package/src/compiler/output-paths.ts +5 -18
  313. package/src/compiler/package-entrypoints.ts +345 -0
  314. package/src/compiler/package-json.ts +4 -4
  315. package/src/compiler/parallel-check.ts +326 -52
  316. package/src/compiler/parallel-emit.ts +320 -0
  317. package/src/compiler/parallel-parse.ts +16 -5
  318. package/src/compiler/parse-thread.ts +3 -0
  319. package/src/compiler/parser.ts +156 -39
  320. package/src/compiler/path.ts +22 -2
  321. package/src/compiler/printer/emit-context.ts +21 -0
  322. package/src/compiler/printer/factory-base.ts +10 -3
  323. package/src/compiler/printer/factory.ts +4 -1
  324. package/src/compiler/printer/helpers.ts +10 -1
  325. package/src/compiler/printer/name-generator.ts +24 -2
  326. package/src/compiler/printer/printer.ts +266 -30
  327. package/src/compiler/printer/utilities.ts +8 -2
  328. package/src/compiler/program-checker.ts +57 -5
  329. package/src/compiler/program-utilities.ts +23 -10
  330. package/src/compiler/program.ts +18 -26
  331. package/src/compiler/pseudo-bigint.ts +17 -0
  332. package/src/compiler/regexp-checker.ts +63 -30
  333. package/src/compiler/relations.ts +240 -77
  334. package/src/compiler/reparser.ts +7 -2
  335. package/src/compiler/scanner.ts +109 -79
  336. package/src/compiler/shared-results.ts +2414 -0
  337. package/src/compiler/show-config.ts +18 -1
  338. package/src/compiler/sourcemap.ts +2 -2
  339. package/src/compiler/symbol-accessibility.ts +26 -3
  340. package/src/compiler/symbol.ts +46 -24
  341. package/src/compiler/syntax-kind.ts +188 -187
  342. package/src/compiler/thread-entry.ts +64 -4
  343. package/src/compiler/transformers/alias-references.ts +123 -4
  344. package/src/compiler/transformers/async.ts +2 -17
  345. package/src/compiler/transformers/class-fields.ts +13 -12
  346. package/src/compiler/transformers/commonjs-module.ts +11 -7
  347. package/src/compiler/transformers/declarations-diagnostics.ts +5 -3
  348. package/src/compiler/transformers/declarations-pseudo.ts +2 -4
  349. package/src/compiler/transformers/declarations-resolver.ts +0 -3
  350. package/src/compiler/transformers/declarations-syntactic.ts +1 -21
  351. package/src/compiler/transformers/declarations.ts +134 -48
  352. package/src/compiler/transformers/decorator-metadata.ts +9 -1
  353. package/src/compiler/transformers/destructuring.ts +4 -3
  354. package/src/compiler/transformers/external-module-info.ts +1 -1
  355. package/src/compiler/transformers/jsx.ts +2 -1
  356. package/src/compiler/transformers/reference-resolver.ts +83 -19
  357. package/src/compiler/transformers/runtime-syntax.ts +6 -1
  358. package/src/compiler/transformers/syntax-facts.ts +2 -7
  359. package/src/compiler/transformers/type-eraser.ts +10 -1
  360. package/src/compiler/transformers/type-serialization.ts +3 -2
  361. package/src/compiler/transformers/visitor-base.ts +2 -1
  362. package/src/compiler/transformers/visitor-hooks.ts +9 -4
  363. package/src/compiler/tsc-build.ts +66 -9
  364. package/src/compiler/tsc-cli.ts +7 -0
  365. package/src/compiler/tsc-compile.ts +284 -4
  366. package/src/compiler/tsc-watch.ts +74 -45
  367. package/src/compiler/tsconfig.ts +176 -19
  368. package/src/compiler/type-printer.ts +36 -2
  369. package/src/compiler/types.ts +2 -1
  370. package/src/library/ast.generated.ts +57 -41
  371. package/src/library/compiler-options.generated.ts +117 -103
  372. package/src/library/disk.ts +10 -1
  373. package/src/library/enums.generated.ts +196 -196
@@ -3,7 +3,7 @@
3
3
  import { checkDeprecatedSignature } from './checker-deprecation.js';
4
4
  import { Node, getArguments as getArgumentList, getExpression, getName, getParameters, getText, getTypeArguments as getTypeArgumentList, getNodeId, getBody, getSymbol, callQuestionDotToken, callTypeArguments, } from './ast.js';
5
5
  import { canHaveDecorators, getEffectiveCheckNode, isFunctionLikeDeclarationKind, isImportCall, nodeIsPresent, } from './ast-utilities.js';
6
- import { getContainingClass, getSourceFileOfNode, isAccessExpression, isExpressionOfOptionalChainRoot, isOptionalChain, isOutermostOptionalChain, isDottedName, } from './binder-utilities.js';
6
+ import { getContainingClass, getSourceFileOfNode, isAccessExpression, isExpressionOfOptionalChainRoot, isOptionalChain, isOutermostOptionalChain, isDottedName, isFunctionExpressionOrArrowFunction, } from './binder-utilities.js';
7
7
  import { Diagnostic, chainDiagnostic } from './diagnostics.js';
8
8
  import { resolveInstanceofExpression } from './checker-operators.js';
9
9
  import { skipTrivia } from './scanner.js';
@@ -20,7 +20,7 @@ import { getEffectsSignature } from './checker-narrowing.js';
20
20
  import { addOptionalTypeMarker, getOptionalType, getTypeOfSymbol, removeOptionalTypeMarker, } from './checker-symbol-types.js';
21
21
  import { checkTypeRelatedTo, getRegularTypeOfObjectLiteral, isTypeAssignableTo } from './relations.js';
22
22
  import { getNonNullableType } from './checker-flow.js';
23
- import { checkExpression, checkExpressionCached, checkNonNullType, checkNonNullTypeEx, checkTypeQueryExpression, } from './checker-expressions.js';
23
+ import { checkExpression, checkExpressionCached, checkNonNullType, checkNonNullTypeEx, checkTypeQueryExpression, getResolvedSymbol, } from './checker-expressions.js';
24
24
  import { checkIteratedTypeOrElementType } from './checker-iteration.js';
25
25
  import { isContextSensitive } from './checker-functions.js';
26
26
  import { getExtendsHeritageClauseElement, getInstantiatedConstructorsForTypeArguments, fillMissingTypeArguments, getConstraintOfTypeParameter, getDefaultFromTypeParameter, getMinTypeArgumentCount, } from './checker-declared-types.js';
@@ -29,7 +29,7 @@ import { getIndexedAccessTypeEx, getRestTypeOfTupleType } from './checker-type-o
29
29
  import { instantiateType, isNodeDescendantOf } from './instantiation.js';
30
30
  import { maybeTypeOfKind } from './checker-utilities.js';
31
31
  import { checkSourceElement, checkNodeDeferred } from './checker-source-file.js';
32
- import { InferenceInfo, applyToParameterTypes, applyToReturnTypes, hasOverlappingInferences, instantiateSignatureInContextOf, mergeInferences, cloneInferenceContext, cloneInferredPartOfContext, createInferenceContext, createOuterReturnMapper, getInferredTypes, getMapperFromContext, everyInferenceHasCandidates, someInferenceHasCandidates, inferTypes, isConstTypeVariable, isMutableArrayLikeType, } from './checker-inference.js';
32
+ import { InferenceInfo, applyToParameterTypes, applyToReturnTypes, hasOverlappingInferences, instantiateSignatureInContextOf, mergeInferences, cloneInferenceContext, cloneInferredPartOfContext, createInferenceContext, createOuterReturnMapper, getInferredTypes, getMapperFromContext, everyInferenceHasCandidates, someInferenceHasCandidates, inferTypes, inferTypesFromUnstarted, isConstTypeVariable, isMutableArrayLikeType, } from './checker-inference.js';
33
33
  import { checkExpressionWithContextualType, getApparentTypeOfContextualTypeEx, getContextualTypeEx, getContextualTypeForElementExpression, getInferenceContext, } from './checker-contextual.js';
34
34
  import { couldContainTypeVariables } from './instantiation.js';
35
35
  import { typeToString } from './type-printer.js';
@@ -38,7 +38,7 @@ import { getGlobalValueSymbol, getSymbolOfDeclaration, resolveName } from './che
38
38
  import { checkImportCallExpression } from './checker-modules.js';
39
39
  import { checkApplicableSignatureForJsxCallLikeElement, getAttributesOf, getEffectiveJsxArguments, inferJsxTypeArguments, isJsxOpeningLikeElement, resolveJsxOpeningLikeElement, } from './checker-jsx.js';
40
40
  import { isCommonJSRequire, resolveExternalModuleTypeByLiteral } from './checker-javascript.js';
41
- import { declarationCount, getDeclarations } from './symbol.js';
41
+ import { copyDeclarations, declarationCount, getDeclarations, } from './symbol.js';
42
42
  /** The type of an optional chain's expression with the chain's `undefined` removed. */
43
43
  export function getOptionalExpressionType(c, exprType, expression) {
44
44
  if (isExpressionOfOptionalChainRoot(expression))
@@ -73,26 +73,26 @@ export function checkCallExpression(c, node, checkMode) {
73
73
  return getESSymbolLikeTypeForNode(c, walkUpParenthesizedExpressions(node.parent));
74
74
  // An assertion call must name its target through explicitly typed declarations.
75
75
  if (callQuestionDotToken(call) === undefined &&
76
- node.parent.kind === 245 /* SyntaxKind.ExpressionStatement */ &&
76
+ node.parent.kind === 246 /* SyntaxKind.ExpressionStatement */ &&
77
77
  (returnType.flags & 16 /* TypeFlags.Void */) !== 0 &&
78
78
  getTypePredicateOfSignature(c, signature) !== undefined) {
79
79
  if (!isDottedName(callee))
80
- c.error(callee, 908 /* Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name */);
80
+ c.error(callee, 915 /* Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name */);
81
81
  else if (getEffectsSignature(c, node) === undefined)
82
- c.error(callee, 907 /* Diagnostics.Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation */);
82
+ c.error(callee, 914 /* Diagnostics.Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation */);
83
83
  }
84
84
  return returnType;
85
85
  }
86
86
  function walkUpParenthesizedExpressions(node) {
87
87
  let current = node;
88
- while (current.kind === 218 /* SyntaxKind.ParenthesizedExpression */)
88
+ while (current.kind === 219 /* SyntaxKind.ParenthesizedExpression */)
89
89
  current = current.parent;
90
90
  return current;
91
91
  }
92
92
  /** Whether `node` calls the global `Symbol` or `Symbol.for`. */
93
93
  export function isSymbolOrSymbolForCall(c, node) {
94
94
  let left = node.expression;
95
- if (left.kind === 212 /* SyntaxKind.PropertyAccessExpression */ && getText(getName(left)) === 'for')
95
+ if (left.kind === 213 /* SyntaxKind.PropertyAccessExpression */ && getText(getName(left)) === 'for')
96
96
  left = getExpression(left);
97
97
  if (left.kind !== 79 /* SyntaxKind.Identifier */ || getText(left) !== 'Symbol')
98
98
  return false;
@@ -107,12 +107,12 @@ export function checkNewExpression(c, node, checkMode) {
107
107
  checkDeprecatedSignature(c, signature, node);
108
108
  const declaration = signature.declaration;
109
109
  if (declaration !== undefined &&
110
- declaration.kind !== 177 /* SyntaxKind.Constructor */ &&
111
- declaration.kind !== 181 /* SyntaxKind.ConstructSignature */ &&
112
- declaration.kind !== 186 /* SyntaxKind.ConstructorType */) {
110
+ declaration.kind !== 178 /* SyntaxKind.Constructor */ &&
111
+ declaration.kind !== 182 /* SyntaxKind.ConstructSignature */ &&
112
+ declaration.kind !== 187 /* SyntaxKind.ConstructorType */) {
113
113
  // A call signature resolved for `new` makes the result `any`.
114
114
  if (c.noImplicitAny)
115
- c.error(node, 1681 /* Diagnostics.X_new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type */);
115
+ c.error(node, 1700 /* Diagnostics.X_new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type */);
116
116
  return c.anyType;
117
117
  }
118
118
  return getReturnTypeOfSignature(c, signature);
@@ -154,19 +154,19 @@ export function resolveCallSignatureForContext(c, call) {
154
154
  }
155
155
  function resolveSignature(c, node, checkMode) {
156
156
  switch (node.kind) {
157
- case 214 /* SyntaxKind.CallExpression */:
157
+ case 215 /* SyntaxKind.CallExpression */:
158
158
  return resolveCallExpression(c, node, checkMode);
159
- case 215 /* SyntaxKind.NewExpression */:
159
+ case 216 /* SyntaxKind.NewExpression */:
160
160
  return resolveNewExpression(c, node, checkMode);
161
- case 216 /* SyntaxKind.TaggedTemplateExpression */:
161
+ case 217 /* SyntaxKind.TaggedTemplateExpression */:
162
162
  return resolveTaggedTemplateExpression(c, node, checkMode);
163
- case 287 /* SyntaxKind.JsxOpeningElement */:
164
- case 286 /* SyntaxKind.JsxSelfClosingElement */:
165
- case 290 /* SyntaxKind.JsxOpeningFragment */:
163
+ case 288 /* SyntaxKind.JsxOpeningElement */:
164
+ case 287 /* SyntaxKind.JsxSelfClosingElement */:
165
+ case 291 /* SyntaxKind.JsxOpeningFragment */:
166
166
  return resolveJsxOpeningLikeElement(c, node, checkMode);
167
- case 171 /* SyntaxKind.Decorator */:
167
+ case 172 /* SyntaxKind.Decorator */:
168
168
  return resolveDecorator(c, node, checkMode);
169
- case 227 /* SyntaxKind.BinaryExpression */:
169
+ case 228 /* SyntaxKind.BinaryExpression */:
170
170
  return resolveInstanceofExpression(c, node, checkMode);
171
171
  }
172
172
  return resolveUntypedCall(c, node);
@@ -197,12 +197,12 @@ function resolveCallExpression(c, node, checkMode) {
197
197
  const numConstructSignatures = getSignaturesOfType(c, apparentType, 1 /* SignatureKind.Construct */).length;
198
198
  if (isUntypedFunctionCall(c, funcType, apparentType, callSignatures.length, numConstructSignatures)) {
199
199
  if (!isErrorType(c, funcType) && callTypeArguments(node) !== undefined)
200
- c.error(node, 523 /* Diagnostics.Untyped_function_calls_may_not_accept_type_arguments */);
200
+ c.error(node, 530 /* Diagnostics.Untyped_function_calls_may_not_accept_type_arguments */);
201
201
  return resolveUntypedCall(c, node);
202
202
  }
203
203
  if (callSignatures.length === 0) {
204
204
  if (numConstructSignatures !== 0)
205
- c.error(node, 524 /* Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new */, typeToString(c, funcType));
205
+ c.error(node, 531 /* Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new */, typeToString(c, funcType));
206
206
  else
207
207
  invocationError(c, callee, apparentType, 0 /* SignatureKind.Call */);
208
208
  return resolveErrorCall(c, node);
@@ -246,15 +246,15 @@ function resolveNewExpression(c, node, checkMode) {
246
246
  return resolveErrorCall(c, node);
247
247
  if ((expressionType.flags & 1 /* TypeFlags.Any */) !== 0) {
248
248
  if (node.typeArguments !== undefined && node.typeArguments.nodes.length !== 0)
249
- c.error(node, 523 /* Diagnostics.Untyped_function_calls_may_not_accept_type_arguments */);
249
+ c.error(node, 530 /* Diagnostics.Untyped_function_calls_may_not_accept_type_arguments */);
250
250
  return resolveUntypedCall(c, node);
251
251
  }
252
252
  const constructSignatures = getSignaturesOfType(c, expressionType, 1 /* SignatureKind.Construct */);
253
253
  if (constructSignatures.length !== 0) {
254
- if (!isConstructorAccessible(c, node, constructSignatures[0]))
254
+ if (!isConstructorAccessible(c, node, constructSignatures))
255
255
  return resolveErrorCall(c, node);
256
256
  if (someSignature(constructSignatures, (s) => (s.flags & 8 /* SignatureFlags.Abstract */) !== 0)) {
257
- c.error(node, 671 /* Diagnostics.Cannot_create_an_instance_of_an_abstract_class */);
257
+ c.error(node, 678 /* Diagnostics.Cannot_create_an_instance_of_an_abstract_class */);
258
258
  return resolveErrorCall(c, node);
259
259
  }
260
260
  return resolveCall(c, node, constructSignatures, checkMode, 0 /* SignatureFlags.None */, undefined);
@@ -265,9 +265,9 @@ function resolveNewExpression(c, node, checkMode) {
265
265
  const signature = resolveCall(c, node, callSignatures, checkMode, 0 /* SignatureFlags.None */, undefined);
266
266
  if (!c.noImplicitAny) {
267
267
  if (signature.declaration !== undefined && getReturnTypeOfSignature(c, signature) !== c.voidType)
268
- c.error(node, 526 /* Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword */);
268
+ c.error(node, 533 /* Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword */);
269
269
  if (getThisTypeOfSignature(c, signature) === c.voidType)
270
- c.error(node, 813 /* Diagnostics.A_function_that_is_called_with_the_new_keyword_cannot_have_a_this_type_that_is_void */);
270
+ c.error(node, 820 /* Diagnostics.A_function_that_is_called_with_the_new_keyword_cannot_have_a_this_type_that_is_void */);
271
271
  }
272
272
  return signature;
273
273
  }
@@ -312,8 +312,8 @@ function resolveTaggedTemplateExpression(c, node, checkMode) {
312
312
  if (isUntypedFunctionCall(c, tagType, apparentType, callSignatures.length, numConstructSignatures))
313
313
  return resolveUntypedCall(c, node);
314
314
  if (callSignatures.length === 0) {
315
- if (node.parent !== undefined && node.parent.kind === 210 /* SyntaxKind.ArrayLiteralExpression */) {
316
- c.error(tag, 928 /* Diagnostics.It_is_likely_that_you_are_missing_a_comma_to_separate_these_two_template_expressions_They_form_a_tagged_template_expression_which_cannot_be_invoked */);
315
+ if (node.parent !== undefined && node.parent.kind === 211 /* SyntaxKind.ArrayLiteralExpression */) {
316
+ c.error(tag, 935 /* Diagnostics.It_is_likely_that_you_are_missing_a_comma_to_separate_these_two_template_expressions_They_form_a_tagged_template_expression_which_cannot_be_invoked */);
317
317
  return resolveErrorCall(c, node);
318
318
  }
319
319
  invocationError(c, tag, apparentType, 0 /* SignatureKind.Call */);
@@ -335,7 +335,7 @@ function resolveDecorator(c, node, checkMode) {
335
335
  if (isUntypedFunctionCall(c, funcType, apparentType, callSignatures.length, numConstructSignatures))
336
336
  return resolveUntypedCall(c, node);
337
337
  if (isPotentiallyUncalledDecorator(c, node, callSignatures) &&
338
- expression.kind !== 218 /* SyntaxKind.ParenthesizedExpression */) {
338
+ expression.kind !== 219 /* SyntaxKind.ParenthesizedExpression */) {
339
339
  c.error(node, 265 /* Diagnostics.X_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write_0 */, getUncalledDecoratorText(node));
340
340
  return resolveErrorCall(c, node);
341
341
  }
@@ -360,15 +360,15 @@ export function isUntypedFunctionCall(c, funcType, apparentFuncType, numCallSign
360
360
  }
361
361
  export function resolveUntypedCall(c, node) {
362
362
  // Type arguments are checked even though untyped calls can't accept them.
363
- if (node.kind === 214 /* SyntaxKind.CallExpression */ ||
364
- node.kind === 215 /* SyntaxKind.NewExpression */ ||
365
- node.kind === 216 /* SyntaxKind.TaggedTemplateExpression */ ||
363
+ if (node.kind === 215 /* SyntaxKind.CallExpression */ ||
364
+ node.kind === 216 /* SyntaxKind.NewExpression */ ||
365
+ node.kind === 217 /* SyntaxKind.TaggedTemplateExpression */ ||
366
366
  isJsxOpeningLikeElement(node))
367
367
  for (const t of getCallTypeArguments(node))
368
368
  checkSourceElement(c, t);
369
- if (node.kind === 216 /* SyntaxKind.TaggedTemplateExpression */) {
369
+ if (node.kind === 217 /* SyntaxKind.TaggedTemplateExpression */) {
370
370
  const template = node.template;
371
- if (template.kind === 229 /* SyntaxKind.TemplateExpression */)
371
+ if (template.kind === 230 /* SyntaxKind.TemplateExpression */)
372
372
  for (const span of template.templateSpans.nodes)
373
373
  checkExpression(c, getExpression(span));
374
374
  }
@@ -384,29 +384,29 @@ export function resolveErrorCall(c, node) {
384
384
  function invocationError(c, errorTarget, apparentType, kind) {
385
385
  const isCall = kind === 0 /* SignatureKind.Call */;
386
386
  const parent = errorTarget.parent;
387
- const target = errorTarget.kind === 212 /* SyntaxKind.PropertyAccessExpression */ &&
387
+ const target = errorTarget.kind === 213 /* SyntaxKind.PropertyAccessExpression */ &&
388
388
  parent !== undefined &&
389
- parent.kind === 214 /* SyntaxKind.CallExpression */
389
+ parent.kind === 215 /* SyntaxKind.CallExpression */
390
390
  ? getName(errorTarget)
391
391
  : errorTarget;
392
392
  let headMessage = isCall
393
- ? 525 /* Diagnostics.This_expression_is_not_callable */
394
- : 527 /* Diagnostics.This_expression_is_not_constructable */;
393
+ ? 532 /* Diagnostics.This_expression_is_not_callable */
394
+ : 534 /* Diagnostics.This_expression_is_not_constructable */;
395
395
  // A get accessor called as a function.
396
396
  if (parent !== undefined &&
397
- parent.kind === 214 /* SyntaxKind.CallExpression */ &&
397
+ parent.kind === 215 /* SyntaxKind.CallExpression */ &&
398
398
  parent.arguments.nodes.length === 0) {
399
399
  const resolvedSymbol = c.resolvedSymbols.get(errorTarget.id);
400
400
  if (resolvedSymbol !== undefined && (resolvedSymbol.flags & 32768 /* SymbolFlags.GetAccessor */) !== 0)
401
401
  headMessage =
402
- 1386 /* Diagnostics.This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without */;
402
+ 1397 /* Diagnostics.This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without */;
403
403
  }
404
404
  c.addDiagnostic(chainDiagnostic(getInvocationErrorDetails(c, target, apparentType, isCall), headMessage));
405
405
  }
406
406
  function getInvocationErrorDetails(c, target, apparentType, isCall) {
407
407
  const kind = isCall ? 0 /* SignatureKind.Call */ : 1 /* SignatureKind.Construct */;
408
408
  if ((apparentType.flags & 134217728 /* TypeFlags.Union */) === 0)
409
- return createDiagnosticForNode(target, isCall ? 889 /* Diagnostics.Type_0_has_no_call_signatures */ : 893 /* Diagnostics.Type_0_has_no_construct_signatures */, [typeToString(c, apparentType)]);
409
+ return createDiagnosticForNode(target, isCall ? 896 /* Diagnostics.Type_0_has_no_call_signatures */ : 900 /* Diagnostics.Type_0_has_no_construct_signatures */, [typeToString(c, apparentType)]);
410
410
  let diagnostic = undefined;
411
411
  let hasSignatures = false;
412
412
  for (const constituent of typesOf(apparentType)) {
@@ -418,19 +418,19 @@ function getInvocationErrorDetails(c, target, apparentType, isCall) {
418
418
  }
419
419
  else if (diagnostic === undefined) {
420
420
  // The first non-callable constituent.
421
- diagnostic = chainDiagnostic(createDiagnosticForNode(target, isCall ? 889 /* Diagnostics.Type_0_has_no_call_signatures */ : 893 /* Diagnostics.Type_0_has_no_construct_signatures */, [typeToString(c, constituent)]), isCall
422
- ? 888 /* Diagnostics.Not_all_constituents_of_type_0_are_callable */
423
- : 892 /* Diagnostics.Not_all_constituents_of_type_0_are_constructable */, typeToString(c, apparentType));
421
+ diagnostic = chainDiagnostic(createDiagnosticForNode(target, isCall ? 896 /* Diagnostics.Type_0_has_no_call_signatures */ : 900 /* Diagnostics.Type_0_has_no_construct_signatures */, [typeToString(c, constituent)]), isCall
422
+ ? 895 /* Diagnostics.Not_all_constituents_of_type_0_are_callable */
423
+ : 899 /* Diagnostics.Not_all_constituents_of_type_0_are_constructable */, typeToString(c, apparentType));
424
424
  if (hasSignatures)
425
425
  break;
426
426
  }
427
427
  }
428
428
  if (!hasSignatures)
429
- return createDiagnosticForNode(target, isCall ? 887 /* Diagnostics.No_constituent_of_type_0_is_callable */ : 891 /* Diagnostics.No_constituent_of_type_0_is_constructable */, [typeToString(c, apparentType)]);
429
+ return createDiagnosticForNode(target, isCall ? 894 /* Diagnostics.No_constituent_of_type_0_is_callable */ : 898 /* Diagnostics.No_constituent_of_type_0_is_constructable */, [typeToString(c, apparentType)]);
430
430
  return (diagnostic ??
431
431
  createDiagnosticForNode(target, isCall
432
- ? 890 /* Diagnostics.Each_member_of_the_union_type_0_has_signatures_but_none_of_those_signatures_are_compatible_with_each_other */
433
- : 894 /* Diagnostics.Each_member_of_the_union_type_0_has_construct_signatures_but_none_of_those_signatures_are_compatible_with_each_other */, [typeToString(c, apparentType)]));
432
+ ? 897 /* Diagnostics.Each_member_of_the_union_type_0_has_signatures_but_none_of_those_signatures_are_compatible_with_each_other */
433
+ : 901 /* Diagnostics.Each_member_of_the_union_type_0_has_construct_signatures_but_none_of_those_signatures_are_compatible_with_each_other */, [typeToString(c, apparentType)]));
434
434
  }
435
435
  function checkNonNullTypeForCall(c, t, node) {
436
436
  return checkNonNullTypeEx(c, t, node, true);
@@ -456,7 +456,7 @@ export class SyntheticExpression extends Node {
456
456
  isSpread;
457
457
  tupleNameSource;
458
458
  constructor(parent, type, isSpread, tupleNameSource) {
459
- super(238 /* SyntaxKind.SyntheticExpression */);
459
+ super(239 /* SyntaxKind.SyntheticExpression */);
460
460
  this.parent = parent;
461
461
  this.pos = parent.pos;
462
462
  this.end = parent.end;
@@ -473,12 +473,12 @@ export class SyntheticExpression extends Node {
473
473
  }
474
474
  }
475
475
  function getCallArgumentNodes(node) {
476
- if (node.kind === 227 /* SyntaxKind.BinaryExpression */)
476
+ if (node.kind === 228 /* SyntaxKind.BinaryExpression */)
477
477
  return [node.left];
478
- if (node.kind === 216 /* SyntaxKind.TaggedTemplateExpression */) {
478
+ if (node.kind === 217 /* SyntaxKind.TaggedTemplateExpression */) {
479
479
  const template = node.template;
480
480
  const args = [template];
481
- if (template.kind === 229 /* SyntaxKind.TemplateExpression */)
481
+ if (template.kind === 230 /* SyntaxKind.TemplateExpression */)
482
482
  for (const span of template.templateSpans.nodes)
483
483
  args.push(getExpression(span));
484
484
  return args;
@@ -489,11 +489,11 @@ function getCallArgumentNodes(node) {
489
489
  /** The arguments of a call, with spreads of tuples expanded and a tagged template's strings first. */
490
490
  export function getEffectiveCallArguments(c, node) {
491
491
  // A fragment's attributes have no `children` yet, like those of `<React.Fragment>`.
492
- if (node.kind === 290 /* SyntaxKind.JsxOpeningFragment */)
492
+ if (node.kind === 291 /* SyntaxKind.JsxOpeningFragment */)
493
493
  return [new SyntheticExpression(node, c.emptyFreshJsxObjectType, false, undefined)];
494
494
  if (isJsxOpeningLikeElement(node))
495
495
  return getEffectiveJsxArguments(node);
496
- if (node.kind === 171 /* SyntaxKind.Decorator */) {
496
+ if (node.kind === 172 /* SyntaxKind.Decorator */) {
497
497
  // One synthetic argument per parameter of the decorator's call signature.
498
498
  const expression = node.expression;
499
499
  const args = [];
@@ -501,10 +501,10 @@ export function getEffectiveCallArguments(c, node) {
501
501
  args.push(new SyntheticExpression(expression, t, false, undefined));
502
502
  return args;
503
503
  }
504
- if (node.kind === 216 /* SyntaxKind.TaggedTemplateExpression */) {
504
+ if (node.kind === 217 /* SyntaxKind.TaggedTemplateExpression */) {
505
505
  const template = node.template;
506
506
  const args = [new SyntheticExpression(template, getGlobalTemplateStringsArrayType(c), false, undefined)];
507
- if (template.kind === 229 /* SyntaxKind.TemplateExpression */)
507
+ if (template.kind === 230 /* SyntaxKind.TemplateExpression */)
508
508
  for (const span of template.templateSpans.nodes)
509
509
  args.push(getExpression(span));
510
510
  return args;
@@ -518,7 +518,7 @@ export function getEffectiveCallArguments(c, node) {
518
518
  for (let i = spreadIndex; i < args.length; i++) {
519
519
  const arg = args[i];
520
520
  // Spread expressions never have a contextual type, so caching is safe.
521
- const spreadType = arg.kind === 231 /* SyntaxKind.SpreadElement */
521
+ const spreadType = arg.kind === 232 /* SyntaxKind.SpreadElement */
522
522
  ? c.flowLoopStack.length !== 0
523
523
  ? checkExpression(c, arg.expression)
524
524
  : checkExpressionCached(c, arg.expression)
@@ -538,7 +538,7 @@ export function getEffectiveCallArguments(c, node) {
538
538
  }
539
539
  /** Checks an argument with the parameter type as its contextual type. */
540
540
  function checkArgument(c, arg, paramType, context, checkMode) {
541
- if (arg.kind === 238 /* SyntaxKind.SyntheticExpression */)
541
+ if (arg.kind === 239 /* SyntaxKind.SyntheticExpression */)
542
542
  return checkSyntheticExpression(c, arg);
543
543
  return checkExpressionWithContextualType(c, arg, paramType, context, checkMode);
544
544
  }
@@ -555,8 +555,8 @@ function getSpreadArgumentIndex(args) {
555
555
  return -1;
556
556
  }
557
557
  function isSpreadArgument(arg) {
558
- return (arg.kind === 231 /* SyntaxKind.SpreadElement */ ||
559
- (arg.kind === 238 /* SyntaxKind.SyntheticExpression */ && arg.isSpread));
558
+ return (arg.kind === 232 /* SyntaxKind.SpreadElement */ ||
559
+ (arg.kind === 239 /* SyntaxKind.SyntheticExpression */ && arg.isSpread));
560
560
  }
561
561
  /** The rest arguments from `index` as a tuple, or an array for a trailing spread to a rest parameter. */
562
562
  function getSpreadArgumentType(c, call, args, index, argCount, restType, context, checkMode) {
@@ -565,12 +565,12 @@ function getSpreadArgumentType(c, call, args, index, argCount, restType, context
565
565
  const arg = args[argCount - 1];
566
566
  if (isSpreadArgument(arg)) {
567
567
  // A spread in the last position to a rest parameter: both are `...x` forms.
568
- const spreadType = arg.kind === 238 /* SyntaxKind.SyntheticExpression */
568
+ const spreadType = arg.kind === 239 /* SyntaxKind.SyntheticExpression */
569
569
  ? arg.type
570
570
  : checkExpressionWithContextualType(c, arg.expression, restType, context, checkMode);
571
571
  if (isArrayLikeType(c, spreadType))
572
572
  return getMutableArrayOrTupleType(c, spreadType);
573
- const errorNode = arg.kind === 231 /* SyntaxKind.SpreadElement */ ? arg.expression : arg;
573
+ const errorNode = arg.kind === 232 /* SyntaxKind.SpreadElement */ ? arg.expression : arg;
574
574
  return createArrayTypeEx(c, checkIteratedTypeOrElementType(c, 33 /* IterationUse.Spread */, spreadType, c.undefinedType, errorNode), inConstContext);
575
575
  }
576
576
  }
@@ -579,7 +579,7 @@ function getSpreadArgumentType(c, call, args, index, argCount, restType, context
579
579
  for (let i = index; i < argCount; i++) {
580
580
  const arg = args[i];
581
581
  if (isSpreadArgument(arg)) {
582
- const spreadType = arg.kind === 238 /* SyntaxKind.SyntheticExpression */
582
+ const spreadType = arg.kind === 239 /* SyntaxKind.SyntheticExpression */
583
583
  ? arg.type
584
584
  : checkExpression(c, arg.expression);
585
585
  if (isArrayLikeType(c, spreadType)) {
@@ -587,7 +587,7 @@ function getSpreadArgumentType(c, call, args, index, argCount, restType, context
587
587
  infos.push(new TupleElementInfo(8 /* ElementFlags.Variadic */, undefined));
588
588
  }
589
589
  else {
590
- const errorNode = arg.kind === 231 /* SyntaxKind.SpreadElement */ ? arg.expression : arg;
590
+ const errorNode = arg.kind === 232 /* SyntaxKind.SpreadElement */ ? arg.expression : arg;
591
591
  types.push(checkIteratedTypeOrElementType(c, 33 /* IterationUse.Spread */, spreadType, c.undefinedType, errorNode));
592
592
  infos.push(new TupleElementInfo(4 /* ElementFlags.Rest */, undefined));
593
593
  }
@@ -600,7 +600,7 @@ function getSpreadArgumentType(c, call, args, index, argCount, restType, context
600
600
  const hasPrimitiveContextualType = inConstContext ||
601
601
  maybeTypeOfKind(contextualType, 12713980 /* TypeFlags.Primitive */ | 2097152 /* TypeFlags.Index */ | 4194304 /* TypeFlags.TemplateLiteral */ | 8388608 /* TypeFlags.StringMapping */);
602
602
  types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(c, argType) : getWidenedLiteralType(c, argType));
603
- infos.push(new TupleElementInfo(1 /* ElementFlags.Required */, arg.kind === 238 /* SyntaxKind.SyntheticExpression */ ? arg.tupleNameSource : undefined));
603
+ infos.push(new TupleElementInfo(1 /* ElementFlags.Required */, arg.kind === 239 /* SyntaxKind.SyntheticExpression */ ? arg.tupleNameSource : undefined));
604
604
  }
605
605
  return createTupleTypeEx(c, types, infos, inConstContext && !someType(restType, (t) => isMutableArrayLikeType(c, t)));
606
606
  }
@@ -626,6 +626,8 @@ class CallState {
626
626
  candidates;
627
627
  argCheckMode = 0 /* CheckMode.Normal */;
628
628
  isSingleNonGenericCandidate = false;
629
+ /** The call is resolved while its own resolution is in progress. */
630
+ recursiveResolution = false;
629
631
  candidatesForArgumentError = [];
630
632
  candidateForArgumentArityError = undefined;
631
633
  candidateForTypeArgumentError = undefined;
@@ -637,9 +639,9 @@ class CallState {
637
639
  }
638
640
  }
639
641
  function getCallTypeArguments(node) {
640
- if (node.kind === 290 /* SyntaxKind.JsxOpeningFragment */ || node.kind === 171 /* SyntaxKind.Decorator */)
642
+ if (node.kind === 291 /* SyntaxKind.JsxOpeningFragment */ || node.kind === 172 /* SyntaxKind.Decorator */)
641
643
  return [];
642
- if (node.kind === 214 /* SyntaxKind.CallExpression */ && node.expression.kind === 107 /* SyntaxKind.SuperKeyword */)
644
+ if (node.kind === 215 /* SyntaxKind.CallExpression */ && node.expression.kind === 107 /* SyntaxKind.SuperKeyword */)
643
645
  return [];
644
646
  const list = getTypeArgumentList(node);
645
647
  return list !== undefined ? list.nodes : [];
@@ -656,14 +658,27 @@ export function resolveCall(c, node, signatures, checkMode, callChainFlags, head
656
658
  // included in a second pass with their contextual types fixed.
657
659
  s.isSingleNonGenericCandidate = candidates.length === 1 && candidates[0].typeParameters.length === 0;
658
660
  // Decorator arguments are synthetic, so never context sensitive.
659
- if (node.kind !== 171 /* SyntaxKind.Decorator */ && !s.isSingleNonGenericCandidate && someContextSensitive(c, s.args))
661
+ if (node.kind !== 172 /* SyntaxKind.Decorator */ && !s.isSingleNonGenericCandidate && someContextSensitive(c, s.args))
660
662
  s.argCheckMode = 4 /* CheckMode.SkipContextSensitive */;
661
663
  // A subtype pass picks the best overload; assignability decides whether the call is an error.
662
664
  let result = undefined;
665
+ const callResolutionDepth = c.callResolutionDepth;
666
+ const callResolutionStack = c.callResolutionStack;
667
+ for (let i = 0; i < callResolutionDepth; i++)
668
+ if (callResolutionStack[i] === node) {
669
+ s.recursiveResolution = true;
670
+ break;
671
+ }
672
+ if (callResolutionDepth < callResolutionStack.length)
673
+ callResolutionStack[callResolutionDepth] = node;
674
+ else
675
+ callResolutionStack.push(node);
676
+ c.callResolutionDepth = callResolutionDepth + 1;
663
677
  if (candidates.length > 1)
664
678
  result = chooseOverload(c, s, c.subtypeRelation);
665
679
  if (result === undefined)
666
680
  result = chooseOverload(c, s, c.assignableRelation);
681
+ c.callResolutionDepth = callResolutionDepth;
667
682
  if (result !== undefined)
668
683
  return result;
669
684
  result = getCandidateForOverloadFailure(c, node, s.candidates, s.args, checkMode);
@@ -709,7 +724,11 @@ export function reorderCandidates(c, signatures, callChainFlags) {
709
724
  spliceIndex = index;
710
725
  if (callChainFlags !== 0)
711
726
  signature = getOptionalCallSignature(c, signature, callChainFlags);
712
- result.splice(spliceIndex, 0, signature);
727
+ // Most signatures go at the end, where a push is cheaper than an inserting splice.
728
+ if (spliceIndex === result.length)
729
+ result.push(signature);
730
+ else
731
+ result.splice(spliceIndex, 0, signature);
713
732
  }
714
733
  return result;
715
734
  }
@@ -760,7 +779,12 @@ function chooseOverload(c, s, relation) {
760
779
  }
761
780
  }
762
781
  else {
763
- inferenceContext = createInferenceContext(c, candidate.typeParameters, candidate, isInJSFile(s.node) ? 2 /* InferenceFlags.AnyDefault */ : 0 /* InferenceFlags.None */, undefined);
782
+ inferenceContext = createInferenceContext(c, candidate.typeParameters, candidate,
783
+ // A recursive resolution of a call with one candidate skips constraint checks during inference, which
784
+ // would otherwise report circularities.
785
+ (s.recursiveResolution && s.candidates.length === 1
786
+ ? 8 /* InferenceFlags.NoConstraintChecks */
787
+ : 0 /* InferenceFlags.None */) | (isInJSFile(s.node) ? 2 /* InferenceFlags.AnyDefault */ : 0 /* InferenceFlags.None */), undefined);
764
788
  typeArgumentTypes = inferTypeArguments(c, s.node, candidate, s.args, s.argCheckMode | 8 /* CheckMode.SkipGenericFunctions */, inferenceContext);
765
789
  if ((inferenceContext.flags & 4 /* InferenceFlags.SkippedGenericFunction */) !== 0)
766
790
  s.argCheckMode |= 8 /* CheckMode.SkipGenericFunctions */;
@@ -804,7 +828,7 @@ function isInJSFile(node) {
804
828
  return node !== undefined && (node.flags & 65536 /* NodeFlags.JavaScriptFile */) !== 0;
805
829
  }
806
830
  function hasCorrectArity(c, node, args, signature) {
807
- if (node.kind === 290 /* SyntaxKind.JsxOpeningFragment */)
831
+ if (node.kind === 291 /* SyntaxKind.JsxOpeningFragment */)
808
832
  return true;
809
833
  let argCount;
810
834
  let callIsIncomplete = false;
@@ -821,10 +845,10 @@ function hasCorrectArity(c, node, args, signature) {
821
845
  // A component's extra parameters, such as a legacy context, are provided by the library.
822
846
  effectiveMinimumArguments = Math.min(effectiveMinimumArguments, 1);
823
847
  }
824
- else if (node.kind === 216 /* SyntaxKind.TaggedTemplateExpression */) {
848
+ else if (node.kind === 217 /* SyntaxKind.TaggedTemplateExpression */) {
825
849
  argCount = args.length;
826
850
  const template = node.template;
827
- if (template.kind === 229 /* SyntaxKind.TemplateExpression */) {
851
+ if (template.kind === 230 /* SyntaxKind.TemplateExpression */) {
828
852
  // A template without a tail literal makes the call incomplete.
829
853
  const spans = template.templateSpans.nodes;
830
854
  const literal = spans[spans.length - 1].literal;
@@ -833,10 +857,10 @@ function hasCorrectArity(c, node, args, signature) {
833
857
  else
834
858
  callIsIncomplete = isUnterminatedLiteral(template);
835
859
  }
836
- else if (node.kind === 171 /* SyntaxKind.Decorator */) {
860
+ else if (node.kind === 172 /* SyntaxKind.Decorator */) {
837
861
  argCount = getDecoratorArgumentCount(c, node, signature);
838
862
  }
839
- else if (node.kind === 215 /* SyntaxKind.NewExpression */ && node.arguments === undefined) {
863
+ else if (node.kind === 216 /* SyntaxKind.NewExpression */ && node.arguments === undefined) {
840
864
  // `new C`
841
865
  return getMinArgumentCount(c, signature) === 0;
842
866
  }
@@ -882,7 +906,7 @@ function checkTypeArguments(c, signature, typeArgumentNodes, reportErrors, headM
882
906
  continue;
883
907
  const typeArgument = typeArgumentTypes[i];
884
908
  const diagnostics = [];
885
- if (!checkTypeRelatedTo(c, typeArgument, getTypeWithThisArgument(c, instantiateType(c, constraint, mapper), typeArgument, false), c.assignableRelation, reportErrors ? typeArgumentNodes[i] : undefined, headMessage ?? 520 /* Diagnostics.Type_0_does_not_satisfy_the_constraint_1 */, diagnostics)) {
909
+ if (!checkTypeRelatedTo(c, typeArgument, getTypeWithThisArgument(c, instantiateType(c, constraint, mapper), typeArgument, false), c.assignableRelation, reportErrors ? typeArgumentNodes[i] : undefined, headMessage ?? 527 /* Diagnostics.Type_0_does_not_satisfy_the_constraint_1 */, diagnostics)) {
886
910
  if (diagnostics.length !== 0)
887
911
  c.addDiagnostic(diagnostics[0]);
888
912
  return undefined;
@@ -891,26 +915,26 @@ function checkTypeArguments(c, signature, typeArgumentNodes, reportErrors, headM
891
915
  return typeArgumentTypes;
892
916
  }
893
917
  function isSignatureApplicable(c, node, args, signature, relation, checkMode, reportErrors, diagnosticOutput) {
894
- if (isJsxOpeningLikeElement(node) || node.kind === 290 /* SyntaxKind.JsxOpeningFragment */)
918
+ if (isJsxOpeningLikeElement(node) || node.kind === 291 /* SyntaxKind.JsxOpeningFragment */)
895
919
  return checkApplicableSignatureForJsxCallLikeElement(c, node, signature, relation, checkMode, reportErrors, diagnosticOutput);
896
920
  const thisType = getThisTypeOfSignature(c, signature);
897
921
  if (thisType !== undefined &&
898
922
  thisType !== c.voidType &&
899
- !(node.kind === 215 /* SyntaxKind.NewExpression */ ||
900
- (node.kind === 214 /* SyntaxKind.CallExpression */ && isSuperProperty(getExpression(node))))) {
923
+ !(node.kind === 216 /* SyntaxKind.NewExpression */ ||
924
+ (node.kind === 215 /* SyntaxKind.CallExpression */ && isSuperProperty(getExpression(node))))) {
901
925
  // Without an `x.f` callee the `this` argument is `void`.
902
926
  const thisArgumentNode = getThisArgumentOfCall(c, node);
903
927
  const thisArgumentType = getThisArgumentType(c, thisArgumentNode);
904
928
  const errorNode = reportErrors ? (thisArgumentNode ?? node) : undefined;
905
- if (!checkTypeRelatedTo(c, thisArgumentType, thisType, relation, errorNode, 817 /* Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1 */, diagnosticOutput))
929
+ if (!checkTypeRelatedTo(c, thisArgumentType, thisType, relation, errorNode, 824 /* Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1 */, diagnosticOutput))
906
930
  return false;
907
931
  }
908
- const headMessage = 521 /* Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1 */;
932
+ const headMessage = 528 /* Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1 */;
909
933
  const restType = getNonArrayRestType(c, signature);
910
934
  const argCount = restType !== undefined ? Math.min(getParameterCount(c, signature) - 1, args.length) : args.length;
911
935
  for (let i = 0; i < argCount; i++) {
912
936
  const arg = args[i];
913
- if (arg.kind === 233 /* SyntaxKind.OmittedExpression */)
937
+ if (arg.kind === 234 /* SyntaxKind.OmittedExpression */)
914
938
  continue;
915
939
  const paramType = getTypeAtPosition(c, signature, i);
916
940
  const argType = checkArgument(c, arg, paramType, undefined, checkMode);
@@ -956,20 +980,20 @@ function isUnterminatedLiteral(node) {
956
980
  return false;
957
981
  }
958
982
  function isSuperProperty(node) {
959
- return ((node.kind === 212 /* SyntaxKind.PropertyAccessExpression */ || node.kind === 213 /* SyntaxKind.ElementAccessExpression */) &&
983
+ return ((node.kind === 213 /* SyntaxKind.PropertyAccessExpression */ || node.kind === 214 /* SyntaxKind.ElementAccessExpression */) &&
960
984
  getExpression(node).kind === 107 /* SyntaxKind.SuperKeyword */);
961
985
  }
962
986
  /** The `this` argument of `x.f(...)` and `x[f](...)`. */
963
987
  function getThisArgumentOfCall(c, node) {
964
988
  // `x instanceof C` calls `C[Symbol.hasInstance](x)`.
965
- if (node.kind === 227 /* SyntaxKind.BinaryExpression */)
989
+ if (node.kind === 228 /* SyntaxKind.BinaryExpression */)
966
990
  return node.right;
967
991
  let expression = undefined;
968
- if (node.kind === 214 /* SyntaxKind.CallExpression */)
992
+ if (node.kind === 215 /* SyntaxKind.CallExpression */)
969
993
  expression = node.expression;
970
- else if (node.kind === 216 /* SyntaxKind.TaggedTemplateExpression */)
994
+ else if (node.kind === 217 /* SyntaxKind.TaggedTemplateExpression */)
971
995
  expression = node.tag;
972
- else if (node.kind === 171 /* SyntaxKind.Decorator */ && !c.legacyDecorators)
996
+ else if (node.kind === 172 /* SyntaxKind.Decorator */ && !c.legacyDecorators)
973
997
  expression = node.expression;
974
998
  if (expression === undefined)
975
999
  return undefined;
@@ -979,13 +1003,13 @@ function getThisArgumentOfCall(c, node) {
979
1003
  function skipOuterExpressionsForCall(node) {
980
1004
  for (;;) {
981
1005
  switch (node.kind) {
982
- case 218 /* SyntaxKind.ParenthesizedExpression */:
983
- case 235 /* SyntaxKind.AsExpression */:
984
- case 217 /* SyntaxKind.TypeAssertionExpression */:
985
- case 239 /* SyntaxKind.SatisfiesExpression */:
986
- case 236 /* SyntaxKind.NonNullExpression */:
987
- case 234 /* SyntaxKind.ExpressionWithTypeArguments */:
988
- case 348 /* SyntaxKind.PartiallyEmittedExpression */:
1006
+ case 219 /* SyntaxKind.ParenthesizedExpression */:
1007
+ case 236 /* SyntaxKind.AsExpression */:
1008
+ case 218 /* SyntaxKind.TypeAssertionExpression */:
1009
+ case 240 /* SyntaxKind.SatisfiesExpression */:
1010
+ case 237 /* SyntaxKind.NonNullExpression */:
1011
+ case 235 /* SyntaxKind.ExpressionWithTypeArguments */:
1012
+ case 349 /* SyntaxKind.PartiallyEmittedExpression */:
989
1013
  node = getExpression(node);
990
1014
  continue;
991
1015
  }
@@ -1014,7 +1038,7 @@ function inferTypeArguments(c, node, signature, args, checkMode, context) {
1014
1038
  }
1015
1039
  }
1016
1040
  // Decorators have no contextual type.
1017
- const contextualType = node.kind === 171 /* SyntaxKind.Decorator */
1041
+ const contextualType = node.kind === 172 /* SyntaxKind.Decorator */
1018
1042
  ? undefined
1019
1043
  : getContextualTypeEx(c, node, skipBindingPatterns ? 8 /* ContextFlags.SkipBindingPatterns */ : 0 /* ContextFlags.None */);
1020
1044
  if (contextualType !== undefined) {
@@ -1034,14 +1058,14 @@ function inferTypeArguments(c, node, signature, args, checkMode, context) {
1034
1058
  ? getOrCreateTypeFromSignature(c, getSignatureInstantiationWithoutFillingInTypeArguments(c, contextualSignature, contextualSignature.typeParameters))
1035
1059
  : instantiatedType;
1036
1060
  // Return type inferences have the lowest priority.
1037
- inferTypes(c, context.inferences, inferenceSourceType, inferenceTargetType, 128 /* InferencePriority.ReturnType */, false);
1061
+ inferTypesFromUnstarted(c, signature, context.inferences, inferenceSourceType, inferenceTargetType, 128 /* InferencePriority.ReturnType */);
1038
1062
  }
1039
1063
  // A separate pass for the mapper used to instantiate generic contextual types, from the outer
1040
1064
  // return mapper so that inferences can't reference the type parameters being inferred.
1041
1065
  const returnContext = createInferenceContext(c, signature.typeParameters, signature, context.flags, undefined);
1042
1066
  const outerReturnMapper = outerContext !== undefined ? createOuterReturnMapper(c, outerContext) : undefined;
1043
1067
  const returnSourceType = instantiateType(c, contextualType, outerReturnMapper);
1044
- inferTypes(c, returnContext.inferences, returnSourceType, inferenceTargetType, 0 /* InferencePriority.None */, false);
1068
+ inferTypesFromUnstarted(c, signature, returnContext.inferences, returnSourceType, inferenceTargetType, 0 /* InferencePriority.None */);
1045
1069
  context.returnMapper = someInferenceHasCandidates(returnContext.inferences)
1046
1070
  ? getMapperFromContext(cloneInferredPartOfContext(c, returnContext))
1047
1071
  : undefined;
@@ -1061,7 +1085,7 @@ function inferTypeArguments(c, node, signature, args, checkMode, context) {
1061
1085
  inferTypes(c, context.inferences, getThisArgumentType(c, getThisArgumentOfCall(c, node)), thisType, 0 /* InferencePriority.None */, false);
1062
1086
  for (let i = 0; i < argCount; i++) {
1063
1087
  const arg = args[i];
1064
- if (arg.kind === 233 /* SyntaxKind.OmittedExpression */)
1088
+ if (arg.kind === 234 /* SyntaxKind.OmittedExpression */)
1065
1089
  continue;
1066
1090
  const paramType = getTypeAtPosition(c, signature, i);
1067
1091
  if (couldContainTypeVariables(c, paramType)) {
@@ -1218,13 +1242,13 @@ function reportCallResolutionErrors(c, s, signatures, headMessage) {
1218
1242
  isSignatureApplicable(c, s.node, s.args, last, c.assignableRelation, 0 /* CheckMode.Normal */, true, diagnostics);
1219
1243
  for (let diagnostic of diagnostics) {
1220
1244
  if (s.candidatesForArgumentError.length > 1) {
1221
- diagnostic = chainDiagnostic(diagnostic, 902 /* Diagnostics.The_last_overload_gave_the_following_error */);
1222
- diagnostic = chainDiagnostic(diagnostic, 901 /* Diagnostics.No_overload_matches_this_call */);
1245
+ diagnostic = chainDiagnostic(diagnostic, 909 /* Diagnostics.The_last_overload_gave_the_following_error */);
1246
+ diagnostic = chainDiagnostic(diagnostic, 908 /* Diagnostics.No_overload_matches_this_call */);
1223
1247
  }
1224
1248
  if (headMessage !== undefined)
1225
1249
  diagnostic = chainDiagnostic(diagnostic, headMessage);
1226
1250
  if (last.declaration !== undefined && s.candidatesForArgumentError.length > 1)
1227
- diagnostic.addRelatedInfo(createDiagnosticForNode(last.declaration, 903 /* Diagnostics.The_last_overload_is_declared_here */, []));
1251
+ diagnostic.addRelatedInfo(createDiagnosticForNode(last.declaration, 910 /* Diagnostics.The_last_overload_is_declared_here */, []));
1228
1252
  addImplementationSuccessElaboration(c, s, last, diagnostic);
1229
1253
  c.addDiagnostic(diagnostic);
1230
1254
  }
@@ -1233,7 +1257,7 @@ function reportCallResolutionErrors(c, s, signatures, headMessage) {
1233
1257
  c.addDiagnostic(getArgumentArityError(c, s.node, [s.candidateForArgumentArityError], s.args, headMessage));
1234
1258
  else if (s.candidateForTypeArgumentError !== undefined)
1235
1259
  checkTypeArguments(c, s.candidateForTypeArgumentError, getCallTypeArguments(s.node), true, headMessage);
1236
- else if (s.node.kind !== 290 /* SyntaxKind.JsxOpeningFragment */) {
1260
+ else if (s.node.kind !== 291 /* SyntaxKind.JsxOpeningFragment */) {
1237
1261
  const withCorrectTypeArgumentArity = [];
1238
1262
  for (const sig of signatures)
1239
1263
  if (hasCorrectTypeArgumentArity(c, sig, s.typeArguments))
@@ -1266,15 +1290,35 @@ function addImplementationSuccessElaboration(c, s, failed, diagnostic) {
1266
1290
  localState.candidateForArgumentArityError = s.candidateForArgumentArityError;
1267
1291
  localState.candidateForTypeArgumentError = s.candidateForTypeArgumentError;
1268
1292
  if (chooseOverload(c, localState, c.assignableRelation) !== undefined)
1269
- diagnostic.addRelatedInfo(createDiagnosticForNode(implementation, 925 /* Diagnostics.The_call_would_have_succeeded_against_this_implementation_but_implementation_signatures_of_overloads_are_not_externally_visible */, []));
1293
+ diagnostic.addRelatedInfo(createDiagnosticForNode(implementation, 932 /* Diagnostics.The_call_would_have_succeeded_against_this_implementation_but_implementation_signatures_of_overloads_are_not_externally_visible */, []));
1270
1294
  }
1271
1295
  function withHeadMessage(diagnostic, headMessage) {
1272
1296
  return headMessage !== undefined ? chainDiagnostic(diagnostic, headMessage) : diagnostic;
1273
1297
  }
1298
+ /** Whether `node` calls the `resolve` parameter of an executor passed to the global `new Promise`. */
1299
+ function isPromiseResolveArityError(c, node) {
1300
+ if (node.kind !== 215 /* SyntaxKind.CallExpression */)
1301
+ return false;
1302
+ const callee = getExpression(node);
1303
+ if (callee.kind !== 79 /* SyntaxKind.Identifier */)
1304
+ return false;
1305
+ const symbol = resolveName(c, callee, getText(callee), 111551 /* SymbolFlags.Value */, undefined, false, false);
1306
+ const declaration = symbol?.valueDeclaration;
1307
+ if (declaration === undefined ||
1308
+ declaration.kind !== 171 /* SyntaxKind.Parameter */ ||
1309
+ !isFunctionExpressionOrArrowFunction(declaration.parent) ||
1310
+ declaration.parent.parent?.kind !== 216 /* SyntaxKind.NewExpression */)
1311
+ return false;
1312
+ const constructor = getExpression(declaration.parent.parent);
1313
+ if (constructor === undefined || constructor.kind !== 79 /* SyntaxKind.Identifier */)
1314
+ return false;
1315
+ const globalPromiseSymbol = getGlobalValueSymbol(c, 'Promise', false);
1316
+ return globalPromiseSymbol !== undefined && getResolvedSymbol(c, constructor) === globalPromiseSymbol;
1317
+ }
1274
1318
  function getArgumentArityError(c, node, signatures, args, headMessage) {
1275
1319
  const spreadIndex = getSpreadArgumentIndex(args);
1276
1320
  if (spreadIndex > -1)
1277
- return createDiagnosticForNode(args[spreadIndex], 711 /* Diagnostics.A_spread_argument_must_either_have_a_tuple_type_or_be_passed_to_a_rest_parameter */, []);
1321
+ return createDiagnosticForNode(args[spreadIndex], 718 /* Diagnostics.A_spread_argument_must_either_have_a_tuple_type_or_be_passed_to_a_rest_parameter */, []);
1278
1322
  let minCount = Number.MAX_SAFE_INTEGER;
1279
1323
  let maxCount = Number.MIN_SAFE_INTEGER;
1280
1324
  let maxBelow = Number.MIN_SAFE_INTEGER;
@@ -1305,17 +1349,23 @@ function getArgumentArityError(c, node, signatures, args, headMessage) {
1305
1349
  : minCount < maxCount
1306
1350
  ? minCount + '-' + maxCount
1307
1351
  : String(minCount);
1352
+ // `resolve()` without an argument, where `resolve` is the parameter of a `new Promise` executor.
1353
+ const isVoidPromiseError = !hasRestParameter && parameterRange === '1' && args.length === 0 && isPromiseResolveArityError(c, node);
1308
1354
  const errorNode = getErrorNodeForCallNode(node);
1309
- const message = node.kind === 171 /* SyntaxKind.Decorator */
1355
+ if (isVoidPromiseError && isInJSFile(node))
1356
+ return createDiagnosticForNode(errorNode, 948 /* Diagnostics.Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_without_arguments */, []);
1357
+ const message = node.kind === 172 /* SyntaxKind.Decorator */
1310
1358
  ? hasRestParameter
1311
1359
  ? 228 /* Diagnostics.The_runtime_will_invoke_the_decorator_with_1_arguments_but_the_decorator_expects_at_least_0 */
1312
1360
  : 227 /* Diagnostics.The_runtime_will_invoke_the_decorator_with_1_arguments_but_the_decorator_expects_0 */
1313
1361
  : hasRestParameter
1314
- ? 710 /* Diagnostics.Expected_at_least_0_arguments_but_got_1 */
1315
- : 709 /* Diagnostics.Expected_0_arguments_but_got_1 */;
1362
+ ? 717 /* Diagnostics.Expected_at_least_0_arguments_but_got_1 */
1363
+ : isVoidPromiseError
1364
+ ? 933 /* Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise */
1365
+ : 716 /* Diagnostics.Expected_0_arguments_but_got_1 */;
1316
1366
  if (minCount < args.length && args.length < maxCount)
1317
1367
  // Between min and max, but no overload matches.
1318
- return withHeadMessage(createDiagnosticForNode(errorNode, 726 /* Diagnostics.No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments */, [String(args.length), String(maxBelow), String(minAbove)]), headMessage);
1368
+ return withHeadMessage(createDiagnosticForNode(errorNode, 733 /* Diagnostics.No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments */, [String(args.length), String(maxBelow), String(minAbove)]), headMessage);
1319
1369
  if (args.length < minCount) {
1320
1370
  // Too short: the error spans the callee.
1321
1371
  const diagnostic = withHeadMessage(createDiagnosticForNode(errorNode, message, [parameterRange, String(args.length)]), headMessage);
@@ -1325,14 +1375,14 @@ function getArgumentArityError(c, node, signatures, args, headMessage) {
1325
1375
  const parameter = params !== undefined && index < params.nodes.length ? params.nodes[index] : undefined;
1326
1376
  if (parameter !== undefined) {
1327
1377
  const name = getName(parameter);
1328
- if (name.kind === 207 /* SyntaxKind.ObjectBindingPattern */ || name.kind === 208 /* SyntaxKind.ArrayBindingPattern */)
1329
- diagnostic.addRelatedInfo(createDiagnosticForNode(parameter, 1364 /* Diagnostics.An_argument_matching_this_binding_pattern_was_not_provided */, []));
1378
+ if (name.kind === 208 /* SyntaxKind.ObjectBindingPattern */ || name.kind === 209 /* SyntaxKind.ArrayBindingPattern */)
1379
+ diagnostic.addRelatedInfo(createDiagnosticForNode(parameter, 1375 /* Diagnostics.An_argument_matching_this_binding_pattern_was_not_provided */, []));
1330
1380
  else if (parameter.dotDotDotToken !== undefined)
1331
- diagnostic.addRelatedInfo(createDiagnosticForNode(parameter, 1388 /* Diagnostics.Arguments_for_the_rest_parameter_0_were_not_provided */, [
1381
+ diagnostic.addRelatedInfo(createDiagnosticForNode(parameter, 1399 /* Diagnostics.Arguments_for_the_rest_parameter_0_were_not_provided */, [
1332
1382
  getTextOfName(name),
1333
1383
  ]));
1334
1384
  else
1335
- diagnostic.addRelatedInfo(createDiagnosticForNode(parameter, 1363 /* Diagnostics.An_argument_for_0_was_not_provided */, [getTextOfName(name)]));
1385
+ diagnostic.addRelatedInfo(createDiagnosticForNode(parameter, 1374 /* Diagnostics.An_argument_for_0_was_not_provided */, [getTextOfName(name)]));
1336
1386
  }
1337
1387
  return diagnostic;
1338
1388
  }
@@ -1362,7 +1412,7 @@ function getTypeArgumentArityError(c, node, signatures, typeArguments, headMessa
1362
1412
  const minCount = getMinTypeArgumentCount(c, sig.typeParameters);
1363
1413
  const maxCount = sig.typeParameters.length;
1364
1414
  const expected = minCount < maxCount ? minCount + '-' + maxCount : String(minCount);
1365
- diagnostic = new Diagnostic(file.diagnosticFile(), pos, end, 712 /* Diagnostics.Expected_0_type_arguments_but_got_1 */, [
1415
+ diagnostic = new Diagnostic(file.diagnosticFile(), pos, end, 719 /* Diagnostics.Expected_0_type_arguments_but_got_1 */, [
1366
1416
  expected,
1367
1417
  String(argCount),
1368
1418
  ]);
@@ -1380,8 +1430,8 @@ function getTypeArgumentArityError(c, node, signatures, typeArguments, headMessa
1380
1430
  }
1381
1431
  diagnostic =
1382
1432
  belowArgCount !== Number.MIN_SAFE_INTEGER && aboveArgCount !== Number.MAX_SAFE_INTEGER
1383
- ? new Diagnostic(file.diagnosticFile(), pos, end, 875 /* Diagnostics.No_overload_expects_0_type_arguments_but_overloads_do_exist_that_expect_either_1_or_2_type_arguments */, [String(argCount), String(belowArgCount), String(aboveArgCount)])
1384
- : new Diagnostic(file.diagnosticFile(), pos, end, 712 /* Diagnostics.Expected_0_type_arguments_but_got_1 */, [
1433
+ ? new Diagnostic(file.diagnosticFile(), pos, end, 882 /* Diagnostics.No_overload_expects_0_type_arguments_but_overloads_do_exist_that_expect_either_1_or_2_type_arguments */, [String(argCount), String(belowArgCount), String(aboveArgCount)])
1434
+ : new Diagnostic(file.diagnosticFile(), pos, end, 719 /* Diagnostics.Expected_0_type_arguments_but_got_1 */, [
1385
1435
  String(belowArgCount === Number.MIN_SAFE_INTEGER ? aboveArgCount : belowArgCount),
1386
1436
  String(argCount),
1387
1437
  ]);
@@ -1392,9 +1442,9 @@ function getTextOfName(name) {
1392
1442
  return name.kind === 79 /* SyntaxKind.Identifier */ ? getText(name) : '';
1393
1443
  }
1394
1444
  function getErrorNodeForCallNode(node) {
1395
- if (node.kind === 214 /* SyntaxKind.CallExpression */) {
1445
+ if (node.kind === 215 /* SyntaxKind.CallExpression */) {
1396
1446
  const callee = node.expression;
1397
- if (callee.kind === 212 /* SyntaxKind.PropertyAccessExpression */)
1447
+ if (callee.kind === 213 /* SyntaxKind.PropertyAccessExpression */)
1398
1448
  return getName(callee);
1399
1449
  return callee;
1400
1450
  }
@@ -1516,14 +1566,14 @@ export function checkExpressionWithTypeArguments(c, node) {
1516
1566
  for (const a of typeArguments.nodes)
1517
1567
  checkSourceElement(c, a);
1518
1568
  let exprType;
1519
- if (node.kind === 234 /* SyntaxKind.ExpressionWithTypeArguments */) {
1569
+ if (node.kind === 235 /* SyntaxKind.ExpressionWithTypeArguments */) {
1520
1570
  let parent = node.parent;
1521
- while (parent.kind === 218 /* SyntaxKind.ParenthesizedExpression */)
1571
+ while (parent.kind === 219 /* SyntaxKind.ParenthesizedExpression */)
1522
1572
  parent = parent.parent;
1523
- if (parent.kind === 227 /* SyntaxKind.BinaryExpression */ &&
1573
+ if (parent.kind === 228 /* SyntaxKind.BinaryExpression */ &&
1524
1574
  parent.operatorToken.kind === 103 /* SyntaxKind.InstanceOfKeyword */ &&
1525
1575
  isNodeDescendantOf(node, parent.right))
1526
- c.error(node, 968 /* Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_not_be_an_instantiation_expression */);
1576
+ c.error(node, 975 /* Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_not_be_an_instantiation_expression */);
1527
1577
  exprType = checkExpression(c, getExpression(node));
1528
1578
  }
1529
1579
  else
@@ -1545,7 +1595,7 @@ export function getInstantiationExpressionType(c, exprType, node) {
1545
1595
  const errorType = instantiator.hasSomeApplicableSignature ? instantiator.nonApplicableType : exprType;
1546
1596
  if (errorType !== undefined) {
1547
1597
  const file = getSourceFileOfNode(node);
1548
- c.addDiagnostic(new Diagnostic(file.diagnosticFile(), skipTrivia(file.text, typeArgumentList.pos), typeArgumentList.end, 778 /* Diagnostics.Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable */, [typeToString(c, errorType)]));
1598
+ c.addDiagnostic(new Diagnostic(file.diagnosticFile(), skipTrivia(file.text, typeArgumentList.pos), typeArgumentList.end, 785 /* Diagnostics.Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable */, [typeToString(c, errorType)]));
1549
1599
  }
1550
1600
  return result;
1551
1601
  }
@@ -1588,7 +1638,11 @@ class InstantiationExpressionInstantiator {
1588
1638
  if (callSignatures.length !== 0 || constructSignatures.length !== 0)
1589
1639
  this.hasApplicableSignature = true;
1590
1640
  if (callSignatures !== resolved.callSignatures || constructSignatures !== resolved.constructSignatures) {
1591
- const result = newObjectType(c, 16 /* ObjectFlags.Anonymous */ | 16777216 /* ObjectFlags.InstantiationExpressionType */, c.newSymbol(0 /* SymbolFlags.None */, "\uFFFEinstantiationExpression" /* InternalSymbolName.InstantiationExpression */));
1641
+ // A symbol of its own, with the declarations of the instantiated type's symbol.
1642
+ const symbol = c.newSymbol(0 /* SymbolFlags.None */, "\uFFFEinstantiationExpression" /* InternalSymbolName.InstantiationExpression */);
1643
+ if (t.symbol !== undefined)
1644
+ copyDeclarations(symbol, t.symbol);
1645
+ const result = newObjectType(c, 16 /* ObjectFlags.Anonymous */ | 16777216 /* ObjectFlags.InstantiationExpressionType */, symbol);
1592
1646
  setStructuredTypeMembers(c, result, resolved.members, callSignatures, constructSignatures, resolved.indexInfos);
1593
1647
  result.node = this.node;
1594
1648
  return result;