tsc-ts 0.0.10 → 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 (367) 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 +20 -15
  6. package/dist/api/compiler/ast.js +1023 -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 +173 -123
  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 +469 -438
  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 -113
  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 +210 -74
  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 +137 -34
  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 +93 -31
  73. package/dist/api/compiler/checker.js +143 -35
  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 +19 -4
  77. package/dist/api/compiler/compile-program.js +45 -26
  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.js +7 -7
  81. package/dist/api/compiler/emitter.d.ts +7 -1
  82. package/dist/api/compiler/emitter.js +53 -11
  83. package/dist/api/compiler/file-include.d.ts +2 -1
  84. package/dist/api/compiler/file-include.js +11 -7
  85. package/dist/api/compiler/file-loader.d.ts +10 -0
  86. package/dist/api/compiler/file-loader.js +138 -41
  87. package/dist/api/compiler/instantiation.d.ts +7 -0
  88. package/dist/api/compiler/instantiation.js +101 -49
  89. package/dist/api/compiler/jsdoc.js +23 -23
  90. package/dist/api/compiler/link-tables.d.ts +48 -18
  91. package/dist/api/compiler/link-tables.js +80 -37
  92. package/dist/api/compiler/locales/cs-CZ.d.ts +1 -1
  93. package/dist/api/compiler/locales/cs-CZ.js +1 -1
  94. package/dist/api/compiler/locales/de-DE.d.ts +1 -1
  95. package/dist/api/compiler/locales/de-DE.js +1 -1
  96. package/dist/api/compiler/locales/es-ES.d.ts +1 -1
  97. package/dist/api/compiler/locales/es-ES.js +1 -1
  98. package/dist/api/compiler/locales/fr-FR.d.ts +1 -1
  99. package/dist/api/compiler/locales/fr-FR.js +1 -1
  100. package/dist/api/compiler/locales/it-IT.d.ts +1 -1
  101. package/dist/api/compiler/locales/it-IT.js +1 -1
  102. package/dist/api/compiler/locales/ja-JP.d.ts +1 -1
  103. package/dist/api/compiler/locales/ja-JP.js +1 -1
  104. package/dist/api/compiler/locales/ko-KR.d.ts +1 -1
  105. package/dist/api/compiler/locales/ko-KR.js +1 -1
  106. package/dist/api/compiler/locales/pl-PL.d.ts +1 -1
  107. package/dist/api/compiler/locales/pl-PL.js +1 -1
  108. package/dist/api/compiler/locales/pt-BR.d.ts +1 -1
  109. package/dist/api/compiler/locales/pt-BR.js +1 -1
  110. package/dist/api/compiler/locales/ru-RU.d.ts +1 -1
  111. package/dist/api/compiler/locales/ru-RU.js +1 -1
  112. package/dist/api/compiler/locales/tr-TR.d.ts +1 -1
  113. package/dist/api/compiler/locales/tr-TR.js +1 -1
  114. package/dist/api/compiler/locales/zh-CN.d.ts +1 -1
  115. package/dist/api/compiler/locales/zh-CN.js +1 -1
  116. package/dist/api/compiler/locales/zh-TW.d.ts +1 -1
  117. package/dist/api/compiler/locales/zh-TW.js +1 -1
  118. package/dist/api/compiler/module-resolution-types.js +6 -6
  119. package/dist/api/compiler/module-resolution.d.ts +10 -1
  120. package/dist/api/compiler/module-resolution.js +115 -84
  121. package/dist/api/compiler/module-specifiers.d.ts +15 -0
  122. package/dist/api/compiler/module-specifiers.js +24 -18
  123. package/dist/api/compiler/name-resolver.js +74 -65
  124. package/dist/api/compiler/node-builder-names.d.ts +11 -3
  125. package/dist/api/compiler/node-builder-names.js +210 -90
  126. package/dist/api/compiler/node-builder-pseudo.js +29 -31
  127. package/dist/api/compiler/node-builder-reuse.js +23 -22
  128. package/dist/api/compiler/node-builder.d.ts +18 -1
  129. package/dist/api/compiler/node-builder.js +191 -102
  130. package/dist/api/compiler/option-declarations.d.ts +2 -6
  131. package/dist/api/compiler/option-declarations.js +315 -375
  132. package/dist/api/compiler/options.d.ts +15 -33
  133. package/dist/api/compiler/options.js +21 -54
  134. package/dist/api/compiler/output-paths.d.ts +4 -1
  135. package/dist/api/compiler/output-paths.js +6 -11
  136. package/dist/api/compiler/package-json.d.ts +3 -3
  137. package/dist/api/compiler/package-json.js +11 -10
  138. package/dist/api/compiler/parser.d.ts +40 -19
  139. package/dist/api/compiler/parser.js +308 -216
  140. package/dist/api/compiler/path.d.ts +9 -0
  141. package/dist/api/compiler/path.js +20 -3
  142. package/dist/api/compiler/printer/emit-context.d.ts +3 -1
  143. package/dist/api/compiler/printer/emit-context.js +16 -1
  144. package/dist/api/compiler/printer/factory-base.d.ts +2 -2
  145. package/dist/api/compiler/printer/factory-base.js +7 -3
  146. package/dist/api/compiler/printer/factory.js +3 -1
  147. package/dist/api/compiler/printer/helpers.js +10 -1
  148. package/dist/api/compiler/printer/name-generator.d.ts +1 -1
  149. package/dist/api/compiler/printer/name-generator.js +35 -16
  150. package/dist/api/compiler/printer/printer.d.ts +1 -0
  151. package/dist/api/compiler/printer/printer.js +303 -281
  152. package/dist/api/compiler/printer/utilities.js +149 -147
  153. package/dist/api/compiler/program-checker.d.ts +8 -2
  154. package/dist/api/compiler/program-checker.js +84 -34
  155. package/dist/api/compiler/program-utilities.d.ts +3 -1
  156. package/dist/api/compiler/program-utilities.js +28 -15
  157. package/dist/api/compiler/program.d.ts +2 -0
  158. package/dist/api/compiler/program.js +69 -57
  159. package/dist/api/compiler/pseudo-bigint.d.ts +2 -0
  160. package/dist/api/compiler/pseudo-bigint.js +18 -0
  161. package/dist/api/compiler/regexp-checker.d.ts +1 -1
  162. package/dist/api/compiler/regexp-checker.js +93 -76
  163. package/dist/api/compiler/relations.d.ts +27 -4
  164. package/dist/api/compiler/relations.js +337 -180
  165. package/dist/api/compiler/reparser.js +60 -56
  166. package/dist/api/compiler/scanner.d.ts +19 -2
  167. package/dist/api/compiler/scanner.js +123 -108
  168. package/dist/api/compiler/shared-results.d.ts +463 -0
  169. package/dist/api/compiler/shared-results.js +2128 -0
  170. package/dist/api/compiler/sourcemap.js +2 -2
  171. package/dist/api/compiler/symbol-accessibility.js +87 -74
  172. package/dist/api/compiler/symbol.d.ts +22 -13
  173. package/dist/api/compiler/symbol.js +15 -1
  174. package/dist/api/compiler/syntax-kind.d.ts +198 -197
  175. package/dist/api/compiler/transformers/alias-references.js +247 -139
  176. package/dist/api/compiler/transformers/async-utilities.js +25 -25
  177. package/dist/api/compiler/transformers/async.d.ts +0 -1
  178. package/dist/api/compiler/transformers/async.js +64 -77
  179. package/dist/api/compiler/transformers/class-fields.d.ts +1 -0
  180. package/dist/api/compiler/transformers/class-fields.js +81 -78
  181. package/dist/api/compiler/transformers/commonjs-module.js +18 -15
  182. package/dist/api/compiler/transformers/const-enum-inliner.js +1 -1
  183. package/dist/api/compiler/transformers/declarations-diagnostics.js +247 -244
  184. package/dist/api/compiler/transformers/declarations-pseudo.js +100 -100
  185. package/dist/api/compiler/transformers/declarations-resolver.d.ts +0 -3
  186. package/dist/api/compiler/transformers/declarations-syntactic.d.ts +1 -2
  187. package/dist/api/compiler/transformers/declarations-syntactic.js +134 -156
  188. package/dist/api/compiler/transformers/declarations-tracker.js +18 -18
  189. package/dist/api/compiler/transformers/declarations.d.ts +4 -1
  190. package/dist/api/compiler/transformers/declarations.js +305 -238
  191. package/dist/api/compiler/transformers/decorator-metadata.d.ts +1 -1
  192. package/dist/api/compiler/transformers/decorator-metadata.js +53 -45
  193. package/dist/api/compiler/transformers/decorator-utilities.js +24 -24
  194. package/dist/api/compiler/transformers/destructuring.js +19 -18
  195. package/dist/api/compiler/transformers/emit-resolver.js +1 -1
  196. package/dist/api/compiler/transformers/es-decorators.js +55 -55
  197. package/dist/api/compiler/transformers/external-module-info.js +3 -3
  198. package/dist/api/compiler/transformers/for-await.js +25 -25
  199. package/dist/api/compiler/transformers/import-elision.js +14 -14
  200. package/dist/api/compiler/transformers/jsx.js +12 -12
  201. package/dist/api/compiler/transformers/legacy-decorators.js +17 -17
  202. package/dist/api/compiler/transformers/module.js +8 -8
  203. package/dist/api/compiler/transformers/named-evaluation.js +4 -4
  204. package/dist/api/compiler/transformers/object-rest-spread.js +20 -20
  205. package/dist/api/compiler/transformers/optional-chain.js +10 -10
  206. package/dist/api/compiler/transformers/reference-resolver.d.ts +12 -1
  207. package/dist/api/compiler/transformers/reference-resolver.js +131 -69
  208. package/dist/api/compiler/transformers/runtime-syntax.js +35 -31
  209. package/dist/api/compiler/transformers/subtree-facts.js +47 -47
  210. package/dist/api/compiler/transformers/syntax-facts.js +56 -58
  211. package/dist/api/compiler/transformers/type-eraser.js +73 -66
  212. package/dist/api/compiler/transformers/type-serialization.js +24 -24
  213. package/dist/api/compiler/transformers/using.js +12 -12
  214. package/dist/api/compiler/transformers/utilities.js +77 -77
  215. package/dist/api/compiler/transformers/visitor-base.js +172 -172
  216. package/dist/api/compiler/transformers/visitor-hooks.js +6 -2
  217. package/dist/api/compiler/tsconfig.d.ts +10 -2
  218. package/dist/api/compiler/tsconfig.js +136 -48
  219. package/dist/api/compiler/type-printer.js +40 -3
  220. package/dist/api/compiler/types.d.ts +2 -1
  221. package/dist/api/library/ast.generated.d.ts +42 -39
  222. package/dist/api/library/ast.generated.js +1 -1
  223. package/dist/api/library/compiler-options.generated.d.ts +111 -100
  224. package/dist/api/library/compiler-options.generated.js +1 -1
  225. package/dist/api/library/disk.js +12 -1
  226. package/dist/api/library/enums.generated.d.ts +206 -206
  227. package/dist/api/library/enums.generated.js +206 -206
  228. package/dist/api/library/nodes.js +26 -26
  229. package/package.json +9 -9
  230. package/src/compiler/ast-utilities.ts +99 -7
  231. package/src/compiler/ast.ts +55 -26
  232. package/src/compiler/binder.ts +39 -4
  233. package/src/compiler/character-codes.ts +2 -2
  234. package/src/compiler/checker-calls.ts +76 -8
  235. package/src/compiler/checker-classes.ts +78 -24
  236. package/src/compiler/checker-contextual.ts +6 -1
  237. package/src/compiler/checker-declarations.ts +31 -4
  238. package/src/compiler/checker-declared-types.ts +8 -5
  239. package/src/compiler/checker-decorators.ts +1 -1
  240. package/src/compiler/checker-deprecation.ts +29 -8
  241. package/src/compiler/checker-destructuring.ts +10 -3
  242. package/src/compiler/checker-emit-helpers.ts +1 -0
  243. package/src/compiler/checker-emit-resolver.ts +16 -6
  244. package/src/compiler/checker-expressions.ts +79 -46
  245. package/src/compiler/checker-functions.ts +21 -6
  246. package/src/compiler/checker-generated-code.ts +2 -22
  247. package/src/compiler/checker-grammar.ts +133 -60
  248. package/src/compiler/checker-heritage.ts +22 -21
  249. package/src/compiler/checker-inference.ts +514 -87
  250. package/src/compiler/checker-iteration.ts +18 -31
  251. package/src/compiler/checker-javascript.ts +1 -1
  252. package/src/compiler/checker-jsdoc.ts +50 -27
  253. package/src/compiler/checker-jsx.ts +26 -4
  254. package/src/compiler/checker-members.ts +197 -55
  255. package/src/compiler/checker-modules.ts +332 -65
  256. package/src/compiler/checker-narrowing.ts +98 -19
  257. package/src/compiler/checker-object-literals.ts +3 -0
  258. package/src/compiler/checker-operators.ts +11 -4
  259. package/src/compiler/checker-property-access.ts +7 -2
  260. package/src/compiler/checker-services.ts +39 -12
  261. package/src/compiler/checker-signatures.ts +15 -1
  262. package/src/compiler/checker-source-file.ts +39 -13
  263. package/src/compiler/checker-statements.ts +3 -2
  264. package/src/compiler/checker-symbol-types.ts +29 -6
  265. package/src/compiler/checker-symbols.ts +158 -15
  266. package/src/compiler/checker-type-factory.ts +120 -21
  267. package/src/compiler/checker-type-nodes.ts +46 -3
  268. package/src/compiler/checker-type-operators.ts +83 -26
  269. package/src/compiler/checker-types.ts +147 -4
  270. package/src/compiler/checker-unused.ts +9 -14
  271. package/src/compiler/checker.ts +168 -41
  272. package/src/compiler/command-line.ts +28 -28
  273. package/src/compiler/compile-program.ts +51 -25
  274. package/src/compiler/decoder.ts +13 -4
  275. package/src/compiler/diagnostic-messages.ts +1973 -1892
  276. package/src/compiler/emitter.ts +57 -8
  277. package/src/compiler/encoder.ts +23 -8
  278. package/src/compiler/file-include.ts +9 -3
  279. package/src/compiler/file-loader.ts +139 -32
  280. package/src/compiler/help.ts +10 -14
  281. package/src/compiler/incremental.ts +86 -18
  282. package/src/compiler/init.ts +2 -7
  283. package/src/compiler/instantiation.ts +77 -22
  284. package/src/compiler/jsdoc.ts +3 -1
  285. package/src/compiler/link-tables.ts +82 -37
  286. package/src/compiler/locales/cs-CZ.ts +1 -1
  287. package/src/compiler/locales/de-DE.ts +1 -1
  288. package/src/compiler/locales/es-ES.ts +1 -1
  289. package/src/compiler/locales/fr-FR.ts +1 -1
  290. package/src/compiler/locales/it-IT.ts +1 -1
  291. package/src/compiler/locales/ja-JP.ts +1 -1
  292. package/src/compiler/locales/ko-KR.ts +1 -1
  293. package/src/compiler/locales/pl-PL.ts +1 -1
  294. package/src/compiler/locales/pt-BR.ts +1 -1
  295. package/src/compiler/locales/ru-RU.ts +1 -1
  296. package/src/compiler/locales/tr-TR.ts +1 -1
  297. package/src/compiler/locales/zh-CN.ts +1 -1
  298. package/src/compiler/locales/zh-TW.ts +1 -1
  299. package/src/compiler/module-resolution.ts +44 -8
  300. package/src/compiler/module-specifiers.ts +62 -20
  301. package/src/compiler/name-resolver.ts +9 -1
  302. package/src/compiler/node-builder-names.ts +236 -54
  303. package/src/compiler/node-builder-pseudo.ts +4 -7
  304. package/src/compiler/node-builder-reuse.ts +5 -4
  305. package/src/compiler/node-builder.ts +130 -31
  306. package/src/compiler/option-declarations.ts +33 -103
  307. package/src/compiler/options.ts +23 -62
  308. package/src/compiler/output-paths.ts +5 -18
  309. package/src/compiler/package-entrypoints.ts +345 -0
  310. package/src/compiler/package-json.ts +4 -4
  311. package/src/compiler/parallel-check.ts +197 -8
  312. package/src/compiler/parallel-emit.ts +1 -1
  313. package/src/compiler/parser.ts +156 -39
  314. package/src/compiler/path.ts +22 -2
  315. package/src/compiler/printer/emit-context.ts +16 -0
  316. package/src/compiler/printer/factory-base.ts +10 -3
  317. package/src/compiler/printer/factory.ts +4 -1
  318. package/src/compiler/printer/helpers.ts +10 -1
  319. package/src/compiler/printer/name-generator.ts +24 -2
  320. package/src/compiler/printer/printer.ts +35 -14
  321. package/src/compiler/printer/utilities.ts +8 -2
  322. package/src/compiler/program-checker.ts +53 -5
  323. package/src/compiler/program-utilities.ts +23 -10
  324. package/src/compiler/program.ts +13 -1
  325. package/src/compiler/pseudo-bigint.ts +17 -0
  326. package/src/compiler/regexp-checker.ts +63 -30
  327. package/src/compiler/relations.ts +233 -77
  328. package/src/compiler/reparser.ts +7 -2
  329. package/src/compiler/scanner.ts +109 -79
  330. package/src/compiler/shared-results.ts +2414 -0
  331. package/src/compiler/show-config.ts +18 -1
  332. package/src/compiler/sourcemap.ts +2 -2
  333. package/src/compiler/symbol-accessibility.ts +26 -3
  334. package/src/compiler/symbol.ts +31 -14
  335. package/src/compiler/syntax-kind.ts +188 -187
  336. package/src/compiler/thread-entry.ts +19 -2
  337. package/src/compiler/transformers/alias-references.ts +123 -4
  338. package/src/compiler/transformers/async.ts +2 -17
  339. package/src/compiler/transformers/class-fields.ts +13 -12
  340. package/src/compiler/transformers/commonjs-module.ts +11 -7
  341. package/src/compiler/transformers/declarations-diagnostics.ts +5 -3
  342. package/src/compiler/transformers/declarations-pseudo.ts +2 -4
  343. package/src/compiler/transformers/declarations-resolver.ts +0 -3
  344. package/src/compiler/transformers/declarations-syntactic.ts +1 -21
  345. package/src/compiler/transformers/declarations.ts +134 -48
  346. package/src/compiler/transformers/decorator-metadata.ts +9 -1
  347. package/src/compiler/transformers/destructuring.ts +4 -3
  348. package/src/compiler/transformers/external-module-info.ts +1 -1
  349. package/src/compiler/transformers/jsx.ts +2 -1
  350. package/src/compiler/transformers/reference-resolver.ts +83 -19
  351. package/src/compiler/transformers/runtime-syntax.ts +6 -1
  352. package/src/compiler/transformers/syntax-facts.ts +2 -7
  353. package/src/compiler/transformers/type-eraser.ts +10 -1
  354. package/src/compiler/transformers/type-serialization.ts +3 -2
  355. package/src/compiler/transformers/visitor-base.ts +2 -1
  356. package/src/compiler/transformers/visitor-hooks.ts +9 -4
  357. package/src/compiler/tsc-build.ts +3 -0
  358. package/src/compiler/tsc-cli.ts +2 -0
  359. package/src/compiler/tsc-compile.ts +7 -2
  360. package/src/compiler/tsc-watch.ts +74 -45
  361. package/src/compiler/tsconfig.ts +176 -19
  362. package/src/compiler/type-printer.ts +36 -2
  363. package/src/compiler/types.ts +2 -1
  364. package/src/library/ast.generated.ts +57 -41
  365. package/src/library/compiler-options.generated.ts +117 -103
  366. package/src/library/disk.ts +10 -1
  367. package/src/library/enums.generated.ts +196 -196
@@ -43,6 +43,7 @@ import {
43
43
  isOptionalChain,
44
44
  isOutermostOptionalChain,
45
45
  isDottedName,
46
+ isFunctionExpressionOrArrowFunction,
46
47
  } from './binder-utilities.js';
47
48
  import { Diagnostic, type DiagnosticMessage, Diagnostics, chainDiagnostic } from './diagnostics.js';
48
49
  import { resolveInstanceofExpression } from './checker-operators.js';
@@ -147,6 +148,7 @@ import {
147
148
  checkNonNullType,
148
149
  checkNonNullTypeEx,
149
150
  checkTypeQueryExpression,
151
+ getResolvedSymbol,
150
152
  } from './checker-expressions.js';
151
153
  import { IterationUse, checkIteratedTypeOrElementType } from './checker-iteration.js';
152
154
  import { isContextSensitive } from './checker-functions.js';
@@ -182,6 +184,7 @@ import {
182
184
  everyInferenceHasCandidates,
183
185
  someInferenceHasCandidates,
184
186
  inferTypes,
187
+ inferTypesFromUnstarted,
185
188
  isConstTypeVariable,
186
189
  isMutableArrayLikeType,
187
190
  } from './checker-inference.js';
@@ -207,7 +210,14 @@ import {
207
210
  resolveJsxOpeningLikeElement,
208
211
  } from './checker-jsx.js';
209
212
  import { isCommonJSRequire, resolveExternalModuleTypeByLiteral } from './checker-javascript.js';
210
- import { declarationCount, getDeclarations, InternalSymbolName, type Symbol, SymbolFlags } from './symbol.js';
213
+ import {
214
+ copyDeclarations,
215
+ declarationCount,
216
+ getDeclarations,
217
+ InternalSymbolName,
218
+ type Symbol,
219
+ SymbolFlags,
220
+ } from './symbol.js';
211
221
 
212
222
  /** The type of an optional chain's expression with the chain's `undefined` removed. */
213
223
  export function getOptionalExpressionType(c: Checker, exprType: Type, expression: Node): Type {
@@ -430,7 +440,7 @@ function resolveNewExpression(c: Checker, node: NewExpression, checkMode: CheckM
430
440
  }
431
441
  const constructSignatures = getSignaturesOfType(c, expressionType, SignatureKind.Construct);
432
442
  if (constructSignatures.length !== 0) {
433
- if (!isConstructorAccessible(c, node, constructSignatures[0]!)) return resolveErrorCall(c, node);
443
+ if (!isConstructorAccessible(c, node, constructSignatures)) return resolveErrorCall(c, node);
434
444
  if (someSignature(constructSignatures, (s) => (s.flags & SignatureFlags.Abstract) !== 0)) {
435
445
  c.error(node, Diagnostics.Cannot_create_an_instance_of_an_abstract_class);
436
446
  return resolveErrorCall(c, node);
@@ -892,6 +902,8 @@ class CallState {
892
902
  candidates: Signature[];
893
903
  argCheckMode: CheckMode = CheckMode.Normal;
894
904
  isSingleNonGenericCandidate = false;
905
+ /** The call is resolved while its own resolution is in progress. */
906
+ recursiveResolution = false;
895
907
  candidatesForArgumentError: Signature[] = [];
896
908
  candidateForArgumentArityError: Signature | undefined = undefined;
897
909
  candidateForTypeArgumentError: Signature | undefined = undefined;
@@ -933,8 +945,19 @@ export function resolveCall(
933
945
  s.argCheckMode = CheckMode.SkipContextSensitive;
934
946
  // A subtype pass picks the best overload; assignability decides whether the call is an error.
935
947
  let result: Signature | undefined = undefined;
948
+ const callResolutionDepth = c.callResolutionDepth;
949
+ const callResolutionStack = c.callResolutionStack;
950
+ for (let i = 0; i < callResolutionDepth; i++)
951
+ if (callResolutionStack[i] === node) {
952
+ s.recursiveResolution = true;
953
+ break;
954
+ }
955
+ if (callResolutionDepth < callResolutionStack.length) callResolutionStack[callResolutionDepth] = node;
956
+ else callResolutionStack.push(node);
957
+ c.callResolutionDepth = callResolutionDepth + 1;
936
958
  if (candidates.length > 1) result = chooseOverload(c, s, c.subtypeRelation);
937
959
  if (result === undefined) result = chooseOverload(c, s, c.assignableRelation);
960
+ c.callResolutionDepth = callResolutionDepth;
938
961
  if (result !== undefined) return result;
939
962
  result = getCandidateForOverloadFailure(c, node, s.candidates, s.args, checkMode);
940
963
  // Cache now so that error reporting below handles circularities like getResolvedSignature would.
@@ -1031,7 +1054,11 @@ function chooseOverload(c: Checker, s: CallState, relation: Relation): Signature
1031
1054
  c,
1032
1055
  candidate.typeParameters,
1033
1056
  candidate,
1034
- isInJSFile(s.node) ? InferenceFlags.AnyDefault : InferenceFlags.None,
1057
+ // A recursive resolution of a call with one candidate skips constraint checks during inference, which
1058
+ // would otherwise report circularities.
1059
+ (s.recursiveResolution && s.candidates.length === 1
1060
+ ? InferenceFlags.NoConstraintChecks
1061
+ : InferenceFlags.None) | (isInJSFile(s.node) ? InferenceFlags.AnyDefault : InferenceFlags.None),
1035
1062
  undefined,
1036
1063
  );
1037
1064
  typeArgumentTypes = inferTypeArguments(
@@ -1408,13 +1435,13 @@ function inferTypeArguments(
1408
1435
  )
1409
1436
  : instantiatedType;
1410
1437
  // Return type inferences have the lowest priority.
1411
- inferTypes(
1438
+ inferTypesFromUnstarted(
1412
1439
  c,
1440
+ signature,
1413
1441
  context.inferences,
1414
1442
  inferenceSourceType,
1415
1443
  inferenceTargetType,
1416
1444
  InferencePriority.ReturnType,
1417
- false,
1418
1445
  );
1419
1446
  }
1420
1447
  // A separate pass for the mapper used to instantiate generic contextual types, from the outer
@@ -1422,7 +1449,14 @@ function inferTypeArguments(
1422
1449
  const returnContext = createInferenceContext(c, signature.typeParameters, signature, context.flags, undefined);
1423
1450
  const outerReturnMapper = outerContext !== undefined ? createOuterReturnMapper(c, outerContext) : undefined;
1424
1451
  const returnSourceType = instantiateType(c, contextualType, outerReturnMapper);
1425
- inferTypes(c, returnContext.inferences, returnSourceType, inferenceTargetType, InferencePriority.None, false);
1452
+ inferTypesFromUnstarted(
1453
+ c,
1454
+ signature,
1455
+ returnContext.inferences,
1456
+ returnSourceType,
1457
+ inferenceTargetType,
1458
+ InferencePriority.None,
1459
+ );
1426
1460
  context.returnMapper = someInferenceHasCandidates(returnContext.inferences)
1427
1461
  ? getMapperFromContext(cloneInferredPartOfContext(c, returnContext))
1428
1462
  : undefined;
@@ -1708,6 +1742,26 @@ function withHeadMessage(diagnostic: Diagnostic, headMessage: DiagnosticMessage
1708
1742
  return headMessage !== undefined ? chainDiagnostic(diagnostic, headMessage) : diagnostic;
1709
1743
  }
1710
1744
 
1745
+ /** Whether `node` calls the `resolve` parameter of an executor passed to the global `new Promise`. */
1746
+ function isPromiseResolveArityError(c: Checker, node: Node): boolean {
1747
+ if (node.kind !== SyntaxKind.CallExpression) return false;
1748
+ const callee = getExpression(node)!;
1749
+ if (callee.kind !== SyntaxKind.Identifier) return false;
1750
+ const symbol = resolveName(c, callee, getText(callee), SymbolFlags.Value, undefined, false, false);
1751
+ const declaration = symbol?.valueDeclaration;
1752
+ if (
1753
+ declaration === undefined ||
1754
+ declaration.kind !== SyntaxKind.Parameter ||
1755
+ !isFunctionExpressionOrArrowFunction(declaration.parent!) ||
1756
+ declaration.parent!.parent?.kind !== SyntaxKind.NewExpression
1757
+ )
1758
+ return false;
1759
+ const constructor = getExpression(declaration.parent!.parent!);
1760
+ if (constructor === undefined || constructor.kind !== SyntaxKind.Identifier) return false;
1761
+ const globalPromiseSymbol = getGlobalValueSymbol(c, 'Promise', false);
1762
+ return globalPromiseSymbol !== undefined && getResolvedSymbol(c, constructor) === globalPromiseSymbol;
1763
+ }
1764
+
1711
1765
  function getArgumentArityError(
1712
1766
  c: Checker,
1713
1767
  node: Node,
@@ -1750,7 +1804,16 @@ function getArgumentArityError(
1750
1804
  : minCount < maxCount
1751
1805
  ? minCount + '-' + maxCount
1752
1806
  : String(minCount);
1807
+ // `resolve()` without an argument, where `resolve` is the parameter of a `new Promise` executor.
1808
+ const isVoidPromiseError =
1809
+ !hasRestParameter && parameterRange === '1' && args.length === 0 && isPromiseResolveArityError(c, node);
1753
1810
  const errorNode = getErrorNodeForCallNode(node);
1811
+ if (isVoidPromiseError && isInJSFile(node))
1812
+ return createDiagnosticForNode(
1813
+ errorNode,
1814
+ Diagnostics.Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_without_arguments,
1815
+ [],
1816
+ );
1754
1817
  const message =
1755
1818
  node.kind === SyntaxKind.Decorator
1756
1819
  ? hasRestParameter
@@ -1758,7 +1821,9 @@ function getArgumentArityError(
1758
1821
  : Diagnostics.The_runtime_will_invoke_the_decorator_with_1_arguments_but_the_decorator_expects_0
1759
1822
  : hasRestParameter
1760
1823
  ? Diagnostics.Expected_at_least_0_arguments_but_got_1
1761
- : Diagnostics.Expected_0_arguments_but_got_1;
1824
+ : isVoidPromiseError
1825
+ ? Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise
1826
+ : Diagnostics.Expected_0_arguments_but_got_1;
1762
1827
  if (minCount < args.length && args.length < maxCount)
1763
1828
  // Between min and max, but no overload matches.
1764
1829
  return withHeadMessage(
@@ -2106,10 +2171,13 @@ class InstantiationExpressionInstantiator {
2106
2171
  if (resolved.callSignatures.length !== 0 || resolved.constructSignatures.length !== 0) this.hasSignatures = true;
2107
2172
  if (callSignatures.length !== 0 || constructSignatures.length !== 0) this.hasApplicableSignature = true;
2108
2173
  if (callSignatures !== resolved.callSignatures || constructSignatures !== resolved.constructSignatures) {
2174
+ // A symbol of its own, with the declarations of the instantiated type's symbol.
2175
+ const symbol = c.newSymbol(SymbolFlags.None, InternalSymbolName.InstantiationExpression);
2176
+ if (t.symbol !== undefined) copyDeclarations(symbol, t.symbol);
2109
2177
  const result = newObjectType(
2110
2178
  c,
2111
2179
  ObjectFlags.Anonymous | ObjectFlags.InstantiationExpressionType,
2112
- c.newSymbol(SymbolFlags.None, InternalSymbolName.InstantiationExpression),
2180
+ symbol,
2113
2181
  ) as InstantiationExpressionType;
2114
2182
  setStructuredTypeMembers(c, result, resolved.members, callSignatures, constructSignatures, resolved.indexInfos);
2115
2183
  result.node = this.node;
@@ -46,7 +46,7 @@ import {
46
46
  isPrivateIdentifierClassElementDeclaration,
47
47
  isStatic,
48
48
  } from './binder-utilities.js';
49
- import { isFunctionLike, nodeIsMissing, nodeIsPresent } from './ast-utilities.js';
49
+ import { isFunctionLike, isInJSFile, nodeIsMissing, nodeIsPresent } from './ast-utilities.js';
50
50
  import { ScriptTarget, getEmitScriptTarget, getUseDefineForClassFields } from './options.js';
51
51
  import { hasDynamicName, hasLateBindableName } from './checker-utilities.js';
52
52
  import { type DiagnosticMessage, Diagnostics } from './diagnostics.js';
@@ -78,7 +78,13 @@ import { getSymbolOfDeclaration } from './checker-symbols.js';
78
78
  import { getOptionalType, getTypeOfSymbol } from './checker-symbol-types.js';
79
79
  import { convertAutoToAny, getFlowTypeOfReference } from './checker-narrowing.js';
80
80
  import { TypeFacts, hasTypeFacts } from './checker-flow.js';
81
- import { getIndexInfosOfType, getSignaturesOfType, getTypeOfPropertyOfType } from './checker-members.js';
81
+ import {
82
+ getIndexInfosOfType,
83
+ getPropertiesOfType,
84
+ getSignaturesOfType,
85
+ getTypeOfPropertyOfType,
86
+ } from './checker-members.js';
87
+ import { isConstructorDeclaredThisProperty } from './checker-javascript.js';
82
88
  import {
83
89
  checkJSDocLinksOfNode,
84
90
  checkNodeDeferred,
@@ -91,7 +97,7 @@ import {
91
97
  checkExportsOnMergedDeclarations,
92
98
  } from './checker-declarations.js';
93
99
  import { checkFunctionLikeBody } from './checker-functions.js';
94
- import { checkJSDocFullSignature } from './checker-jsdoc.js';
100
+ import { checkJSDocFullSignature, checkJSDocFullSignatureType } from './checker-jsdoc.js';
95
101
  import { checkComputedPropertyName } from './checker-expressions.js';
96
102
  import { checkFunctionOrConstructorSymbol, checkFunctionOrMethodSymbols } from './checker-overloads.js';
97
103
  import {
@@ -100,6 +106,7 @@ import {
100
106
  checkInterfaceHeritage,
101
107
  } from './checker-heritage.js';
102
108
  import { checkDecorators, getFirstTransformableStaticClassElement } from './checker-decorators.js';
109
+ import { getTypeOfNode } from './checker-services.js';
103
110
 
104
111
  export function checkClassDeclaration(c: Checker, node: Node): void {
105
112
  checkClassLikeDeclaration(c, node);
@@ -148,6 +155,23 @@ export function checkClassLikeDeferred(c: Checker, node: Node): void {
148
155
 
149
156
  function checkClassMembers(c: Checker, node: Node): void {
150
157
  for (const member of getMembers(node)!.nodes) checkClassMember(c, member);
158
+ checkConstructorDeclaredProperties(c, node);
159
+ }
160
+
161
+ /**
162
+ * Resolves the types of a JavaScript class's properties declared by `this.x` assignments in its
163
+ * constructor, so the diagnostics of their initializers don't depend on which use is checked first.
164
+ */
165
+ function checkConstructorDeclaredProperties(c: Checker, node: Node): void {
166
+ if (!isInJSFile(node)) return;
167
+ const symbol = getSymbolOfDeclaration(c, node);
168
+ if (symbol === undefined) return;
169
+ for (const property of getPropertiesOfType(c, getDeclaredTypeOfSymbol(c, symbol)))
170
+ if (
171
+ isConstructorDeclaredThisProperty(c, property) &&
172
+ c.symbolLinks(property).thisAssignmentLocation!.parent === node
173
+ )
174
+ getTypeOfSymbol(c, property);
151
175
  }
152
176
 
153
177
  function checkClassLikeDeclaration(c: Checker, node: Node): void {
@@ -241,6 +265,7 @@ function checkClassMember(c: Checker, member: Node): void {
241
265
  if (symbol !== undefined && member.kind !== SyntaxKind.Constructor) getTypeOfSymbol(c, symbol);
242
266
  checkFunctionLikeBody(c, member);
243
267
  if (member.kind === SyntaxKind.MethodDeclaration) {
268
+ checkJSDocFullSignatureType(c, member);
244
269
  checkJSDocFullSignature(c, member);
245
270
  checkFunctionOrMethodSymbols(c, member);
246
271
  if (hasSyntacticModifier(member, ModifierFlags.Abstract) && getBody(member) !== undefined)
@@ -612,35 +637,64 @@ function containsUndefinedType(t: Type): boolean {
612
637
  return (first.flags & TypeFlags.Undefined) !== 0;
613
638
  }
614
639
 
615
- /** Whether `new` at `node` may call a constructor, reporting private and protected ones out of reach. */
616
- export function isConstructorAccessible(c: Checker, node: Node, signature: Signature | undefined): boolean {
617
- if (signature === undefined || signature.declaration === undefined) return true;
618
- const declaration = signature.declaration;
619
- const modifiers = getModifierFlags(declaration) & ModifierFlags.NonPublicAccessibilityModifier;
620
- // Public constructors and constructor functions are always accessible.
621
- if (modifiers === 0 || declaration.kind !== SyntaxKind.Constructor) return true;
622
- const classSymbol = getSymbol(declaration.parent!)!;
623
- const declaringClassDeclaration = getClassLikeDeclarationOfSymbol(classSymbol);
624
- const declaringClass = getDeclaredTypeOfSymbol(c, classSymbol);
625
- // Private and protected constructors are only callable within their class, or subclasses if protected.
626
- for (let container = getContainingClass(node); container !== undefined; container = getContainingClass(container))
627
- if (container === declaringClassDeclaration) return true;
628
- const containingClass = getContainingClass(node);
629
- if (containingClass !== undefined && (modifiers & ModifierFlags.Protected) !== 0) {
630
- const containingType = getDeclaredTypeOfSymbol(c, getSymbol(containingClass)!);
631
- if (typeHasProtectedAccessibleBase(c, classSymbol, containingType)) return true;
640
+ /** A constructor that `node` may not call: the modifiers that forbid it, and the class that declares it. */
641
+ export class ConstructorAccessibilityError {
642
+ constructor(
643
+ readonly kind: ModifierFlags,
644
+ readonly declaringClass: Type,
645
+ ) {}
646
+ }
647
+
648
+ /**
649
+ * The first of `signatures` whose constructor `node` may not call because of the modifiers in `modifiersMask`:
650
+ * private and protected constructors are only callable within their class, or subclasses if protected.
651
+ */
652
+ export function getConstructorAccessibilityError(
653
+ c: Checker,
654
+ node: Node,
655
+ signatures: readonly Signature[],
656
+ modifiersMask: ModifierFlags,
657
+ ): ConstructorAccessibilityError | undefined {
658
+ for (const signature of signatures) {
659
+ const declaration = signature.declaration;
660
+ if (declaration === undefined) continue;
661
+ const modifiers = getModifierFlags(declaration) & modifiersMask;
662
+ // Public constructors and constructor functions are always accessible.
663
+ if (modifiers === 0 || declaration.kind !== SyntaxKind.Constructor) continue;
664
+ const classSymbol = getSymbol(declaration.parent!)!;
665
+ const declaringClassDeclaration = getClassLikeDeclarationOfSymbol(classSymbol);
666
+ let withinClass = false;
667
+ for (let container = getContainingClass(node); container !== undefined; container = getContainingClass(container))
668
+ if (container === declaringClassDeclaration) {
669
+ withinClass = true;
670
+ break;
671
+ }
672
+ if (withinClass) continue;
673
+ const containingClass = getContainingClass(node);
674
+ if (containingClass !== undefined && (modifiers & ModifierFlags.Protected) !== 0) {
675
+ const containingType = getTypeOfNode(c, containingClass);
676
+ if (typeHasProtectedAccessibleBase(c, classSymbol, containingType)) continue;
677
+ }
678
+ return new ConstructorAccessibilityError(modifiers, getDeclaredTypeOfSymbol(c, classSymbol));
632
679
  }
633
- if ((modifiers & ModifierFlags.Private) !== 0)
680
+ return undefined;
681
+ }
682
+
683
+ /** Whether `new` at `node` may call the constructors of `signatures`, reporting private and protected ones out of reach. */
684
+ export function isConstructorAccessible(c: Checker, node: Node, signatures: readonly Signature[]): boolean {
685
+ const error = getConstructorAccessibilityError(c, node, signatures, ModifierFlags.NonPublicAccessibilityModifier);
686
+ if (error === undefined) return true;
687
+ if ((error.kind & ModifierFlags.Private) !== 0)
634
688
  c.error(
635
689
  node,
636
690
  Diagnostics.Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration,
637
- typeToString(c, declaringClass),
691
+ typeToString(c, error.declaringClass),
638
692
  );
639
- if ((modifiers & ModifierFlags.Protected) !== 0)
693
+ if ((error.kind & ModifierFlags.Protected) !== 0)
640
694
  c.error(
641
695
  node,
642
696
  Diagnostics.Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration,
643
- typeToString(c, declaringClass),
697
+ typeToString(c, error.declaringClass),
644
698
  );
645
699
  return false;
646
700
  }
@@ -470,7 +470,12 @@ function getContextualTypeForInitializer(c: Checker, declaration: Node, contextF
470
470
  ) {
471
471
  const parentType = getContextualTypeEx(c, declaration.parent!, contextFlags);
472
472
  const symbol = getSymbolOfDeclaration(c, declaration);
473
- if (parentType !== undefined && symbol !== undefined)
473
+ // The class's own type might still be in progress, so contextually typing by it would report a spurious circularity.
474
+ if (
475
+ parentType !== undefined &&
476
+ symbol !== undefined &&
477
+ parentType.symbol !== getSymbolOfDeclaration(c, declaration.parent!)
478
+ )
474
479
  return getTypeOfPropertyOfContextualType(c, parentType, symbol.name);
475
480
  }
476
481
  return undefined;
@@ -2,6 +2,7 @@
2
2
  import { checkCollisionsForDeclarationName } from './checker-generated-code.js';
3
3
  import { ExternalEmitHelpers, checkExternalEmitHelpers } from './checker-emit-helpers.js';
4
4
  import { convertAutoToAny } from './checker-narrowing.js';
5
+ import { grammarErrorOnNode } from './checker-operators.js';
5
6
  import { markPropertyAsReferenced } from './checker-unused.js';
6
7
  import {
7
8
  type BindingElement,
@@ -13,6 +14,7 @@ import {
13
14
  type NodeList,
14
15
  NodeVisitor,
15
16
  type TypeAliasDeclaration,
17
+ type TypeLiteralNode,
16
18
  type TypeParameterDeclaration,
17
19
  type VariableDeclarationList,
18
20
  type VariableStatement,
@@ -138,7 +140,7 @@ import {
138
140
  } from './ast-utilities.js';
139
141
  import { getTypeForBindingElementParent } from './checker-destructuring.js';
140
142
  import { checkFunctionOrMethodSymbols } from './checker-overloads.js';
141
- import { checkJSDocFullSignature } from './checker-jsdoc.js';
143
+ import { checkJSDocFullSignature, checkJSDocFullSignatureType } from './checker-jsdoc.js';
142
144
  import { checkAliasSymbol } from './checker-modules.js';
143
145
  import { checkDecorators } from './checker-decorators.js';
144
146
  import {
@@ -400,7 +402,7 @@ function checkParameter(c: Checker, node: Node): void {
400
402
  }
401
403
  }
402
404
 
403
- function isVariableLike(node: Node): boolean {
405
+ export function isVariableLike(node: Node): boolean {
404
406
  switch (node.kind) {
405
407
  case SyntaxKind.BindingElement:
406
408
  case SyntaxKind.EnumMember:
@@ -444,6 +446,12 @@ function reportNonIdenticalModifiers(c: Checker, name: Node): void {
444
446
  function checkBindingElement(c: Checker, element: BindingElement): void {
445
447
  // Missing array binding elements have no name.
446
448
  if (element.name === undefined) return;
449
+ if (element.propertyName !== undefined && element.propertyName.kind === SyntaxKind.PrivateIdentifier)
450
+ grammarErrorOnNode(
451
+ c,
452
+ element.propertyName,
453
+ Diagnostics.Private_identifiers_cannot_be_used_in_destructuring_patterns,
454
+ );
447
455
  if (
448
456
  element.propertyName !== undefined &&
449
457
  element.name.kind === SyntaxKind.Identifier &&
@@ -598,6 +606,7 @@ export function checkFunctionDeclaration(c: Checker, node: Node): void {
598
606
  const symbol = getSymbolOfDeclaration(c, node);
599
607
  if (symbol !== undefined) getTypeOfSymbol(c, symbol);
600
608
  checkFunctionLikeBody(c, node);
609
+ checkJSDocFullSignatureType(c, node);
601
610
  checkJSDocFullSignature(c, node);
602
611
  checkFunctionOrMethodSymbols(c, node);
603
612
  checkCollisionsForDeclarationName(c, node, getName(node));
@@ -775,6 +784,8 @@ export function checkEnumMember(c: Checker, node: Node): void {
775
784
  const name = getName(node);
776
785
  if (name !== undefined && name.kind === SyntaxKind.PrivateIdentifier)
777
786
  c.error(node, Diagnostics.An_enum_member_cannot_be_named_with_a_private_identifier);
787
+ // A computed name is a grammar error, but its expression is checked.
788
+ if (name !== undefined && name.kind === SyntaxKind.ComputedPropertyName) checkExpression(c, getExpression(name)!);
778
789
  const initializer = getInitializer(node);
779
790
  if (initializer !== undefined) checkExpression(c, initializer);
780
791
  }
@@ -794,7 +805,8 @@ export function checkEnumDeclaration(c: Checker, node: Node): void {
794
805
  if (links.enumChecked) return;
795
806
  links.enumChecked = true;
796
807
  if (declarationCount(symbol) > 1) {
797
- const enumIsConst = isEnumConst(node);
808
+ // Reported against the first enum declaration, whichever declaration is checked first.
809
+ const enumIsConst = isEnumConst(getDeclarationOfKind(symbol, SyntaxKind.EnumDeclaration)!);
798
810
  for (const d of getDeclarations(symbol))
799
811
  if (d.kind === SyntaxKind.EnumDeclaration && isEnumConst(d) !== enumIsConst)
800
812
  c.error(getNameOfDeclaration(d), Diagnostics.Enum_declarations_must_all_be_const_or_non_const);
@@ -814,6 +826,14 @@ export function checkEnumDeclaration(c: Checker, node: Node): void {
814
826
  }
815
827
  }
816
828
 
829
+ /** An ambient module's import attributes type must be assignable to the global `ImportAttributes`. */
830
+ function checkImportAttributesType(c: Checker, attributes: TypeLiteralNode): void {
831
+ checkSourceElement(c, attributes);
832
+ const importAttributesType = getCachedGlobalType(c, 'ImportAttributes', 0, true);
833
+ if (importAttributesType !== c.emptyObjectType)
834
+ checkTypeAssignableTo(c, getTypeFromTypeNode(c, attributes), importAttributesType, attributes, undefined);
835
+ }
836
+
817
837
  /** Whether erasableSyntaxOnly applies at `node`: it is set, and `node` is in a TypeScript file. */
818
838
  export function shouldCheckErasableSyntax(c: Checker, node: Node): boolean {
819
839
  return c.compilerOptions.erasableSyntaxOnly === true && !isInJSFile(node);
@@ -830,6 +850,8 @@ export function checkModuleDeclaration(c: Checker, node: Node): void {
830
850
  module.name,
831
851
  Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context,
832
852
  );
853
+ const attributes = module.attributes;
854
+ if (attributes !== undefined) checkImportAttributesType(c, attributes);
833
855
  const contextMessage = isAmbientModule(node)
834
856
  ? Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file
835
857
  : Diagnostics.A_namespace_declaration_is_only_allowed_at_the_top_level_of_a_namespace_or_module;
@@ -888,6 +910,8 @@ export function checkModuleDeclaration(c: Checker, node: Node): void {
888
910
  }
889
911
  if (!isAmbientModule(node)) return;
890
912
  if (isModuleAugmentationExternal(node)) {
913
+ if (attributes !== undefined)
914
+ c.error(attributes, Diagnostics.Import_attributes_are_not_allowed_on_a_module_augmentation);
891
915
  // Check an augmentation's body only when it merged with its target.
892
916
  const checkBody = isGlobalAugmentation || (symbol !== undefined && (symbol.flags & SymbolFlags.Transient) !== 0);
893
917
  if (checkBody && body !== undefined && body.kind === SyntaxKind.ModuleBlock)
@@ -1066,7 +1090,10 @@ export function checkExportsOnMergedDeclarations(c: Checker, node: Node): void {
1066
1090
  symbol = getSymbolOfDeclaration(c, node);
1067
1091
  if (symbol === undefined || symbol.exportSymbol === undefined) return;
1068
1092
  }
1069
- if (getDeclarationOfKind(symbol, node.kind) !== node) return;
1093
+ if (declarationCount(symbol) < 2) return;
1094
+ const links = c.symbolLinks(symbol);
1095
+ if (links.mergedExportsChecked) return;
1096
+ links.mergedExportsChecked = true;
1070
1097
  let exported = DeclarationSpaces.None;
1071
1098
  let nonExported = DeclarationSpaces.None;
1072
1099
  let defaultExported = DeclarationSpaces.None;
@@ -19,7 +19,8 @@ import {
19
19
  MappedTypeNode,
20
20
  getHeritageClauses,
21
21
  } from './ast.js';
22
- import { getSourceFileOfNode, isEnumConst, isObjectLiteralMethod } from './binder-utilities.js';
22
+ import { getSourceFileOfNode, hasDynamicName, isEnumConst, isObjectLiteralMethod } from './binder-utilities.js';
23
+ import { getHeritageClauseElementName } from './ast-utilities.js';
23
24
  import { Diagnostics } from './diagnostics.js';
24
25
  import { SyntaxKind } from './syntax-kind.js';
25
26
  import { type Checker, createDiagnosticForNode } from './checker.js';
@@ -56,6 +57,7 @@ import {
56
57
  typeListKey,
57
58
  typesOf,
58
59
  typeListHash,
60
+ compareTypes,
59
61
  } from './checker-type-factory.js';
60
62
  import {
61
63
  TypeSystemPropertyName,
@@ -157,9 +159,9 @@ function isThislessInterface(c: Checker, symbol: Symbol): boolean {
157
159
  if (declaration.kind !== SyntaxKind.InterfaceDeclaration) continue;
158
160
  if ((declaration.flags & NodeFlags.ContainsThis) !== 0) return false;
159
161
  for (const node of getExtendsHeritageClauseElements(declaration)) {
160
- const expression = getExpression(node)!;
161
- if (isEntityNameExpression(expression)) {
162
- const baseSymbol = resolveEntityName(c, expression, SymbolFlags.Type, true, false, undefined);
162
+ const name = getHeritageClauseElementName(node);
163
+ if (name.kind === SyntaxKind.QualifiedName || isEntityNameExpression(name)) {
164
+ const baseSymbol = resolveEntityName(c, name, SymbolFlags.Type, true, false, undefined);
163
165
  if (
164
166
  baseSymbol === undefined ||
165
167
  (baseSymbol.flags & SymbolFlags.Interface) === 0 ||
@@ -302,6 +304,7 @@ export function getInferTypeParameters(c: Checker, node: Node): Type[] {
302
304
  if (locals !== undefined)
303
305
  for (const symbol of locals.values())
304
306
  if ((symbol.flags & SymbolFlags.TypeParameter) !== 0) result.push(getDeclaredTypeOfSymbol(c, symbol));
307
+ result.sort((t1, t2) => compareTypes(c, t1, t2));
305
308
  return result;
306
309
  }
307
310
 
@@ -377,7 +380,7 @@ export function getDeclaredTypeOfEnum(c: Checker, symbol: Symbol): Type {
377
380
  for (const declaration of getDeclarations(symbol)) {
378
381
  if (declaration.kind !== SyntaxKind.EnumDeclaration) continue;
379
382
  for (const member of (declaration as EnumDeclaration).members.nodes) {
380
- if (!hasBindableName(member)) continue;
383
+ if (hasDynamicName(member)) continue;
381
384
  const memberSymbol = getSymbolOfDeclaration(c, member)!;
382
385
  computeEnumMemberValues(c, declaration);
383
386
  const memberLinks = c.nodeLinks(member);
@@ -404,7 +404,7 @@ export function getDecoratorArgumentCount(c: Checker, node: Node, signature: Sig
404
404
  case SyntaxKind.GetAccessor:
405
405
  case SyntaxKind.SetAccessor:
406
406
  // Decorators with only two parameters get only two arguments.
407
- return signature.parameters.length <= 2 ? 2 : 3;
407
+ return getParameterCount(c, signature) <= 2 ? 2 : 3;
408
408
  }
409
409
  return 3;
410
410
  }
@@ -6,15 +6,16 @@ import {
6
6
  type IndexedAccessTypeNode,
7
7
  JSDoc,
8
8
  JSDocDeprecatedTag,
9
- type JsxAttribute,
10
9
  type JsxNamespacedName,
11
10
  type Node,
11
+ type SourceFile,
12
12
  NodeFlags,
13
13
  type QualifiedName,
14
14
  type TaggedTemplateExpression,
15
15
  type TypeReferenceNode,
16
16
  getExpression,
17
17
  getName,
18
+ getProperties,
18
19
  getTagName,
19
20
  getText,
20
21
  } from './ast.js';
@@ -31,6 +32,7 @@ import { hasMatchingArgument } from './checker-narrowing.js';
31
32
  import { entityNameToString } from './checker-expressions.js';
32
33
  import { isErrorType } from './checker-type-factory.js';
33
34
  import { getPropertyOfType } from './checker-members.js';
35
+ import { getApparentTypeOfContextualType } from './checker-contextual.js';
34
36
  import { signatureToString } from './type-printer.js';
35
37
  import { declarationAt, declarationCount, getDeclarations, type Symbol, SymbolFlags } from './symbol.js';
36
38
 
@@ -347,11 +349,30 @@ export function checkDeprecatedImportSpecifier(c: Checker, node: Node, symbol: S
347
349
  addDeprecatedSuggestion(c, node, getDeclarations(targetSymbol), targetSymbol.name);
348
350
  }
349
351
 
350
- /** Reports a JSX attribute setting a deprecated property of the element's contextual props type. */
351
- export function checkDeprecatedJsxAttribute(c: Checker, contextualType: Type, attribute: JsxAttribute): void {
352
- const name = attribute.name;
353
- if (name.kind !== SyntaxKind.Identifier) return;
354
- const prop = getPropertyOfType(c, contextualType, getText(name));
355
- if (prop !== undefined && declarationCount(prop) !== 0 && isDeprecatedSymbol(c, prop))
356
- addDeprecatedSuggestion(c, name, getDeclarations(prop), getText(name));
352
+ /** Reports the deprecated properties the checked object literals of `file` set (`checkContextualDeprecations`). */
353
+ export function checkObjectLiteralDeprecations(c: Checker, file: SourceFile): void {
354
+ const pending = c.objectLiteralsForDeprecations.get(file);
355
+ if (pending === undefined) return;
356
+ c.objectLiteralsForDeprecations.delete(file);
357
+ for (const node of pending) checkContextualDeprecations(c, node);
358
+ }
359
+
360
+ /**
361
+ * Reports the members of an object literal or the attributes of a JSX element that set a deprecated
362
+ * property of its contextual type. Deferred, so the contextual type of the final check is used.
363
+ */
364
+ export function checkContextualDeprecations(c: Checker, node: Node): void {
365
+ const contextualType = getApparentTypeOfContextualType(c, node);
366
+ if (contextualType === undefined) return;
367
+ for (const property of getProperties(node)!.nodes) {
368
+ const name = getName(property);
369
+ if (name === undefined || name.kind === SyntaxKind.ComputedPropertyName) continue;
370
+ const text =
371
+ name.kind === SyntaxKind.JsxNamespacedName
372
+ ? (name as JsxNamespacedName).namespace.text + ':' + (name as JsxNamespacedName).name.text
373
+ : getText(name);
374
+ const prop = getPropertyOfType(c, contextualType, text);
375
+ if (prop !== undefined && declarationCount(prop) !== 0 && isDeprecatedSymbol(c, prop))
376
+ addDeprecatedSuggestion(c, name, getDeclarations(prop), text);
377
+ }
357
378
  }
@@ -110,7 +110,12 @@ import {
110
110
  } from './checker-expressions.js';
111
111
  import { IterationUse, checkIteratedTypeOrElementType, createIterableType } from './checker-iteration.js';
112
112
  import { ScriptTarget } from './options.js';
113
- import { checkBinaryExpression, checkReferenceExpression, removeDefinitelyFalsyTypes } from './checker-operators.js';
113
+ import {
114
+ checkBinaryExpression,
115
+ checkReferenceExpression,
116
+ grammarErrorOnNode,
117
+ removeDefinitelyFalsyTypes,
118
+ } from './checker-operators.js';
114
119
  import { TypeFacts, getNonNullableType, getTypeWithFacts, hasTypeFacts } from './checker-flow.js';
115
120
  import { sliceTupleType } from './checker-signatures.js';
116
121
  import { getPropertyNameFromType, isTypeUsableAsPropertyName, maybeTypeOfKind } from './checker-utilities.js';
@@ -462,7 +467,7 @@ function padObjectLiteralType(c: Checker, t: Type, pattern: Node): Type {
462
467
  const missingElements: BindingElement[] = [];
463
468
  for (const node of getElements(pattern)!.nodes) {
464
469
  const e = node as BindingElement;
465
- if (e.initializer === undefined) continue;
470
+ if (e.dotDotDotToken !== undefined) continue;
466
471
  const name = getPropertyNameFromBindingElement(c, e);
467
472
  if (name !== undefined && getPropertyOfType(c, t, name) === undefined) missingElements.push(e);
468
473
  }
@@ -471,7 +476,7 @@ function padObjectLiteralType(c: Checker, t: Type, pattern: Node): Type {
471
476
  for (const prop of getPropertiesOfObjectType(c, t)) members.set(prop.name, prop);
472
477
  for (const e of missingElements) {
473
478
  const symbol = c.newSymbol(SymbolFlags.Property | SymbolFlags.Optional, getPropertyNameFromBindingElement(c, e)!);
474
- c.symbolTypes.set(getSymbolId(symbol), getTypeFromBindingElement(c, e, false, false));
479
+ c.symbolTypes.set(getSymbolId(symbol), getTypeFromBindingElement(c, e, false, true));
475
480
  members.set(symbol.name, symbol);
476
481
  }
477
482
  const result = createAnonymousType(c, t.symbol, members, [], [], getIndexInfosOfType(c, t));
@@ -588,6 +593,8 @@ function checkObjectLiteralDestructuringPropertyAssignment(
588
593
  const property = properties[propertyIndex]!;
589
594
  if (property.kind === SyntaxKind.PropertyAssignment || property.kind === SyntaxKind.ShorthandPropertyAssignment) {
590
595
  const name = getName(property)!;
596
+ if (name.kind === SyntaxKind.PrivateIdentifier)
597
+ grammarErrorOnNode(c, name, Diagnostics.Private_identifiers_cannot_be_used_in_destructuring_patterns);
591
598
  markDestructuredPropertyAsReferenced(c, objectLiteralType, name, property, rightIsThis);
592
599
  const exprType = getLiteralTypeFromPropertyName(c, name) ?? c.errorType;
593
600
  if (isTypeUsableAsPropertyName(exprType)) {
@@ -174,6 +174,7 @@ function resolveHelpersModule(c: Checker, file: SourceFile, errorNode: Node): Sy
174
174
  Diagnostics.This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found,
175
175
  errorNode,
176
176
  false,
177
+ undefined,
177
178
  ) ?? c.unknownSymbol;
178
179
  return links.helpersModule;
179
180
  }