tsc-ts 0.0.10 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (379) hide show
  1. package/README.md +1 -1
  2. package/bin/tsc-ts.js +70 -1
  3. package/dist/api/compiler/ast-utilities.d.ts +19 -1
  4. package/dist/api/compiler/ast-utilities.js +180 -95
  5. package/dist/api/compiler/ast.d.ts +29 -18
  6. package/dist/api/compiler/ast.js +1040 -1007
  7. package/dist/api/compiler/astnav.js +15 -15
  8. package/dist/api/compiler/binder-utilities.js +186 -186
  9. package/dist/api/compiler/binder.js +290 -263
  10. package/dist/api/compiler/character-codes.js +2 -2
  11. package/dist/api/compiler/checker-calls.js +173 -123
  12. package/dist/api/compiler/checker-classes.d.ts +14 -3
  13. package/dist/api/compiler/checker-classes.js +136 -91
  14. package/dist/api/compiler/checker-contextual.d.ts +20 -0
  15. package/dist/api/compiler/checker-contextual.js +175 -62
  16. package/dist/api/compiler/checker-declaration-order.js +79 -79
  17. package/dist/api/compiler/checker-declarations.d.ts +1 -0
  18. package/dist/api/compiler/checker-declarations.js +160 -136
  19. package/dist/api/compiler/checker-declared-types.js +67 -65
  20. package/dist/api/compiler/checker-decorators.js +77 -77
  21. package/dist/api/compiler/checker-deprecation.d.ts +8 -3
  22. package/dist/api/compiler/checker-deprecation.js +76 -55
  23. package/dist/api/compiler/checker-destructuring.js +47 -45
  24. package/dist/api/compiler/checker-elaboration.js +24 -24
  25. package/dist/api/compiler/checker-emit-helpers.js +4 -4
  26. package/dist/api/compiler/checker-emit-resolver.d.ts +4 -2
  27. package/dist/api/compiler/checker-emit-resolver.js +25 -13
  28. package/dist/api/compiler/checker-evaluator.js +9 -9
  29. package/dist/api/compiler/checker-expressions.js +258 -212
  30. package/dist/api/compiler/checker-functions.js +113 -107
  31. package/dist/api/compiler/checker-generated-code.d.ts +0 -11
  32. package/dist/api/compiler/checker-generated-code.js +28 -52
  33. package/dist/api/compiler/checker-grammar.d.ts +1 -0
  34. package/dist/api/compiler/checker-grammar.js +469 -438
  35. package/dist/api/compiler/checker-heritage.js +91 -93
  36. package/dist/api/compiler/checker-inference.d.ts +77 -5
  37. package/dist/api/compiler/checker-inference.js +487 -113
  38. package/dist/api/compiler/checker-iteration.d.ts +0 -10
  39. package/dist/api/compiler/checker-iteration.js +35 -52
  40. package/dist/api/compiler/checker-javascript.js +14 -14
  41. package/dist/api/compiler/checker-jsdoc.d.ts +8 -10
  42. package/dist/api/compiler/checker-jsdoc.js +67 -58
  43. package/dist/api/compiler/checker-jsx.js +107 -89
  44. package/dist/api/compiler/checker-members.d.ts +9 -2
  45. package/dist/api/compiler/checker-members.js +210 -74
  46. package/dist/api/compiler/checker-modules.d.ts +15 -6
  47. package/dist/api/compiler/checker-modules.js +469 -309
  48. package/dist/api/compiler/checker-narrowing.js +273 -189
  49. package/dist/api/compiler/checker-object-literals.js +25 -22
  50. package/dist/api/compiler/checker-operators.js +126 -118
  51. package/dist/api/compiler/checker-overloads.js +27 -27
  52. package/dist/api/compiler/checker-property-access.js +59 -55
  53. package/dist/api/compiler/checker-services.d.ts +1 -0
  54. package/dist/api/compiler/checker-services.js +222 -210
  55. package/dist/api/compiler/checker-signatures.js +65 -49
  56. package/dist/api/compiler/checker-source-file.d.ts +5 -0
  57. package/dist/api/compiler/checker-source-file.js +154 -130
  58. package/dist/api/compiler/checker-statements.js +33 -32
  59. package/dist/api/compiler/checker-super.js +50 -50
  60. package/dist/api/compiler/checker-symbol-types.js +109 -93
  61. package/dist/api/compiler/checker-symbols.d.ts +13 -1
  62. package/dist/api/compiler/checker-symbols.js +264 -149
  63. package/dist/api/compiler/checker-type-factory.d.ts +5 -0
  64. package/dist/api/compiler/checker-type-factory.js +190 -46
  65. package/dist/api/compiler/checker-type-nodes.d.ts +1 -0
  66. package/dist/api/compiler/checker-type-nodes.js +179 -141
  67. package/dist/api/compiler/checker-type-operators.d.ts +2 -0
  68. package/dist/api/compiler/checker-type-operators.js +110 -63
  69. package/dist/api/compiler/checker-types.d.ts +80 -3
  70. package/dist/api/compiler/checker-types.js +121 -2
  71. package/dist/api/compiler/checker-unused.js +114 -118
  72. package/dist/api/compiler/checker-utilities.js +11 -11
  73. package/dist/api/compiler/checker.d.ts +97 -31
  74. package/dist/api/compiler/checker.js +149 -35
  75. package/dist/api/compiler/command-line.d.ts +1 -3
  76. package/dist/api/compiler/command-line.js +47 -44
  77. package/dist/api/compiler/compile-program.d.ts +24 -4
  78. package/dist/api/compiler/compile-program.js +53 -26
  79. package/dist/api/compiler/diagnostic-messages.d.ts +1849 -1774
  80. package/dist/api/compiler/diagnostic-messages.js +128 -122
  81. package/dist/api/compiler/diagnostics.js +7 -7
  82. package/dist/api/compiler/emitter.d.ts +7 -1
  83. package/dist/api/compiler/emitter.js +53 -11
  84. package/dist/api/compiler/expr-record.d.ts +11 -0
  85. package/dist/api/compiler/expr-record.js +53 -0
  86. package/dist/api/compiler/file-include.d.ts +2 -1
  87. package/dist/api/compiler/file-include.js +11 -7
  88. package/dist/api/compiler/file-loader.d.ts +10 -0
  89. package/dist/api/compiler/file-loader.js +138 -41
  90. package/dist/api/compiler/identifier-name.d.ts +9 -0
  91. package/dist/api/compiler/identifier-name.js +10 -0
  92. package/dist/api/compiler/instantiation.d.ts +7 -0
  93. package/dist/api/compiler/instantiation.js +101 -49
  94. package/dist/api/compiler/jsdoc.js +27 -25
  95. package/dist/api/compiler/link-tables.d.ts +48 -18
  96. package/dist/api/compiler/link-tables.js +80 -37
  97. package/dist/api/compiler/locales/cs-CZ.d.ts +1 -1
  98. package/dist/api/compiler/locales/cs-CZ.js +1 -1
  99. package/dist/api/compiler/locales/de-DE.d.ts +1 -1
  100. package/dist/api/compiler/locales/de-DE.js +1 -1
  101. package/dist/api/compiler/locales/es-ES.d.ts +1 -1
  102. package/dist/api/compiler/locales/es-ES.js +1 -1
  103. package/dist/api/compiler/locales/fr-FR.d.ts +1 -1
  104. package/dist/api/compiler/locales/fr-FR.js +1 -1
  105. package/dist/api/compiler/locales/it-IT.d.ts +1 -1
  106. package/dist/api/compiler/locales/it-IT.js +1 -1
  107. package/dist/api/compiler/locales/ja-JP.d.ts +1 -1
  108. package/dist/api/compiler/locales/ja-JP.js +1 -1
  109. package/dist/api/compiler/locales/ko-KR.d.ts +1 -1
  110. package/dist/api/compiler/locales/ko-KR.js +1 -1
  111. package/dist/api/compiler/locales/pl-PL.d.ts +1 -1
  112. package/dist/api/compiler/locales/pl-PL.js +1 -1
  113. package/dist/api/compiler/locales/pt-BR.d.ts +1 -1
  114. package/dist/api/compiler/locales/pt-BR.js +1 -1
  115. package/dist/api/compiler/locales/ru-RU.d.ts +1 -1
  116. package/dist/api/compiler/locales/ru-RU.js +1 -1
  117. package/dist/api/compiler/locales/tr-TR.d.ts +1 -1
  118. package/dist/api/compiler/locales/tr-TR.js +1 -1
  119. package/dist/api/compiler/locales/zh-CN.d.ts +1 -1
  120. package/dist/api/compiler/locales/zh-CN.js +1 -1
  121. package/dist/api/compiler/locales/zh-TW.d.ts +1 -1
  122. package/dist/api/compiler/locales/zh-TW.js +1 -1
  123. package/dist/api/compiler/module-resolution-types.js +6 -6
  124. package/dist/api/compiler/module-resolution.d.ts +10 -1
  125. package/dist/api/compiler/module-resolution.js +115 -84
  126. package/dist/api/compiler/module-specifiers.d.ts +15 -0
  127. package/dist/api/compiler/module-specifiers.js +24 -18
  128. package/dist/api/compiler/name-resolver.js +74 -65
  129. package/dist/api/compiler/node-builder-names.d.ts +11 -3
  130. package/dist/api/compiler/node-builder-names.js +210 -90
  131. package/dist/api/compiler/node-builder-pseudo.js +29 -31
  132. package/dist/api/compiler/node-builder-reuse.js +23 -22
  133. package/dist/api/compiler/node-builder.d.ts +18 -1
  134. package/dist/api/compiler/node-builder.js +191 -102
  135. package/dist/api/compiler/option-declarations.d.ts +2 -6
  136. package/dist/api/compiler/option-declarations.js +315 -375
  137. package/dist/api/compiler/options.d.ts +15 -33
  138. package/dist/api/compiler/options.js +21 -54
  139. package/dist/api/compiler/output-paths.d.ts +4 -1
  140. package/dist/api/compiler/output-paths.js +6 -11
  141. package/dist/api/compiler/package-json.d.ts +3 -3
  142. package/dist/api/compiler/package-json.js +11 -10
  143. package/dist/api/compiler/parser.d.ts +42 -20
  144. package/dist/api/compiler/parser.js +318 -224
  145. package/dist/api/compiler/path.d.ts +9 -0
  146. package/dist/api/compiler/path.js +20 -3
  147. package/dist/api/compiler/printer/emit-context.d.ts +3 -1
  148. package/dist/api/compiler/printer/emit-context.js +16 -1
  149. package/dist/api/compiler/printer/factory-base.d.ts +2 -2
  150. package/dist/api/compiler/printer/factory-base.js +7 -3
  151. package/dist/api/compiler/printer/factory.js +6 -3
  152. package/dist/api/compiler/printer/helpers.js +10 -1
  153. package/dist/api/compiler/printer/name-generator.d.ts +1 -1
  154. package/dist/api/compiler/printer/name-generator.js +35 -16
  155. package/dist/api/compiler/printer/printer.d.ts +1 -0
  156. package/dist/api/compiler/printer/printer.js +306 -283
  157. package/dist/api/compiler/printer/utilities.js +149 -147
  158. package/dist/api/compiler/program-checker.d.ts +8 -2
  159. package/dist/api/compiler/program-checker.js +84 -34
  160. package/dist/api/compiler/program-utilities.d.ts +3 -1
  161. package/dist/api/compiler/program-utilities.js +28 -15
  162. package/dist/api/compiler/program.d.ts +2 -0
  163. package/dist/api/compiler/program.js +69 -57
  164. package/dist/api/compiler/pseudo-bigint.d.ts +2 -0
  165. package/dist/api/compiler/pseudo-bigint.js +18 -0
  166. package/dist/api/compiler/regexp-checker.d.ts +1 -1
  167. package/dist/api/compiler/regexp-checker.js +93 -76
  168. package/dist/api/compiler/relations.d.ts +27 -4
  169. package/dist/api/compiler/relations.js +337 -180
  170. package/dist/api/compiler/reparser.js +64 -59
  171. package/dist/api/compiler/scanner.d.ts +27 -2
  172. package/dist/api/compiler/scanner.js +181 -150
  173. package/dist/api/compiler/shared-results.d.ts +696 -0
  174. package/dist/api/compiler/shared-results.js +2905 -0
  175. package/dist/api/compiler/sourcemap.js +2 -2
  176. package/dist/api/compiler/symbol-accessibility.js +87 -74
  177. package/dist/api/compiler/symbol.d.ts +22 -13
  178. package/dist/api/compiler/symbol.js +15 -1
  179. package/dist/api/compiler/syntax-kind.d.ts +198 -197
  180. package/dist/api/compiler/transformers/alias-references.js +247 -139
  181. package/dist/api/compiler/transformers/async-utilities.js +25 -25
  182. package/dist/api/compiler/transformers/async.d.ts +0 -1
  183. package/dist/api/compiler/transformers/async.js +64 -77
  184. package/dist/api/compiler/transformers/class-fields.d.ts +1 -0
  185. package/dist/api/compiler/transformers/class-fields.js +81 -78
  186. package/dist/api/compiler/transformers/commonjs-module.js +18 -15
  187. package/dist/api/compiler/transformers/const-enum-inliner.js +1 -1
  188. package/dist/api/compiler/transformers/declarations-diagnostics.js +247 -244
  189. package/dist/api/compiler/transformers/declarations-pseudo.js +100 -100
  190. package/dist/api/compiler/transformers/declarations-resolver.d.ts +0 -3
  191. package/dist/api/compiler/transformers/declarations-syntactic.d.ts +1 -2
  192. package/dist/api/compiler/transformers/declarations-syntactic.js +134 -156
  193. package/dist/api/compiler/transformers/declarations-tracker.js +18 -18
  194. package/dist/api/compiler/transformers/declarations.d.ts +4 -1
  195. package/dist/api/compiler/transformers/declarations.js +307 -239
  196. package/dist/api/compiler/transformers/decorator-metadata.d.ts +1 -1
  197. package/dist/api/compiler/transformers/decorator-metadata.js +53 -45
  198. package/dist/api/compiler/transformers/decorator-utilities.js +24 -24
  199. package/dist/api/compiler/transformers/destructuring.js +19 -18
  200. package/dist/api/compiler/transformers/emit-resolver.js +1 -1
  201. package/dist/api/compiler/transformers/es-decorators.js +55 -55
  202. package/dist/api/compiler/transformers/external-module-info.js +3 -3
  203. package/dist/api/compiler/transformers/for-await.js +25 -25
  204. package/dist/api/compiler/transformers/import-elision.js +14 -14
  205. package/dist/api/compiler/transformers/jsx.js +12 -12
  206. package/dist/api/compiler/transformers/legacy-decorators.js +17 -17
  207. package/dist/api/compiler/transformers/module.js +8 -8
  208. package/dist/api/compiler/transformers/named-evaluation.js +4 -4
  209. package/dist/api/compiler/transformers/object-rest-spread.js +20 -20
  210. package/dist/api/compiler/transformers/optional-chain.js +10 -10
  211. package/dist/api/compiler/transformers/reference-resolver.d.ts +12 -1
  212. package/dist/api/compiler/transformers/reference-resolver.js +131 -69
  213. package/dist/api/compiler/transformers/runtime-syntax.js +35 -31
  214. package/dist/api/compiler/transformers/subtree-facts.js +47 -47
  215. package/dist/api/compiler/transformers/syntax-facts.js +56 -58
  216. package/dist/api/compiler/transformers/type-eraser.js +73 -66
  217. package/dist/api/compiler/transformers/type-serialization.js +24 -24
  218. package/dist/api/compiler/transformers/using.js +12 -12
  219. package/dist/api/compiler/transformers/utilities.js +77 -77
  220. package/dist/api/compiler/transformers/visitor-base.js +172 -172
  221. package/dist/api/compiler/transformers/visitor-hooks.js +6 -2
  222. package/dist/api/compiler/tsconfig.d.ts +10 -2
  223. package/dist/api/compiler/tsconfig.js +136 -48
  224. package/dist/api/compiler/type-printer.js +40 -3
  225. package/dist/api/compiler/types.d.ts +2 -1
  226. package/dist/api/library/ast.generated.d.ts +42 -39
  227. package/dist/api/library/ast.generated.js +1 -1
  228. package/dist/api/library/compiler-options.generated.d.ts +111 -100
  229. package/dist/api/library/compiler-options.generated.js +1 -1
  230. package/dist/api/library/disk.js +12 -1
  231. package/dist/api/library/enums.generated.d.ts +206 -206
  232. package/dist/api/library/enums.generated.js +206 -206
  233. package/dist/api/library/nodes.js +26 -26
  234. package/package.json +9 -9
  235. package/src/compiler/ast-utilities.ts +99 -7
  236. package/src/compiler/ast.ts +74 -38
  237. package/src/compiler/binder.ts +39 -4
  238. package/src/compiler/cgroup.ts +157 -0
  239. package/src/compiler/character-codes.ts +2 -2
  240. package/src/compiler/checker-calls.ts +76 -8
  241. package/src/compiler/checker-classes.ts +80 -25
  242. package/src/compiler/checker-contextual.ts +110 -1
  243. package/src/compiler/checker-declarations.ts +31 -4
  244. package/src/compiler/checker-declared-types.ts +8 -5
  245. package/src/compiler/checker-decorators.ts +1 -1
  246. package/src/compiler/checker-deprecation.ts +29 -8
  247. package/src/compiler/checker-destructuring.ts +10 -3
  248. package/src/compiler/checker-emit-helpers.ts +1 -0
  249. package/src/compiler/checker-emit-resolver.ts +16 -6
  250. package/src/compiler/checker-expressions.ts +95 -47
  251. package/src/compiler/checker-functions.ts +21 -6
  252. package/src/compiler/checker-generated-code.ts +2 -22
  253. package/src/compiler/checker-grammar.ts +133 -60
  254. package/src/compiler/checker-heritage.ts +22 -21
  255. package/src/compiler/checker-inference.ts +514 -87
  256. package/src/compiler/checker-iteration.ts +18 -31
  257. package/src/compiler/checker-javascript.ts +1 -1
  258. package/src/compiler/checker-jsdoc.ts +50 -27
  259. package/src/compiler/checker-jsx.ts +28 -5
  260. package/src/compiler/checker-members.ts +197 -55
  261. package/src/compiler/checker-modules.ts +332 -65
  262. package/src/compiler/checker-narrowing.ts +98 -19
  263. package/src/compiler/checker-object-literals.ts +3 -0
  264. package/src/compiler/checker-operators.ts +11 -4
  265. package/src/compiler/checker-property-access.ts +7 -2
  266. package/src/compiler/checker-services.ts +39 -12
  267. package/src/compiler/checker-signatures.ts +15 -1
  268. package/src/compiler/checker-source-file.ts +39 -13
  269. package/src/compiler/checker-statements.ts +3 -2
  270. package/src/compiler/checker-symbol-types.ts +29 -6
  271. package/src/compiler/checker-symbols.ts +158 -15
  272. package/src/compiler/checker-type-factory.ts +173 -35
  273. package/src/compiler/checker-type-nodes.ts +46 -3
  274. package/src/compiler/checker-type-operators.ts +83 -26
  275. package/src/compiler/checker-types.ts +147 -4
  276. package/src/compiler/checker-unused.ts +9 -14
  277. package/src/compiler/checker.ts +175 -41
  278. package/src/compiler/command-line.ts +28 -28
  279. package/src/compiler/compile-program.ts +59 -25
  280. package/src/compiler/decoder.ts +15 -5
  281. package/src/compiler/diagnostic-messages.ts +1973 -1892
  282. package/src/compiler/doctor-report.ts +133 -0
  283. package/src/compiler/emitter.ts +57 -8
  284. package/src/compiler/encoder.ts +23 -8
  285. package/src/compiler/expr-record.ts +59 -0
  286. package/src/compiler/file-include.ts +9 -3
  287. package/src/compiler/file-loader.ts +139 -32
  288. package/src/compiler/help.ts +10 -14
  289. package/src/compiler/identifier-name.ts +13 -0
  290. package/src/compiler/incremental.ts +86 -18
  291. package/src/compiler/init.ts +2 -7
  292. package/src/compiler/instantiation.ts +77 -22
  293. package/src/compiler/jsdoc.ts +7 -3
  294. package/src/compiler/link-tables.ts +82 -37
  295. package/src/compiler/locales/cs-CZ.ts +1 -1
  296. package/src/compiler/locales/de-DE.ts +1 -1
  297. package/src/compiler/locales/es-ES.ts +1 -1
  298. package/src/compiler/locales/fr-FR.ts +1 -1
  299. package/src/compiler/locales/it-IT.ts +1 -1
  300. package/src/compiler/locales/ja-JP.ts +1 -1
  301. package/src/compiler/locales/ko-KR.ts +1 -1
  302. package/src/compiler/locales/pl-PL.ts +1 -1
  303. package/src/compiler/locales/pt-BR.ts +1 -1
  304. package/src/compiler/locales/ru-RU.ts +1 -1
  305. package/src/compiler/locales/tr-TR.ts +1 -1
  306. package/src/compiler/locales/zh-CN.ts +1 -1
  307. package/src/compiler/locales/zh-TW.ts +1 -1
  308. package/src/compiler/module-resolution.ts +44 -8
  309. package/src/compiler/module-specifiers.ts +62 -20
  310. package/src/compiler/name-resolver.ts +9 -1
  311. package/src/compiler/node-builder-names.ts +236 -54
  312. package/src/compiler/node-builder-pseudo.ts +4 -7
  313. package/src/compiler/node-builder-reuse.ts +5 -4
  314. package/src/compiler/node-builder.ts +130 -31
  315. package/src/compiler/option-declarations.ts +33 -103
  316. package/src/compiler/options.ts +23 -62
  317. package/src/compiler/output-paths.ts +5 -18
  318. package/src/compiler/package-entrypoints.ts +345 -0
  319. package/src/compiler/package-json.ts +4 -4
  320. package/src/compiler/parallel-check.ts +543 -147
  321. package/src/compiler/parallel-emit.ts +4 -4
  322. package/src/compiler/parser.ts +166 -47
  323. package/src/compiler/path.ts +22 -2
  324. package/src/compiler/printer/emit-context.ts +16 -0
  325. package/src/compiler/printer/factory-base.ts +10 -3
  326. package/src/compiler/printer/factory.ts +7 -3
  327. package/src/compiler/printer/helpers.ts +10 -1
  328. package/src/compiler/printer/name-generator.ts +24 -2
  329. package/src/compiler/printer/printer.ts +39 -16
  330. package/src/compiler/printer/utilities.ts +8 -2
  331. package/src/compiler/program-checker.ts +53 -5
  332. package/src/compiler/program-utilities.ts +23 -10
  333. package/src/compiler/program.ts +13 -1
  334. package/src/compiler/pseudo-bigint.ts +17 -0
  335. package/src/compiler/regexp-checker.ts +63 -30
  336. package/src/compiler/relations.ts +233 -77
  337. package/src/compiler/reparser.ts +14 -5
  338. package/src/compiler/run-config.ts +1383 -0
  339. package/src/compiler/run-record-read.ts +87 -0
  340. package/src/compiler/run-records.ts +575 -0
  341. package/src/compiler/scanner.ts +166 -120
  342. package/src/compiler/shared-results.ts +3144 -0
  343. package/src/compiler/show-config.ts +18 -1
  344. package/src/compiler/sourcemap.ts +2 -2
  345. package/src/compiler/symbol-accessibility.ts +26 -3
  346. package/src/compiler/symbol.ts +31 -14
  347. package/src/compiler/syntax-kind.ts +188 -187
  348. package/src/compiler/thread-entry.ts +22 -3
  349. package/src/compiler/transformers/alias-references.ts +123 -4
  350. package/src/compiler/transformers/async.ts +2 -17
  351. package/src/compiler/transformers/class-fields.ts +13 -12
  352. package/src/compiler/transformers/commonjs-module.ts +11 -7
  353. package/src/compiler/transformers/declarations-diagnostics.ts +5 -3
  354. package/src/compiler/transformers/declarations-pseudo.ts +2 -4
  355. package/src/compiler/transformers/declarations-resolver.ts +0 -3
  356. package/src/compiler/transformers/declarations-syntactic.ts +1 -21
  357. package/src/compiler/transformers/declarations.ts +136 -49
  358. package/src/compiler/transformers/decorator-metadata.ts +9 -1
  359. package/src/compiler/transformers/destructuring.ts +4 -3
  360. package/src/compiler/transformers/external-module-info.ts +1 -1
  361. package/src/compiler/transformers/jsx.ts +2 -1
  362. package/src/compiler/transformers/reference-resolver.ts +83 -19
  363. package/src/compiler/transformers/runtime-syntax.ts +6 -1
  364. package/src/compiler/transformers/syntax-facts.ts +2 -7
  365. package/src/compiler/transformers/type-eraser.ts +10 -1
  366. package/src/compiler/transformers/type-serialization.ts +3 -2
  367. package/src/compiler/transformers/visitor-base.ts +2 -1
  368. package/src/compiler/transformers/visitor-hooks.ts +9 -4
  369. package/src/compiler/tsc-build.ts +67 -6
  370. package/src/compiler/tsc-cli.ts +35 -4
  371. package/src/compiler/tsc-compile.ts +220 -10
  372. package/src/compiler/tsc-watch.ts +97 -47
  373. package/src/compiler/tsconfig.ts +176 -19
  374. package/src/compiler/type-printer.ts +36 -2
  375. package/src/compiler/types.ts +2 -1
  376. package/src/library/ast.generated.ts +57 -41
  377. package/src/library/compiler-options.generated.ts +117 -103
  378. package/src/library/disk.ts +10 -1
  379. package/src/library/enums.generated.ts +196 -196
@@ -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,18 @@ 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';
31
+ import { IdentifierName } from './identifier-name.js';
29
32
  export function checkClassDeclaration(c, node) {
30
33
  checkClassLikeDeclaration(c, node);
31
34
  checkClassMembers(c, node);
@@ -52,7 +55,7 @@ function checkClassExpressionExternalHelpers(c, node) {
52
55
  if (willTransformESDecorators && classOrConstructorParameterIsDecorated(false, node)) {
53
56
  location = node;
54
57
  for (const modifier of getModifiers(node)?.nodes ?? [])
55
- if (modifier.kind === 171 /* SyntaxKind.Decorator */) {
58
+ if (modifier.kind === 172 /* SyntaxKind.Decorator */) {
56
59
  location = modifier;
57
60
  break;
58
61
  }
@@ -62,10 +65,10 @@ function checkClassExpressionExternalHelpers(c, node) {
62
65
  if (location === undefined)
63
66
  return;
64
67
  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 */)
68
+ if ((parent.kind === 304 /* SyntaxKind.PropertyAssignment */ ||
69
+ parent.kind === 174 /* SyntaxKind.PropertyDeclaration */ ||
70
+ parent.kind === 210 /* SyntaxKind.BindingElement */) &&
71
+ getName(parent).kind === 169 /* SyntaxKind.ComputedPropertyName */)
69
72
  checkExternalEmitHelpers(c, location, 131072 /* ExternalEmitHelpers.PropKey */);
70
73
  }
71
74
  export function checkClassLikeDeferred(c, node) {
@@ -74,11 +77,27 @@ export function checkClassLikeDeferred(c, node) {
74
77
  function checkClassMembers(c, node) {
75
78
  for (const member of getMembers(node).nodes)
76
79
  checkClassMember(c, member);
80
+ checkConstructorDeclaredProperties(c, node);
81
+ }
82
+ /**
83
+ * Resolves the types of a JavaScript class's properties declared by `this.x` assignments in its
84
+ * constructor, so the diagnostics of their initializers don't depend on which use is checked first.
85
+ */
86
+ function checkConstructorDeclaredProperties(c, node) {
87
+ if (!isInJSFile(node))
88
+ return;
89
+ const symbol = getSymbolOfDeclaration(c, node);
90
+ if (symbol === undefined)
91
+ return;
92
+ for (const property of getPropertiesOfType(c, getDeclaredTypeOfSymbol(c, symbol)))
93
+ if (isConstructorDeclaredThisProperty(c, property) &&
94
+ c.symbolLinks(property).thisAssignmentLocation.parent === node)
95
+ getTypeOfSymbol(c, property);
77
96
  }
78
97
  function checkClassLikeDeclaration(c, node) {
79
98
  checkDecorators(c, node);
80
99
  checkCollisionsForDeclarationName(c, node, getName(node));
81
- if (node.kind === 264 /* SyntaxKind.ClassDeclaration */)
100
+ if (node.kind === 265 /* SyntaxKind.ClassDeclaration */)
82
101
  checkExportsOnMergedDeclarations(c, node);
83
102
  const typeParameters = getTypeParameters(node);
84
103
  checkTypeParameters(c, typeParameters);
@@ -93,7 +112,7 @@ function checkClassLikeDeclaration(c, node) {
93
112
  }
94
113
  const name = getName(node);
95
114
  if (name !== undefined)
96
- checkTypeNameIsReserved(c, name, 585 /* Diagnostics.Class_name_cannot_be_0 */);
115
+ checkTypeNameIsReserved(c, name, 592 /* Diagnostics.Class_name_cannot_be_0 */);
97
116
  const heritageClauses = getHeritageClauses(node);
98
117
  if (heritageClauses !== undefined)
99
118
  checkHeritageClauses(c, heritageClauses.nodes, true);
@@ -144,36 +163,37 @@ function checkHeritageClauses(c, clauses, isClass) {
144
163
  }
145
164
  function checkClassMember(c, member) {
146
165
  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 */)
166
+ if (member.kind === 174 /* SyntaxKind.PropertyDeclaration */ ||
167
+ member.kind === 176 /* SyntaxKind.MethodDeclaration */ ||
168
+ member.kind === 179 /* SyntaxKind.GetAccessor */ ||
169
+ member.kind === 180 /* SyntaxKind.SetAccessor */)
151
170
  markPrivateIdentifierScope(c, member);
152
171
  switch (member.kind) {
153
- case 173 /* SyntaxKind.PropertyDeclaration */:
172
+ case 174 /* SyntaxKind.PropertyDeclaration */:
154
173
  checkVariableLikeDeclaration(c, member);
155
174
  if (hasSyntacticModifier(member, 64 /* ModifierFlags.Abstract */) && getInitializer(member) !== undefined)
156
175
  c.error(member, 216 /* Diagnostics.Property_0_cannot_have_an_initializer_because_it_is_marked_abstract */, declarationNameToString(getSourceFileOfNode(member), getName(member)));
157
176
  return;
158
- case 175 /* SyntaxKind.MethodDeclaration */:
159
- case 177 /* SyntaxKind.Constructor */:
160
- case 178 /* SyntaxKind.GetAccessor */:
161
- case 179 /* SyntaxKind.SetAccessor */: {
177
+ case 176 /* SyntaxKind.MethodDeclaration */:
178
+ case 178 /* SyntaxKind.Constructor */:
179
+ case 179 /* SyntaxKind.GetAccessor */:
180
+ case 180 /* SyntaxKind.SetAccessor */: {
162
181
  checkDecorators(c, member);
163
182
  const name = getName(member);
164
- if (name !== undefined && name.kind === 168 /* SyntaxKind.ComputedPropertyName */)
183
+ if (name !== undefined && name.kind === 169 /* SyntaxKind.ComputedPropertyName */)
165
184
  checkComputedPropertyName(c, name);
166
185
  const symbol = getSymbolOfDeclaration(c, member);
167
- if (symbol !== undefined && member.kind !== 177 /* SyntaxKind.Constructor */)
186
+ if (symbol !== undefined && member.kind !== 178 /* SyntaxKind.Constructor */)
168
187
  getTypeOfSymbol(c, symbol);
169
188
  checkFunctionLikeBody(c, member);
170
- if (member.kind === 175 /* SyntaxKind.MethodDeclaration */) {
189
+ if (member.kind === 176 /* SyntaxKind.MethodDeclaration */) {
190
+ checkJSDocFullSignatureType(c, member);
171
191
  checkJSDocFullSignature(c, member);
172
192
  checkFunctionOrMethodSymbols(c, member);
173
193
  if (hasSyntacticModifier(member, 64 /* ModifierFlags.Abstract */) && getBody(member) !== undefined)
174
194
  c.error(member, 195 /* Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract */, declarationNameToString(getSourceFileOfNode(member), name));
175
195
  }
176
- else if (member.kind === 177 /* SyntaxKind.Constructor */) {
196
+ else if (member.kind === 178 /* SyntaxKind.Constructor */) {
177
197
  if (symbol !== undefined)
178
198
  checkFunctionOrConstructorSymbol(c, symbol);
179
199
  checkConstructorSuperCall(c, member);
@@ -182,10 +202,10 @@ function checkClassMember(c, member) {
182
202
  checkAccessorDeclaration(c, member);
183
203
  return;
184
204
  }
185
- case 182 /* SyntaxKind.IndexSignature */:
205
+ case 183 /* SyntaxKind.IndexSignature */:
186
206
  checkSignatureDeclarationTypes(c, member);
187
207
  return;
188
- case 176 /* SyntaxKind.ClassStaticBlockDeclaration */: {
208
+ case 177 /* SyntaxKind.ClassStaticBlockDeclaration */: {
189
209
  const body = getBody(member);
190
210
  if (body !== undefined)
191
211
  for (const s of getStatements(body).nodes)
@@ -199,20 +219,20 @@ export function checkAccessorDeclaration(c, node) {
199
219
  const name = getName(node);
200
220
  if (name.kind === 79 /* SyntaxKind.Identifier */ && getText(name) === 'constructor' && isClassLike(node.parent))
201
221
  c.error(name, 276 /* Diagnostics.Class_constructor_may_not_be_an_accessor */);
202
- if (node.kind === 178 /* SyntaxKind.GetAccessor */ &&
222
+ if (node.kind === 179 /* SyntaxKind.GetAccessor */ &&
203
223
  (node.flags & 8388608 /* NodeFlags.Ambient */) === 0 &&
204
224
  nodeIsPresent(getBody(node)) &&
205
225
  (node.flags & 256 /* NodeFlags.HasImplicitReturn */) !== 0 &&
206
226
  (node.flags & 512 /* NodeFlags.HasExplicitReturn */) === 0)
207
- c.error(name, 552 /* Diagnostics.A_get_accessor_must_return_a_value */);
227
+ c.error(name, 559 /* Diagnostics.A_get_accessor_must_return_a_value */);
208
228
  if (hasDynamicName(node) && !hasLateBindableName(c, node))
209
229
  return;
210
230
  // Accessors of one member must agree on accessibility and abstractness; checked once, at the getter.
211
231
  const symbol = getSymbolOfDeclaration(c, node);
212
232
  if (symbol === undefined)
213
233
  return;
214
- const getter = getDeclarationOfKind(symbol, 178 /* SyntaxKind.GetAccessor */);
215
- const setter = getDeclarationOfKind(symbol, 179 /* SyntaxKind.SetAccessor */);
234
+ const getter = getDeclarationOfKind(symbol, 179 /* SyntaxKind.GetAccessor */);
235
+ const setter = getDeclarationOfKind(symbol, 180 /* SyntaxKind.SetAccessor */);
216
236
  if (getter === undefined || setter === undefined)
217
237
  return;
218
238
  const links = c.nodeLinks(getter);
@@ -222,14 +242,14 @@ export function checkAccessorDeclaration(c, node) {
222
242
  const getterFlags = getModifierFlags(getter);
223
243
  const setterFlags = getModifierFlags(setter);
224
244
  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 */);
245
+ c.error(getName(getter), 817 /* Diagnostics.Accessors_must_both_be_abstract_or_non_abstract */);
246
+ c.error(getName(setter), 817 /* Diagnostics.Accessors_must_both_be_abstract_or_non_abstract */);
227
247
  }
228
248
  if (((getterFlags & 4 /* ModifierFlags.Protected */) !== 0 &&
229
249
  (setterFlags & (4 /* ModifierFlags.Protected */ | 2 /* ModifierFlags.Private */)) === 0) ||
230
250
  ((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 */);
251
+ c.error(getName(getter), 946 /* Diagnostics.A_get_accessor_must_be_at_least_as_accessible_as_the_setter */);
252
+ c.error(getName(setter), 946 /* Diagnostics.A_get_accessor_must_be_at_least_as_accessible_as_the_setter */);
233
253
  }
234
254
  }
235
255
  /** Derived class constructors must call `super`, at the root when properties are initialized. */
@@ -250,11 +270,11 @@ function checkConstructorSuperCall(c, node) {
250
270
  const superCall = finder.superCall;
251
271
  if (superCall === undefined) {
252
272
  if (!classExtendsNull)
253
- c.error(node, 551 /* Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call */);
273
+ c.error(node, 558 /* Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call */);
254
274
  return;
255
275
  }
256
276
  if (classExtendsNull)
257
- c.error(superCall, 1808 /* Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null */);
277
+ c.error(superCall, 1828 /* Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null */);
258
278
  const emitStandardClassFields = getUseDefineForClassFields(c.compilerOptions) && getEmitScriptTarget(c.compilerOptions) >= ScriptTarget.ES2022;
259
279
  if (emitStandardClassFields)
260
280
  return;
@@ -262,31 +282,31 @@ function checkConstructorSuperCall(c, node) {
262
282
  if (!needsRootLevelSuperCall(classDecl, node))
263
283
  return;
264
284
  let parent = superCall.parent;
265
- while (parent.kind === 218 /* SyntaxKind.ParenthesizedExpression */)
285
+ while (parent.kind === 219 /* SyntaxKind.ParenthesizedExpression */)
266
286
  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 */);
287
+ if (parent.kind !== 246 /* SyntaxKind.ExpressionStatement */ || parent.parent !== body) {
288
+ 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
289
  return;
270
290
  }
271
291
  for (const statement of getStatements(body).nodes) {
272
- if (statement.kind === 245 /* SyntaxKind.ExpressionStatement */ &&
292
+ if (statement.kind === 246 /* SyntaxKind.ExpressionStatement */ &&
273
293
  isSuperCall(skipOuterExpressions(getExpression(statement))))
274
294
  return;
275
295
  if (nodeImmediatelyReferencesSuperOrThis(statement))
276
296
  break;
277
297
  }
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 */);
298
+ 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
299
  }
280
300
  function isSuperCall(node) {
281
- return node.kind === 214 /* SyntaxKind.CallExpression */ && getExpression(node).kind === 107 /* SyntaxKind.SuperKeyword */;
301
+ return node.kind === 215 /* SyntaxKind.CallExpression */ && getExpression(node).kind === 107 /* SyntaxKind.SuperKeyword */;
282
302
  }
283
303
  function skipOuterExpressions(node) {
284
304
  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 */)
305
+ while (n.kind === 219 /* SyntaxKind.ParenthesizedExpression */ ||
306
+ n.kind === 236 /* SyntaxKind.AsExpression */ ||
307
+ n.kind === 240 /* SyntaxKind.SatisfiesExpression */ ||
308
+ n.kind === 218 /* SyntaxKind.TypeAssertionExpression */ ||
309
+ n.kind === 237 /* SyntaxKind.NonNullExpression */)
290
310
  n = getExpression(n);
291
311
  return n;
292
312
  }
@@ -301,7 +321,7 @@ function needsRootLevelSuperCall(classDecl, constructor) {
301
321
  }
302
322
  function isInstancePropertyWithInitializerOrPrivateIdentifierProperty(n) {
303
323
  return (isPrivateIdentifierClassElementDeclaration(n) ||
304
- (n.kind === 173 /* SyntaxKind.PropertyDeclaration */ && !isStatic(n) && getInitializer(n) !== undefined));
324
+ (n.kind === 174 /* SyntaxKind.PropertyDeclaration */ && !isStatic(n) && getInitializer(n) !== undefined));
305
325
  }
306
326
  /** Finds the first `super(...)` call outside nested functions. */
307
327
  class SuperCallFinder extends NodeVisitor {
@@ -323,17 +343,17 @@ class SuperOrThisReferenceFinder extends NodeVisitor {
323
343
  case 107 /* SyntaxKind.SuperKeyword */:
324
344
  case 109 /* SyntaxKind.ThisKeyword */:
325
345
  return true;
326
- case 220 /* SyntaxKind.ArrowFunction */:
327
- case 263 /* SyntaxKind.FunctionDeclaration */:
328
- case 219 /* SyntaxKind.FunctionExpression */:
329
- case 173 /* SyntaxKind.PropertyDeclaration */:
346
+ case 221 /* SyntaxKind.ArrowFunction */:
347
+ case 264 /* SyntaxKind.FunctionDeclaration */:
348
+ case 220 /* SyntaxKind.FunctionExpression */:
349
+ case 174 /* SyntaxKind.PropertyDeclaration */:
330
350
  return false;
331
- case 242 /* SyntaxKind.Block */:
351
+ case 243 /* SyntaxKind.Block */:
332
352
  switch (node.parent.kind) {
333
- case 177 /* SyntaxKind.Constructor */:
334
- case 175 /* SyntaxKind.MethodDeclaration */:
335
- case 178 /* SyntaxKind.GetAccessor */:
336
- case 179 /* SyntaxKind.SetAccessor */:
353
+ case 178 /* SyntaxKind.Constructor */:
354
+ case 176 /* SyntaxKind.MethodDeclaration */:
355
+ case 179 /* SyntaxKind.GetAccessor */:
356
+ case 180 /* SyntaxKind.SetAccessor */:
337
357
  return false;
338
358
  }
339
359
  }
@@ -352,7 +372,7 @@ function checkPropertyInitialization(c, node) {
352
372
  return;
353
373
  const constructor = findConstructorDeclaration(node);
354
374
  for (const member of getMembers(node).nodes) {
355
- if (member.kind !== 173 /* SyntaxKind.PropertyDeclaration */)
375
+ if (member.kind !== 174 /* SyntaxKind.PropertyDeclaration */)
356
376
  continue;
357
377
  if (hasSyntacticModifier(member, 128 /* ModifierFlags.Ambient */) ||
358
378
  hasSyntacticModifier(member, 64 /* ModifierFlags.Abstract */) ||
@@ -364,7 +384,7 @@ function checkPropertyInitialization(c, node) {
364
384
  const propName = prop.name;
365
385
  if (propName.kind !== 79 /* SyntaxKind.Identifier */ &&
366
386
  propName.kind !== 80 /* SyntaxKind.PrivateIdentifier */ &&
367
- propName.kind !== 168 /* SyntaxKind.ComputedPropertyName */)
387
+ propName.kind !== 169 /* SyntaxKind.ComputedPropertyName */)
368
388
  continue;
369
389
  const symbol = getSymbolOfDeclaration(c, member);
370
390
  if (symbol === undefined)
@@ -374,7 +394,7 @@ function checkPropertyInitialization(c, node) {
374
394
  continue;
375
395
  if (constructor !== undefined && isPropertyInitializedInConstructor(c, propName, t, constructor))
376
396
  continue;
377
- c.error(propName, 718 /* Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor */, declarationNameToString(getSourceFileOfNode(propName), propName));
397
+ c.error(propName, 725 /* Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor */, declarationNameToString(getSourceFileOfNode(propName), propName));
378
398
  }
379
399
  }
380
400
  /** Whether `this.name` is definitely assigned at the end of the constructor, by control flow. */
@@ -382,7 +402,7 @@ export function isPropertyInitializedInConstructor(c, propName, propType, constr
382
402
  const thisExpression = new KeywordExpression(109 /* SyntaxKind.ThisKeyword */);
383
403
  const returnFlowNode = constructor.returnFlowNode;
384
404
  let reference;
385
- if (propName.kind === 168 /* SyntaxKind.ComputedPropertyName */) {
405
+ if (propName.kind === 169 /* SyntaxKind.ComputedPropertyName */) {
386
406
  const access = new ElementAccessExpression(thisExpression, undefined, getExpression(propName), 0 /* NodeFlags.None */);
387
407
  access.flowNode = returnFlowNode;
388
408
  reference = access;
@@ -419,7 +439,7 @@ export function getFlowTypeInConstructor(c, symbol, constructor) {
419
439
  const reference = newThisPropertyReference(symbol, constructor, constructor.returnFlowNode);
420
440
  const flowType = getFlowTypeOfProperty(c, reference, symbol);
421
441
  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));
442
+ c.error(symbol.valueDeclaration, 1699 /* Diagnostics.Member_0_implicitly_has_an_1_type */, symbolToString(c, symbol), typeToString(c, flowType));
423
443
  // Assignments of only null or undefined infer nothing.
424
444
  if (everyType(flowType, (t) => hasTypeFacts(c, t, 50331648 /* TypeFacts.IsUndefinedOrNull */)))
425
445
  return undefined;
@@ -431,7 +451,7 @@ export function getFlowTypeInStaticBlocks(c, symbol, staticBlocks) {
431
451
  const reference = newThisPropertyReference(symbol, staticBlock, staticBlock.returnFlowNode);
432
452
  const flowType = getFlowTypeOfProperty(c, reference, symbol);
433
453
  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));
454
+ c.error(symbol.valueDeclaration, 1699 /* Diagnostics.Member_0_implicitly_has_an_1_type */, symbolToString(c, symbol), typeToString(c, flowType));
435
455
  if (everyType(flowType, (t) => hasTypeFacts(c, t, 50331648 /* TypeFacts.IsUndefinedOrNull */)))
436
456
  continue;
437
457
  return convertAutoToAny(c, flowType);
@@ -445,7 +465,7 @@ function newThisPropertyReference(symbol, container, flowNode) {
445
465
  if (name.startsWith('\ufffe#'))
446
466
  accessName = new PrivateIdentifier(name.substring(name.indexOf('@') + 1));
447
467
  else
448
- accessName = new Identifier(name);
468
+ accessName = new Identifier(new IdentifierName(name));
449
469
  const thisExpression = new KeywordExpression(109 /* SyntaxKind.ThisKeyword */);
450
470
  const reference = new PropertyAccessExpression(thisExpression, undefined, accessName, 0 /* NodeFlags.None */);
451
471
  thisExpression.parent = reference;
@@ -470,7 +490,7 @@ export function getFlowTypeOfProperty(c, reference, prop) {
470
490
  export function isAutoTypedProperty(c, symbol) {
471
491
  const declaration = symbol.valueDeclaration;
472
492
  return (declaration !== undefined &&
473
- declaration.kind === 173 /* SyntaxKind.PropertyDeclaration */ &&
493
+ declaration.kind === 174 /* SyntaxKind.PropertyDeclaration */ &&
474
494
  getType(declaration) === undefined &&
475
495
  getInitializer(declaration) === undefined &&
476
496
  c.noImplicitAny);
@@ -487,32 +507,57 @@ function containsUndefinedType(t) {
487
507
  const first = (t.flags & 134217728 /* TypeFlags.Union */) !== 0 ? typesOf(t)[0] : t;
488
508
  return (first.flags & 4 /* TypeFlags.Undefined */) !== 0;
489
509
  }
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;
510
+ /** A constructor that `node` may not call: the modifiers that forbid it, and the class that declares it. */
511
+ export class ConstructorAccessibilityError {
512
+ kind;
513
+ declaringClass;
514
+ constructor(kind, declaringClass) {
515
+ this.kind = kind;
516
+ this.declaringClass = declaringClass;
517
+ }
518
+ }
519
+ /**
520
+ * The first of `signatures` whose constructor `node` may not call because of the modifiers in `modifiersMask`:
521
+ * private and protected constructors are only callable within their class, or subclasses if protected.
522
+ */
523
+ export function getConstructorAccessibilityError(c, node, signatures, modifiersMask) {
524
+ for (const signature of signatures) {
525
+ const declaration = signature.declaration;
526
+ if (declaration === undefined)
527
+ continue;
528
+ const modifiers = getModifierFlags(declaration) & modifiersMask;
529
+ // Public constructors and constructor functions are always accessible.
530
+ if (modifiers === 0 || declaration.kind !== 178 /* SyntaxKind.Constructor */)
531
+ continue;
532
+ const classSymbol = getSymbol(declaration.parent);
533
+ const declaringClassDeclaration = getClassLikeDeclarationOfSymbol(classSymbol);
534
+ let withinClass = false;
535
+ for (let container = getContainingClass(node); container !== undefined; container = getContainingClass(container))
536
+ if (container === declaringClassDeclaration) {
537
+ withinClass = true;
538
+ break;
539
+ }
540
+ if (withinClass)
541
+ continue;
542
+ const containingClass = getContainingClass(node);
543
+ if (containingClass !== undefined && (modifiers & 4 /* ModifierFlags.Protected */) !== 0) {
544
+ const containingType = getTypeOfNode(c, containingClass);
545
+ if (typeHasProtectedAccessibleBase(c, classSymbol, containingType))
546
+ continue;
547
+ }
548
+ return new ConstructorAccessibilityError(modifiers, getDeclaredTypeOfSymbol(c, classSymbol));
511
549
  }
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));
550
+ return undefined;
551
+ }
552
+ /** Whether `new` at `node` may call the constructors of `signatures`, reporting private and protected ones out of reach. */
553
+ export function isConstructorAccessible(c, node, signatures) {
554
+ const error = getConstructorAccessibilityError(c, node, signatures, 6 /* ModifierFlags.NonPublicAccessibilityModifier */);
555
+ if (error === undefined)
556
+ return true;
557
+ if ((error.kind & 2 /* ModifierFlags.Private */) !== 0)
558
+ c.error(node, 814 /* Diagnostics.Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration */, typeToString(c, error.declaringClass));
559
+ if ((error.kind & 4 /* ModifierFlags.Protected */) !== 0)
560
+ c.error(node, 815 /* Diagnostics.Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration */, typeToString(c, error.declaringClass));
516
561
  return false;
517
562
  }
518
563
  /** Whether `target` is a base class of `t`, through bases that aren't mixins. */
@@ -560,7 +605,7 @@ function findMixins(c, types) {
560
605
  export function checkInterfaceDeclaration(c, node) {
561
606
  const decl = node;
562
607
  checkTypeParameters(c, decl.typeParameters);
563
- checkTypeNameIsReserved(c, decl.name, 596 /* Diagnostics.Interface_name_cannot_be_0 */);
608
+ checkTypeNameIsReserved(c, decl.name, 603 /* Diagnostics.Interface_name_cannot_be_0 */);
564
609
  checkExportsOnMergedDeclarations(c, node);
565
610
  const symbol = getSymbolOfDeclaration(c, node);
566
611
  if (symbol !== undefined) {
@@ -573,7 +618,7 @@ export function checkInterfaceDeclaration(c, node) {
573
618
  checkHeritageClauses(c, decl.heritageClauses.nodes, false);
574
619
  for (const member of decl.members.nodes) {
575
620
  checkJSDocLinksOfNode(c, member);
576
- if (member.kind === 172 /* SyntaxKind.PropertySignature */)
621
+ if (member.kind === 173 /* SyntaxKind.PropertySignature */)
577
622
  checkVariableLikeDeclaration(c, member);
578
623
  else
579
624
  checkTypeNodeIfPresent(c, member);
@@ -18,6 +18,26 @@ export declare function pushCachedContextualType(c: Checker, node: Node): void;
18
18
  export declare function popContextualType(c: Checker): void;
19
19
  /** The index of the contextual type pushed onto `node`, or -1. */
20
20
  export declare function findContextualNode(c: Checker, node: Node, includeCaches: boolean): number;
21
+ /**
22
+ * The id of the contextual type in force for `node`, or -1 if the node's contextual type is not on
23
+ * the stack. A key built from -1 can't tell a check under a contextual type that was not pushed from
24
+ * a check with no contextual type, so callers record nothing under -1.
25
+ */
26
+ export declare function getContextualTypeId(c: Checker, node: Node): number;
27
+ /**
28
+ * Whether a check of `node` has no contextual type and no inference context, so its type is a
29
+ * function of the node and the check mode alone: the node is not on the contextual stack, no
30
+ * inference context contains it, and its parent gives it no contextual type. The parents answered
31
+ * here are the ones `getContextualTypeEx` returns `undefined` for without computing anything; a
32
+ * parent it computes a type for is not answered, so the result is never "yes" for a check that
33
+ * could have a contextual type.
34
+ *
35
+ * Types computed inside a flow loop are provisional (the checker does not cache them either), so a
36
+ * check in a loop is not context-free. The same holds while a reduce label is in force, as when
37
+ * flow analysis revisits a `finally` block with the antecedents of one outgoing path: the flow
38
+ * state differs from the one the earlier check of the block saw.
39
+ */
40
+ export declare function isCheckedWithoutContextualType(c: Checker, node: Node): boolean;
21
41
  export declare function pushInferenceContext(c: Checker, node: Node, context: InferenceContext | undefined): void;
22
42
  export declare function popInferenceContext(c: Checker): void;
23
43
  /** The inference context of the innermost call argument containing `node`. */