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
@@ -1,4 +1,4 @@
1
- import { type Node } from './ast.js';
1
+ import { ModifierFlags, type Node } from './ast.js';
2
2
  import { type DiagnosticMessage } from './diagnostics.js';
3
3
  import type { Checker } from './checker.js';
4
4
  import { type Signature, type Type } from './checker-types.js';
@@ -25,6 +25,17 @@ export declare function getFlowTypeOfProperty(c: Checker, reference: Node, prop:
25
25
  export declare function isAutoTypedProperty(c: Checker, symbol: Symbol): boolean;
26
26
  /** The type of the property in the first base class, if it has one. */
27
27
  export declare function getTypeOfPropertyInBaseClass(c: Checker, property: Symbol): Type | undefined;
28
- /** Whether `new` at `node` may call a constructor, reporting private and protected ones out of reach. */
29
- export declare function isConstructorAccessible(c: Checker, node: Node, signature: Signature | undefined): boolean;
28
+ /** A constructor that `node` may not call: the modifiers that forbid it, and the class that declares it. */
29
+ export declare class ConstructorAccessibilityError {
30
+ readonly kind: ModifierFlags;
31
+ readonly declaringClass: Type;
32
+ constructor(kind: ModifierFlags, declaringClass: Type);
33
+ }
34
+ /**
35
+ * The first of `signatures` whose constructor `node` may not call because of the modifiers in `modifiersMask`:
36
+ * private and protected constructors are only callable within their class, or subclasses if protected.
37
+ */
38
+ export declare function getConstructorAccessibilityError(c: Checker, node: Node, signatures: readonly Signature[], modifiersMask: ModifierFlags): ConstructorAccessibilityError | undefined;
39
+ /** Whether `new` at `node` may call the constructors of `signatures`, reporting private and protected ones out of reach. */
40
+ export declare function isConstructorAccessible(c: Checker, node: Node, signatures: readonly Signature[]): boolean;
30
41
  export declare function checkInterfaceDeclaration(c: Checker, node: Node): void;
@@ -6,7 +6,7 @@ import { isOuterExpression } from './transformers/utilities.js';
6
6
  import { checkExternalEmitHelpers } from './checker-emit-helpers.js';
7
7
  import { Identifier, PrivateIdentifier, getType, getSymbol, ElementAccessExpression, KeywordExpression, NodeVisitor, PropertyAccessExpression, getBody, getName, getStatements, getExpression, getTypeArguments, getHeritageClauses, getMembers, getText, getTypeParameters, getInitializer, getParameters, getModifiers, } from './ast.js';
8
8
  import { declarationNameToString, findConstructorDeclaration, getContainingClass, getDeclarationOfKind, getModifierFlags, getSourceFileOfNode, hasSyntacticModifier, isClassLike, isPrivateIdentifierClassElementDeclaration, isStatic, } from './binder-utilities.js';
9
- import { isFunctionLike, nodeIsMissing, nodeIsPresent } from './ast-utilities.js';
9
+ import { isFunctionLike, isInJSFile, nodeIsMissing, nodeIsPresent } from './ast-utilities.js';
10
10
  import { ScriptTarget, getEmitScriptTarget, getUseDefineForClassFields } from './options.js';
11
11
  import { hasDynamicName, hasLateBindableName } from './checker-utilities.js';
12
12
  import { everyType, getTargetType, typesOf } from './checker-type-factory.js';
@@ -17,15 +17,17 @@ import { getSymbolOfDeclaration } from './checker-symbols.js';
17
17
  import { getOptionalType, getTypeOfSymbol } from './checker-symbol-types.js';
18
18
  import { convertAutoToAny, getFlowTypeOfReference } from './checker-narrowing.js';
19
19
  import { hasTypeFacts } from './checker-flow.js';
20
- import { getIndexInfosOfType, getSignaturesOfType, getTypeOfPropertyOfType } from './checker-members.js';
20
+ import { getIndexInfosOfType, getPropertiesOfType, getSignaturesOfType, getTypeOfPropertyOfType, } from './checker-members.js';
21
+ import { isConstructorDeclaredThisProperty } from './checker-javascript.js';
21
22
  import { checkJSDocLinksOfNode, checkNodeDeferred, checkSourceElement, checkTypeNodeIfPresent, } from './checker-source-file.js';
22
23
  import { checkVariableLikeDeclaration, checkTypeParameters, checkExportsOnMergedDeclarations, } from './checker-declarations.js';
23
24
  import { checkFunctionLikeBody } from './checker-functions.js';
24
- import { checkJSDocFullSignature } from './checker-jsdoc.js';
25
+ import { checkJSDocFullSignature, checkJSDocFullSignatureType } from './checker-jsdoc.js';
25
26
  import { checkComputedPropertyName } from './checker-expressions.js';
26
27
  import { checkFunctionOrConstructorSymbol, checkFunctionOrMethodSymbols } from './checker-overloads.js';
27
28
  import { checkClassHeritage, checkClassOrInterfaceForDuplicateIndexSignatures, checkInterfaceHeritage, } from './checker-heritage.js';
28
29
  import { checkDecorators, getFirstTransformableStaticClassElement } from './checker-decorators.js';
30
+ import { getTypeOfNode } from './checker-services.js';
29
31
  export function checkClassDeclaration(c, node) {
30
32
  checkClassLikeDeclaration(c, node);
31
33
  checkClassMembers(c, node);
@@ -52,7 +54,7 @@ function checkClassExpressionExternalHelpers(c, node) {
52
54
  if (willTransformESDecorators && classOrConstructorParameterIsDecorated(false, node)) {
53
55
  location = node;
54
56
  for (const modifier of getModifiers(node)?.nodes ?? [])
55
- if (modifier.kind === 171 /* SyntaxKind.Decorator */) {
57
+ if (modifier.kind === 172 /* SyntaxKind.Decorator */) {
56
58
  location = modifier;
57
59
  break;
58
60
  }
@@ -62,10 +64,10 @@ function checkClassExpressionExternalHelpers(c, node) {
62
64
  if (location === undefined)
63
65
  return;
64
66
  checkExternalEmitHelpers(c, location, 65536 /* ExternalEmitHelpers.SetFunctionName */);
65
- if ((parent.kind === 303 /* SyntaxKind.PropertyAssignment */ ||
66
- parent.kind === 173 /* SyntaxKind.PropertyDeclaration */ ||
67
- parent.kind === 209 /* SyntaxKind.BindingElement */) &&
68
- getName(parent).kind === 168 /* SyntaxKind.ComputedPropertyName */)
67
+ if ((parent.kind === 304 /* SyntaxKind.PropertyAssignment */ ||
68
+ parent.kind === 174 /* SyntaxKind.PropertyDeclaration */ ||
69
+ parent.kind === 210 /* SyntaxKind.BindingElement */) &&
70
+ getName(parent).kind === 169 /* SyntaxKind.ComputedPropertyName */)
69
71
  checkExternalEmitHelpers(c, location, 131072 /* ExternalEmitHelpers.PropKey */);
70
72
  }
71
73
  export function checkClassLikeDeferred(c, node) {
@@ -74,11 +76,27 @@ export function checkClassLikeDeferred(c, node) {
74
76
  function checkClassMembers(c, node) {
75
77
  for (const member of getMembers(node).nodes)
76
78
  checkClassMember(c, member);
79
+ checkConstructorDeclaredProperties(c, node);
80
+ }
81
+ /**
82
+ * Resolves the types of a JavaScript class's properties declared by `this.x` assignments in its
83
+ * constructor, so the diagnostics of their initializers don't depend on which use is checked first.
84
+ */
85
+ function checkConstructorDeclaredProperties(c, node) {
86
+ if (!isInJSFile(node))
87
+ return;
88
+ const symbol = getSymbolOfDeclaration(c, node);
89
+ if (symbol === undefined)
90
+ return;
91
+ for (const property of getPropertiesOfType(c, getDeclaredTypeOfSymbol(c, symbol)))
92
+ if (isConstructorDeclaredThisProperty(c, property) &&
93
+ c.symbolLinks(property).thisAssignmentLocation.parent === node)
94
+ getTypeOfSymbol(c, property);
77
95
  }
78
96
  function checkClassLikeDeclaration(c, node) {
79
97
  checkDecorators(c, node);
80
98
  checkCollisionsForDeclarationName(c, node, getName(node));
81
- if (node.kind === 264 /* SyntaxKind.ClassDeclaration */)
99
+ if (node.kind === 265 /* SyntaxKind.ClassDeclaration */)
82
100
  checkExportsOnMergedDeclarations(c, node);
83
101
  const typeParameters = getTypeParameters(node);
84
102
  checkTypeParameters(c, typeParameters);
@@ -93,7 +111,7 @@ function checkClassLikeDeclaration(c, node) {
93
111
  }
94
112
  const name = getName(node);
95
113
  if (name !== undefined)
96
- checkTypeNameIsReserved(c, name, 585 /* Diagnostics.Class_name_cannot_be_0 */);
114
+ checkTypeNameIsReserved(c, name, 592 /* Diagnostics.Class_name_cannot_be_0 */);
97
115
  const heritageClauses = getHeritageClauses(node);
98
116
  if (heritageClauses !== undefined)
99
117
  checkHeritageClauses(c, heritageClauses.nodes, true);
@@ -144,36 +162,37 @@ function checkHeritageClauses(c, clauses, isClass) {
144
162
  }
145
163
  function checkClassMember(c, member) {
146
164
  checkJSDocLinksOfNode(c, member);
147
- if (member.kind === 173 /* SyntaxKind.PropertyDeclaration */ ||
148
- member.kind === 175 /* SyntaxKind.MethodDeclaration */ ||
149
- member.kind === 178 /* SyntaxKind.GetAccessor */ ||
150
- member.kind === 179 /* SyntaxKind.SetAccessor */)
165
+ if (member.kind === 174 /* SyntaxKind.PropertyDeclaration */ ||
166
+ member.kind === 176 /* SyntaxKind.MethodDeclaration */ ||
167
+ member.kind === 179 /* SyntaxKind.GetAccessor */ ||
168
+ member.kind === 180 /* SyntaxKind.SetAccessor */)
151
169
  markPrivateIdentifierScope(c, member);
152
170
  switch (member.kind) {
153
- case 173 /* SyntaxKind.PropertyDeclaration */:
171
+ case 174 /* SyntaxKind.PropertyDeclaration */:
154
172
  checkVariableLikeDeclaration(c, member);
155
173
  if (hasSyntacticModifier(member, 64 /* ModifierFlags.Abstract */) && getInitializer(member) !== undefined)
156
174
  c.error(member, 216 /* Diagnostics.Property_0_cannot_have_an_initializer_because_it_is_marked_abstract */, declarationNameToString(getSourceFileOfNode(member), getName(member)));
157
175
  return;
158
- case 175 /* SyntaxKind.MethodDeclaration */:
159
- case 177 /* SyntaxKind.Constructor */:
160
- case 178 /* SyntaxKind.GetAccessor */:
161
- case 179 /* SyntaxKind.SetAccessor */: {
176
+ case 176 /* SyntaxKind.MethodDeclaration */:
177
+ case 178 /* SyntaxKind.Constructor */:
178
+ case 179 /* SyntaxKind.GetAccessor */:
179
+ case 180 /* SyntaxKind.SetAccessor */: {
162
180
  checkDecorators(c, member);
163
181
  const name = getName(member);
164
- if (name !== undefined && name.kind === 168 /* SyntaxKind.ComputedPropertyName */)
182
+ if (name !== undefined && name.kind === 169 /* SyntaxKind.ComputedPropertyName */)
165
183
  checkComputedPropertyName(c, name);
166
184
  const symbol = getSymbolOfDeclaration(c, member);
167
- if (symbol !== undefined && member.kind !== 177 /* SyntaxKind.Constructor */)
185
+ if (symbol !== undefined && member.kind !== 178 /* SyntaxKind.Constructor */)
168
186
  getTypeOfSymbol(c, symbol);
169
187
  checkFunctionLikeBody(c, member);
170
- if (member.kind === 175 /* SyntaxKind.MethodDeclaration */) {
188
+ if (member.kind === 176 /* SyntaxKind.MethodDeclaration */) {
189
+ checkJSDocFullSignatureType(c, member);
171
190
  checkJSDocFullSignature(c, member);
172
191
  checkFunctionOrMethodSymbols(c, member);
173
192
  if (hasSyntacticModifier(member, 64 /* ModifierFlags.Abstract */) && getBody(member) !== undefined)
174
193
  c.error(member, 195 /* Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract */, declarationNameToString(getSourceFileOfNode(member), name));
175
194
  }
176
- else if (member.kind === 177 /* SyntaxKind.Constructor */) {
195
+ else if (member.kind === 178 /* SyntaxKind.Constructor */) {
177
196
  if (symbol !== undefined)
178
197
  checkFunctionOrConstructorSymbol(c, symbol);
179
198
  checkConstructorSuperCall(c, member);
@@ -182,10 +201,10 @@ function checkClassMember(c, member) {
182
201
  checkAccessorDeclaration(c, member);
183
202
  return;
184
203
  }
185
- case 182 /* SyntaxKind.IndexSignature */:
204
+ case 183 /* SyntaxKind.IndexSignature */:
186
205
  checkSignatureDeclarationTypes(c, member);
187
206
  return;
188
- case 176 /* SyntaxKind.ClassStaticBlockDeclaration */: {
207
+ case 177 /* SyntaxKind.ClassStaticBlockDeclaration */: {
189
208
  const body = getBody(member);
190
209
  if (body !== undefined)
191
210
  for (const s of getStatements(body).nodes)
@@ -199,20 +218,20 @@ export function checkAccessorDeclaration(c, node) {
199
218
  const name = getName(node);
200
219
  if (name.kind === 79 /* SyntaxKind.Identifier */ && getText(name) === 'constructor' && isClassLike(node.parent))
201
220
  c.error(name, 276 /* Diagnostics.Class_constructor_may_not_be_an_accessor */);
202
- if (node.kind === 178 /* SyntaxKind.GetAccessor */ &&
221
+ if (node.kind === 179 /* SyntaxKind.GetAccessor */ &&
203
222
  (node.flags & 8388608 /* NodeFlags.Ambient */) === 0 &&
204
223
  nodeIsPresent(getBody(node)) &&
205
224
  (node.flags & 256 /* NodeFlags.HasImplicitReturn */) !== 0 &&
206
225
  (node.flags & 512 /* NodeFlags.HasExplicitReturn */) === 0)
207
- c.error(name, 552 /* Diagnostics.A_get_accessor_must_return_a_value */);
226
+ c.error(name, 559 /* Diagnostics.A_get_accessor_must_return_a_value */);
208
227
  if (hasDynamicName(node) && !hasLateBindableName(c, node))
209
228
  return;
210
229
  // Accessors of one member must agree on accessibility and abstractness; checked once, at the getter.
211
230
  const symbol = getSymbolOfDeclaration(c, node);
212
231
  if (symbol === undefined)
213
232
  return;
214
- const getter = getDeclarationOfKind(symbol, 178 /* SyntaxKind.GetAccessor */);
215
- const setter = getDeclarationOfKind(symbol, 179 /* SyntaxKind.SetAccessor */);
233
+ const getter = getDeclarationOfKind(symbol, 179 /* SyntaxKind.GetAccessor */);
234
+ const setter = getDeclarationOfKind(symbol, 180 /* SyntaxKind.SetAccessor */);
216
235
  if (getter === undefined || setter === undefined)
217
236
  return;
218
237
  const links = c.nodeLinks(getter);
@@ -222,14 +241,14 @@ export function checkAccessorDeclaration(c, node) {
222
241
  const getterFlags = getModifierFlags(getter);
223
242
  const setterFlags = getModifierFlags(setter);
224
243
  if ((getterFlags & 64 /* ModifierFlags.Abstract */) !== (setterFlags & 64 /* ModifierFlags.Abstract */)) {
225
- c.error(getName(getter), 810 /* Diagnostics.Accessors_must_both_be_abstract_or_non_abstract */);
226
- c.error(getName(setter), 810 /* Diagnostics.Accessors_must_both_be_abstract_or_non_abstract */);
244
+ c.error(getName(getter), 817 /* Diagnostics.Accessors_must_both_be_abstract_or_non_abstract */);
245
+ c.error(getName(setter), 817 /* Diagnostics.Accessors_must_both_be_abstract_or_non_abstract */);
227
246
  }
228
247
  if (((getterFlags & 4 /* ModifierFlags.Protected */) !== 0 &&
229
248
  (setterFlags & (4 /* ModifierFlags.Protected */ | 2 /* ModifierFlags.Private */)) === 0) ||
230
249
  ((getterFlags & 2 /* ModifierFlags.Private */) !== 0 && (setterFlags & 2 /* ModifierFlags.Private */) === 0)) {
231
- c.error(getName(getter), 939 /* Diagnostics.A_get_accessor_must_be_at_least_as_accessible_as_the_setter */);
232
- c.error(getName(setter), 939 /* Diagnostics.A_get_accessor_must_be_at_least_as_accessible_as_the_setter */);
250
+ c.error(getName(getter), 946 /* Diagnostics.A_get_accessor_must_be_at_least_as_accessible_as_the_setter */);
251
+ c.error(getName(setter), 946 /* Diagnostics.A_get_accessor_must_be_at_least_as_accessible_as_the_setter */);
233
252
  }
234
253
  }
235
254
  /** Derived class constructors must call `super`, at the root when properties are initialized. */
@@ -250,11 +269,11 @@ function checkConstructorSuperCall(c, node) {
250
269
  const superCall = finder.superCall;
251
270
  if (superCall === undefined) {
252
271
  if (!classExtendsNull)
253
- c.error(node, 551 /* Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call */);
272
+ c.error(node, 558 /* Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call */);
254
273
  return;
255
274
  }
256
275
  if (classExtendsNull)
257
- c.error(superCall, 1808 /* Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null */);
276
+ c.error(superCall, 1828 /* Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null */);
258
277
  const emitStandardClassFields = getUseDefineForClassFields(c.compilerOptions) && getEmitScriptTarget(c.compilerOptions) >= ScriptTarget.ES2022;
259
278
  if (emitStandardClassFields)
260
279
  return;
@@ -262,31 +281,31 @@ function checkConstructorSuperCall(c, node) {
262
281
  if (!needsRootLevelSuperCall(classDecl, node))
263
282
  return;
264
283
  let parent = superCall.parent;
265
- while (parent.kind === 218 /* SyntaxKind.ParenthesizedExpression */)
284
+ while (parent.kind === 219 /* SyntaxKind.ParenthesizedExpression */)
266
285
  parent = parent.parent;
267
- if (parent.kind !== 245 /* SyntaxKind.ExpressionStatement */ || parent.parent !== body) {
268
- c.error(superCall, 572 /* Diagnostics.A_super_call_must_be_a_root_level_statement_within_a_constructor_of_a_derived_class_that_contains_initialized_properties_parameter_properties_or_private_identifiers */);
286
+ if (parent.kind !== 246 /* SyntaxKind.ExpressionStatement */ || parent.parent !== body) {
287
+ c.error(superCall, 579 /* Diagnostics.A_super_call_must_be_a_root_level_statement_within_a_constructor_of_a_derived_class_that_contains_initialized_properties_parameter_properties_or_private_identifiers */);
269
288
  return;
270
289
  }
271
290
  for (const statement of getStatements(body).nodes) {
272
- if (statement.kind === 245 /* SyntaxKind.ExpressionStatement */ &&
291
+ if (statement.kind === 246 /* SyntaxKind.ExpressionStatement */ &&
273
292
  isSuperCall(skipOuterExpressions(getExpression(statement))))
274
293
  return;
275
294
  if (nodeImmediatelyReferencesSuperOrThis(statement))
276
295
  break;
277
296
  }
278
- c.error(node, 550 /* Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_to_refer_to_super_or_this_when_a_derived_class_contains_initialized_properties_parameter_properties_or_private_identifiers */);
297
+ c.error(node, 557 /* Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_to_refer_to_super_or_this_when_a_derived_class_contains_initialized_properties_parameter_properties_or_private_identifiers */);
279
298
  }
280
299
  function isSuperCall(node) {
281
- return node.kind === 214 /* SyntaxKind.CallExpression */ && getExpression(node).kind === 107 /* SyntaxKind.SuperKeyword */;
300
+ return node.kind === 215 /* SyntaxKind.CallExpression */ && getExpression(node).kind === 107 /* SyntaxKind.SuperKeyword */;
282
301
  }
283
302
  function skipOuterExpressions(node) {
284
303
  let n = node;
285
- while (n.kind === 218 /* SyntaxKind.ParenthesizedExpression */ ||
286
- n.kind === 235 /* SyntaxKind.AsExpression */ ||
287
- n.kind === 239 /* SyntaxKind.SatisfiesExpression */ ||
288
- n.kind === 217 /* SyntaxKind.TypeAssertionExpression */ ||
289
- n.kind === 236 /* SyntaxKind.NonNullExpression */)
304
+ while (n.kind === 219 /* SyntaxKind.ParenthesizedExpression */ ||
305
+ n.kind === 236 /* SyntaxKind.AsExpression */ ||
306
+ n.kind === 240 /* SyntaxKind.SatisfiesExpression */ ||
307
+ n.kind === 218 /* SyntaxKind.TypeAssertionExpression */ ||
308
+ n.kind === 237 /* SyntaxKind.NonNullExpression */)
290
309
  n = getExpression(n);
291
310
  return n;
292
311
  }
@@ -301,7 +320,7 @@ function needsRootLevelSuperCall(classDecl, constructor) {
301
320
  }
302
321
  function isInstancePropertyWithInitializerOrPrivateIdentifierProperty(n) {
303
322
  return (isPrivateIdentifierClassElementDeclaration(n) ||
304
- (n.kind === 173 /* SyntaxKind.PropertyDeclaration */ && !isStatic(n) && getInitializer(n) !== undefined));
323
+ (n.kind === 174 /* SyntaxKind.PropertyDeclaration */ && !isStatic(n) && getInitializer(n) !== undefined));
305
324
  }
306
325
  /** Finds the first `super(...)` call outside nested functions. */
307
326
  class SuperCallFinder extends NodeVisitor {
@@ -323,17 +342,17 @@ class SuperOrThisReferenceFinder extends NodeVisitor {
323
342
  case 107 /* SyntaxKind.SuperKeyword */:
324
343
  case 109 /* SyntaxKind.ThisKeyword */:
325
344
  return true;
326
- case 220 /* SyntaxKind.ArrowFunction */:
327
- case 263 /* SyntaxKind.FunctionDeclaration */:
328
- case 219 /* SyntaxKind.FunctionExpression */:
329
- case 173 /* SyntaxKind.PropertyDeclaration */:
345
+ case 221 /* SyntaxKind.ArrowFunction */:
346
+ case 264 /* SyntaxKind.FunctionDeclaration */:
347
+ case 220 /* SyntaxKind.FunctionExpression */:
348
+ case 174 /* SyntaxKind.PropertyDeclaration */:
330
349
  return false;
331
- case 242 /* SyntaxKind.Block */:
350
+ case 243 /* SyntaxKind.Block */:
332
351
  switch (node.parent.kind) {
333
- case 177 /* SyntaxKind.Constructor */:
334
- case 175 /* SyntaxKind.MethodDeclaration */:
335
- case 178 /* SyntaxKind.GetAccessor */:
336
- case 179 /* SyntaxKind.SetAccessor */:
352
+ case 178 /* SyntaxKind.Constructor */:
353
+ case 176 /* SyntaxKind.MethodDeclaration */:
354
+ case 179 /* SyntaxKind.GetAccessor */:
355
+ case 180 /* SyntaxKind.SetAccessor */:
337
356
  return false;
338
357
  }
339
358
  }
@@ -352,7 +371,7 @@ function checkPropertyInitialization(c, node) {
352
371
  return;
353
372
  const constructor = findConstructorDeclaration(node);
354
373
  for (const member of getMembers(node).nodes) {
355
- if (member.kind !== 173 /* SyntaxKind.PropertyDeclaration */)
374
+ if (member.kind !== 174 /* SyntaxKind.PropertyDeclaration */)
356
375
  continue;
357
376
  if (hasSyntacticModifier(member, 128 /* ModifierFlags.Ambient */) ||
358
377
  hasSyntacticModifier(member, 64 /* ModifierFlags.Abstract */) ||
@@ -364,7 +383,7 @@ function checkPropertyInitialization(c, node) {
364
383
  const propName = prop.name;
365
384
  if (propName.kind !== 79 /* SyntaxKind.Identifier */ &&
366
385
  propName.kind !== 80 /* SyntaxKind.PrivateIdentifier */ &&
367
- propName.kind !== 168 /* SyntaxKind.ComputedPropertyName */)
386
+ propName.kind !== 169 /* SyntaxKind.ComputedPropertyName */)
368
387
  continue;
369
388
  const symbol = getSymbolOfDeclaration(c, member);
370
389
  if (symbol === undefined)
@@ -374,7 +393,7 @@ function checkPropertyInitialization(c, node) {
374
393
  continue;
375
394
  if (constructor !== undefined && isPropertyInitializedInConstructor(c, propName, t, constructor))
376
395
  continue;
377
- c.error(propName, 718 /* Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor */, declarationNameToString(getSourceFileOfNode(propName), propName));
396
+ c.error(propName, 725 /* Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor */, declarationNameToString(getSourceFileOfNode(propName), propName));
378
397
  }
379
398
  }
380
399
  /** Whether `this.name` is definitely assigned at the end of the constructor, by control flow. */
@@ -382,7 +401,7 @@ export function isPropertyInitializedInConstructor(c, propName, propType, constr
382
401
  const thisExpression = new KeywordExpression(109 /* SyntaxKind.ThisKeyword */);
383
402
  const returnFlowNode = constructor.returnFlowNode;
384
403
  let reference;
385
- if (propName.kind === 168 /* SyntaxKind.ComputedPropertyName */) {
404
+ if (propName.kind === 169 /* SyntaxKind.ComputedPropertyName */) {
386
405
  const access = new ElementAccessExpression(thisExpression, undefined, getExpression(propName), 0 /* NodeFlags.None */);
387
406
  access.flowNode = returnFlowNode;
388
407
  reference = access;
@@ -419,7 +438,7 @@ export function getFlowTypeInConstructor(c, symbol, constructor) {
419
438
  const reference = newThisPropertyReference(symbol, constructor, constructor.returnFlowNode);
420
439
  const flowType = getFlowTypeOfProperty(c, reference, symbol);
421
440
  if (c.noImplicitAny && (flowType === c.autoType || flowType === c.autoArrayType))
422
- c.error(symbol.valueDeclaration, 1680 /* Diagnostics.Member_0_implicitly_has_an_1_type */, symbolToString(c, symbol), typeToString(c, flowType));
441
+ c.error(symbol.valueDeclaration, 1699 /* Diagnostics.Member_0_implicitly_has_an_1_type */, symbolToString(c, symbol), typeToString(c, flowType));
423
442
  // Assignments of only null or undefined infer nothing.
424
443
  if (everyType(flowType, (t) => hasTypeFacts(c, t, 50331648 /* TypeFacts.IsUndefinedOrNull */)))
425
444
  return undefined;
@@ -431,7 +450,7 @@ export function getFlowTypeInStaticBlocks(c, symbol, staticBlocks) {
431
450
  const reference = newThisPropertyReference(symbol, staticBlock, staticBlock.returnFlowNode);
432
451
  const flowType = getFlowTypeOfProperty(c, reference, symbol);
433
452
  if (c.noImplicitAny && (flowType === c.autoType || flowType === c.autoArrayType))
434
- c.error(symbol.valueDeclaration, 1680 /* Diagnostics.Member_0_implicitly_has_an_1_type */, symbolToString(c, symbol), typeToString(c, flowType));
453
+ c.error(symbol.valueDeclaration, 1699 /* Diagnostics.Member_0_implicitly_has_an_1_type */, symbolToString(c, symbol), typeToString(c, flowType));
435
454
  if (everyType(flowType, (t) => hasTypeFacts(c, t, 50331648 /* TypeFacts.IsUndefinedOrNull */)))
436
455
  continue;
437
456
  return convertAutoToAny(c, flowType);
@@ -470,7 +489,7 @@ export function getFlowTypeOfProperty(c, reference, prop) {
470
489
  export function isAutoTypedProperty(c, symbol) {
471
490
  const declaration = symbol.valueDeclaration;
472
491
  return (declaration !== undefined &&
473
- declaration.kind === 173 /* SyntaxKind.PropertyDeclaration */ &&
492
+ declaration.kind === 174 /* SyntaxKind.PropertyDeclaration */ &&
474
493
  getType(declaration) === undefined &&
475
494
  getInitializer(declaration) === undefined &&
476
495
  c.noImplicitAny);
@@ -487,32 +506,57 @@ function containsUndefinedType(t) {
487
506
  const first = (t.flags & 134217728 /* TypeFlags.Union */) !== 0 ? typesOf(t)[0] : t;
488
507
  return (first.flags & 4 /* TypeFlags.Undefined */) !== 0;
489
508
  }
490
- /** Whether `new` at `node` may call a constructor, reporting private and protected ones out of reach. */
491
- export function isConstructorAccessible(c, node, signature) {
492
- if (signature === undefined || signature.declaration === undefined)
493
- return true;
494
- const declaration = signature.declaration;
495
- const modifiers = getModifierFlags(declaration) & 6 /* ModifierFlags.NonPublicAccessibilityModifier */;
496
- // Public constructors and constructor functions are always accessible.
497
- if (modifiers === 0 || declaration.kind !== 177 /* SyntaxKind.Constructor */)
498
- return true;
499
- const classSymbol = getSymbol(declaration.parent);
500
- const declaringClassDeclaration = getClassLikeDeclarationOfSymbol(classSymbol);
501
- const declaringClass = getDeclaredTypeOfSymbol(c, classSymbol);
502
- // Private and protected constructors are only callable within their class, or subclasses if protected.
503
- for (let container = getContainingClass(node); container !== undefined; container = getContainingClass(container))
504
- if (container === declaringClassDeclaration)
505
- return true;
506
- const containingClass = getContainingClass(node);
507
- if (containingClass !== undefined && (modifiers & 4 /* ModifierFlags.Protected */) !== 0) {
508
- const containingType = getDeclaredTypeOfSymbol(c, getSymbol(containingClass));
509
- if (typeHasProtectedAccessibleBase(c, classSymbol, containingType))
510
- return true;
509
+ /** A constructor that `node` may not call: the modifiers that forbid it, and the class that declares it. */
510
+ export class ConstructorAccessibilityError {
511
+ kind;
512
+ declaringClass;
513
+ constructor(kind, declaringClass) {
514
+ this.kind = kind;
515
+ this.declaringClass = declaringClass;
516
+ }
517
+ }
518
+ /**
519
+ * The first of `signatures` whose constructor `node` may not call because of the modifiers in `modifiersMask`:
520
+ * private and protected constructors are only callable within their class, or subclasses if protected.
521
+ */
522
+ export function getConstructorAccessibilityError(c, node, signatures, modifiersMask) {
523
+ for (const signature of signatures) {
524
+ const declaration = signature.declaration;
525
+ if (declaration === undefined)
526
+ continue;
527
+ const modifiers = getModifierFlags(declaration) & modifiersMask;
528
+ // Public constructors and constructor functions are always accessible.
529
+ if (modifiers === 0 || declaration.kind !== 178 /* SyntaxKind.Constructor */)
530
+ continue;
531
+ const classSymbol = getSymbol(declaration.parent);
532
+ const declaringClassDeclaration = getClassLikeDeclarationOfSymbol(classSymbol);
533
+ let withinClass = false;
534
+ for (let container = getContainingClass(node); container !== undefined; container = getContainingClass(container))
535
+ if (container === declaringClassDeclaration) {
536
+ withinClass = true;
537
+ break;
538
+ }
539
+ if (withinClass)
540
+ continue;
541
+ const containingClass = getContainingClass(node);
542
+ if (containingClass !== undefined && (modifiers & 4 /* ModifierFlags.Protected */) !== 0) {
543
+ const containingType = getTypeOfNode(c, containingClass);
544
+ if (typeHasProtectedAccessibleBase(c, classSymbol, containingType))
545
+ continue;
546
+ }
547
+ return new ConstructorAccessibilityError(modifiers, getDeclaredTypeOfSymbol(c, classSymbol));
511
548
  }
512
- if ((modifiers & 2 /* ModifierFlags.Private */) !== 0)
513
- c.error(node, 807 /* Diagnostics.Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration */, typeToString(c, declaringClass));
514
- if ((modifiers & 4 /* ModifierFlags.Protected */) !== 0)
515
- c.error(node, 808 /* Diagnostics.Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration */, typeToString(c, declaringClass));
549
+ return undefined;
550
+ }
551
+ /** Whether `new` at `node` may call the constructors of `signatures`, reporting private and protected ones out of reach. */
552
+ export function isConstructorAccessible(c, node, signatures) {
553
+ const error = getConstructorAccessibilityError(c, node, signatures, 6 /* ModifierFlags.NonPublicAccessibilityModifier */);
554
+ if (error === undefined)
555
+ return true;
556
+ if ((error.kind & 2 /* ModifierFlags.Private */) !== 0)
557
+ c.error(node, 814 /* Diagnostics.Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration */, typeToString(c, error.declaringClass));
558
+ if ((error.kind & 4 /* ModifierFlags.Protected */) !== 0)
559
+ c.error(node, 815 /* Diagnostics.Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration */, typeToString(c, error.declaringClass));
516
560
  return false;
517
561
  }
518
562
  /** Whether `target` is a base class of `t`, through bases that aren't mixins. */
@@ -560,7 +604,7 @@ function findMixins(c, types) {
560
604
  export function checkInterfaceDeclaration(c, node) {
561
605
  const decl = node;
562
606
  checkTypeParameters(c, decl.typeParameters);
563
- checkTypeNameIsReserved(c, decl.name, 596 /* Diagnostics.Interface_name_cannot_be_0 */);
607
+ checkTypeNameIsReserved(c, decl.name, 603 /* Diagnostics.Interface_name_cannot_be_0 */);
564
608
  checkExportsOnMergedDeclarations(c, node);
565
609
  const symbol = getSymbolOfDeclaration(c, node);
566
610
  if (symbol !== undefined) {
@@ -573,7 +617,7 @@ export function checkInterfaceDeclaration(c, node) {
573
617
  checkHeritageClauses(c, decl.heritageClauses.nodes, false);
574
618
  for (const member of decl.members.nodes) {
575
619
  checkJSDocLinksOfNode(c, member);
576
- if (member.kind === 172 /* SyntaxKind.PropertySignature */)
620
+ if (member.kind === 173 /* SyntaxKind.PropertySignature */)
577
621
  checkVariableLikeDeclaration(c, member);
578
622
  else
579
623
  checkTypeNodeIfPresent(c, member);