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
@@ -44,7 +44,6 @@ import {
44
44
  GetAccessorDeclaration,
45
45
  HeritageClause,
46
46
  Identifier,
47
- ImportAttributes,
48
47
  ImportClause,
49
48
  ImportDeclaration,
50
49
  ImportEqualsDeclaration,
@@ -102,6 +101,7 @@ import {
102
101
  isDeclarationNode,
103
102
  } from '../ast.js';
104
103
  import {
104
+ getHeritageClauseElementName,
105
105
  isAmbientModule,
106
106
  isAnyImportOrReExport,
107
107
  isFunctionLike,
@@ -183,6 +183,8 @@ export class DeclarationTransformer extends Transformer {
183
183
  private readonly expandoHosts: Map<Node, Node | undefined>;
184
184
  /** The namespace members for the assigned properties of each function, by statement. */
185
185
  private readonly expandoMembers: Map<Node, Node[]>;
186
+ /** Assigned properties of hosts that weren't visible when found, by host; written if the host becomes visible. */
187
+ private readonly deferredExpandoAssignments: Map<Node, BinaryExpression[]>;
186
188
  /** The `export =` for a CommonJS `module.exports = …`. */
187
189
  private cjsExportAssignment: Node | undefined;
188
190
  /** The exports for CommonJS `exports.x = …` assignments. */
@@ -221,6 +223,7 @@ export class DeclarationTransformer extends Transformer {
221
223
  this.lateStatementReplacements = new Map<Node, Node | undefined>();
222
224
  this.expandoHosts = new Map<Node, Node | undefined>();
223
225
  this.expandoMembers = new Map<Node, Node[]>();
226
+ this.deferredExpandoAssignments = new Map<Node, BinaryExpression[]>();
224
227
  this.cjsExportAssignment = undefined;
225
228
  this.cjsExportMembers = [];
226
229
  this.cjsExportAssignmentName = undefined;
@@ -293,6 +296,7 @@ export class DeclarationTransformer extends Transformer {
293
296
  this.lateStatementReplacements = new Map<Node, Node | undefined>();
294
297
  this.expandoHosts.clear();
295
298
  this.expandoMembers.clear();
299
+ this.deferredExpandoAssignments.clear();
296
300
  this.witnessedCjsExports.clear();
297
301
  this.cjsExportAssignment = undefined;
298
302
  this.cjsExportAssignmentName = undefined;
@@ -672,6 +676,19 @@ export class DeclarationTransformer extends Transformer {
672
676
  case SyntaxKind.TypeQuery:
673
677
  this.checkEntityNameVisibility((input as TypeQueryNode).exprName, this.enclosingDeclaration);
674
678
  return this.visitEachChild(input);
679
+ case SyntaxKind.QualifiedName: {
680
+ // `typeof this.#x`: the private member isn't in the declaration output.
681
+ const right = (input as QualifiedName).right;
682
+ if (right.kind === SyntaxKind.PrivateIdentifier)
683
+ this.tracker.addDiagnostic(
684
+ createDiagnosticForNode(
685
+ input,
686
+ Diagnostics.Declaration_emit_elides_private_members_but_0_refers_to_a_private_member_Write_an_explicit_type_here,
687
+ [getText(right)],
688
+ ),
689
+ );
690
+ return this.visitEachChild(input);
691
+ }
675
692
  case SyntaxKind.TupleType: {
676
693
  const result = this.visitEachChild(input);
677
694
  if (isOriginalNodeSingleLine(this.context, input)) this.context.addEmitFlags(result, EmitFlags.SingleLine);
@@ -774,10 +791,13 @@ export class DeclarationTransformer extends Transformer {
774
791
  const types = clause.types.nodes;
775
792
  const retained: Node[] = [];
776
793
  for (const type of types) {
777
- const expression = (type as ExpressionWithTypeArguments).expression;
794
+ const name = getHeritageClauseElementName(type);
778
795
  if (
779
- isEntityNameExpression(expression, false) ||
780
- (clause.token === SyntaxKind.ExtendsKeyword && expression.kind === SyntaxKind.NullKeyword)
796
+ name.kind === SyntaxKind.QualifiedName ||
797
+ isEntityNameExpression(name, false) ||
798
+ (clause.token === SyntaxKind.ExtendsKeyword &&
799
+ type.kind === SyntaxKind.ExpressionWithTypeArguments &&
800
+ name.kind === SyntaxKind.NullKeyword)
781
801
  )
782
802
  retained.push(type);
783
803
  }
@@ -861,12 +881,14 @@ export class DeclarationTransformer extends Transformer {
861
881
  isVariableDeclarationInitializedToRequire(input)
862
882
  )
863
883
  return this.transformCjsRequireVariableDeclaration(input);
864
- if (input.name instanceof BindingPattern) return this.recreateBindingPattern(input.name);
884
+ // A binding pattern with initializers becomes a declaration per name; without them it stays.
885
+ if (input.name instanceof BindingPattern && hasAnyBindingInitializers(input.name))
886
+ return this.recreateBindingPattern(input.name);
865
887
  // Variable types don't enter new diagnostic contexts.
866
888
  this.suppressNewDiagnosticContexts = true;
867
889
  return this.factory.updateVariableDeclaration(
868
890
  input,
869
- input.name,
891
+ this.visitBindingName(input.name),
870
892
  undefined,
871
893
  this.ensureType(input, false),
872
894
  this.ensureNoInitializer(input),
@@ -1038,9 +1060,16 @@ export class DeclarationTransformer extends Transformer {
1038
1060
  private omitPrivateMethodType(input: Node): Node | undefined {
1039
1061
  const symbol = getSymbol(input);
1040
1062
  if (symbol !== undefined && declarationCount(symbol) > 0 && symbol.declaration !== input) return undefined;
1041
- const result = this.factory.created(
1042
- new PropertyDeclaration(this.ensureModifiers(input), getName(input)!, undefined, undefined, undefined),
1043
- );
1063
+ // A method signature becomes a property signature, a method a property declaration.
1064
+ let result: Node;
1065
+ if (input.kind === SyntaxKind.MethodSignature)
1066
+ result = this.factory.created(
1067
+ new PropertySignatureDeclaration(this.ensureModifiers(input), getName(input)!, undefined, undefined, undefined),
1068
+ );
1069
+ else
1070
+ result = this.factory.created(
1071
+ new PropertyDeclaration(this.ensureModifiers(input), getName(input)!, undefined, undefined, undefined),
1072
+ );
1044
1073
  this.context.assignCommentRange(result, input);
1045
1074
  return result;
1046
1075
  }
@@ -1091,7 +1120,7 @@ export class DeclarationTransformer extends Transformer {
1091
1120
  input.isTypeOnly,
1092
1121
  input.exportClause,
1093
1122
  this.rewriteModuleSpecifier(input, input.moduleSpecifier),
1094
- this.tryGetResolutionModeOverride(input.attributes),
1123
+ input.attributes,
1095
1124
  );
1096
1125
  }
1097
1126
  if (input instanceof ExportAssignment)
@@ -1119,9 +1148,14 @@ export class DeclarationTransformer extends Transformer {
1119
1148
  (input.parent.kind === SyntaxKind.SourceFile || input.parent.kind === SyntaxKind.ModuleBlock)
1120
1149
  ) {
1121
1150
  const result = this.factory.created(new ExportAssignment(undefined, isExportEquals, undefined, expression));
1151
+ this.context.assignSourceMapRange(result, input);
1122
1152
  this.context.assignCommentRange(result, input);
1123
1153
  return result;
1124
1154
  }
1155
+ // Types the default export can't name are reported for it, as class and function declarations too.
1156
+ const tracker = this.tracker;
1157
+ tracker.diagnosticContext = new DiagnosticContext(DiagnosticContextKind.DefaultExport, input, undefined);
1158
+ tracker.pushErrorFallbackNode(assignment);
1125
1159
  const unwrapped = skipOuterExpressions(expression);
1126
1160
  const name = this.getNameOfExportedExpression(unwrapped, isExportEquals);
1127
1161
  // Class and function expressions become declarations.
@@ -1129,17 +1163,16 @@ export class DeclarationTransformer extends Transformer {
1129
1163
  const declaration =
1130
1164
  unwrapped instanceof ClassExpression
1131
1165
  ? this.transformClassExpressionToDeclaration(unwrapped, name, this.declareModifiers())
1132
- : this.transformFunctionLikeToDeclaration(unwrapped, name, this.declareModifiers());
1166
+ : this.transformFunctionLikeToDeclaration(unwrapped, name, this.declareModifiers(), getType(assignment));
1167
+ tracker.popErrorFallbackNode();
1133
1168
  this.context.assignCommentRange(declaration, input);
1134
1169
  const exportAssignment = this.factory.created(new ExportAssignment(undefined, isExportEquals, undefined, name));
1170
+ this.context.assignSourceMapRange(exportAssignment, input);
1135
1171
  this.context.addEmitFlags(exportAssignment, EmitFlags.NoComments);
1136
1172
  return this.factory.createSyntaxList([exportAssignment, declaration]);
1137
1173
  }
1138
1174
  // Other expressions are written as a `_default` variable with the expression's type.
1139
- const tracker = this.tracker;
1140
- tracker.diagnosticContext = new DiagnosticContext(DiagnosticContextKind.DefaultExport, input, undefined);
1141
1175
  this.cjsExportAssignmentName = name;
1142
- tracker.pushErrorFallbackNode(assignment);
1143
1176
  let initializer: Node | undefined = undefined;
1144
1177
  if (isPrimitiveLiteralValue(skipParenthesesOnly(expression), true))
1145
1178
  initializer = this.resolver.createLiteralConstValue(this.context, this.parseNode(assignment), tracker);
@@ -1148,6 +1181,7 @@ export class DeclarationTransformer extends Transformer {
1148
1181
  tracker.popErrorFallbackNode();
1149
1182
  const statement = this.createConstStatement(declaration);
1150
1183
  const exportAssignment = this.factory.created(new ExportAssignment(undefined, isExportEquals, undefined, name));
1184
+ this.context.assignSourceMapRange(exportAssignment, input);
1151
1185
  this.context.assignCommentRange(statement, input);
1152
1186
  return this.factory.createSyntaxList([statement, exportAssignment]);
1153
1187
  }
@@ -1159,8 +1193,24 @@ export class DeclarationTransformer extends Transformer {
1159
1193
  );
1160
1194
  }
1161
1195
 
1162
- private transformFunctionLikeToDeclaration(fn: Node, name: Identifier, modifiers: ModifierList): Node {
1163
- const fullSignature = getFullSignature(fn);
1196
+ private transformFunctionLikeToDeclaration(
1197
+ fn: Node,
1198
+ name: Identifier,
1199
+ modifiers: ModifierList,
1200
+ fullSignatureType: Node | undefined,
1201
+ ): Node {
1202
+ // A JSDoc signature, of the function or of the assignment, is reused as the type of a `const`.
1203
+ const fullSignature = getFullSignature(fn) ?? fullSignatureType;
1204
+ if (fullSignature !== undefined)
1205
+ return this.factory.createVariableStatement(
1206
+ modifiers,
1207
+ this.factory.createVariableDeclarationList(
1208
+ this.factory.createNodeList([
1209
+ this.factory.createVariableDeclaration(name, undefined, this.visitNode(fullSignature), undefined),
1210
+ ]),
1211
+ NodeFlags.Const,
1212
+ ),
1213
+ );
1164
1214
  return this.factory.created(
1165
1215
  new FunctionDeclaration(
1166
1216
  modifiers,
@@ -1169,7 +1219,7 @@ export class DeclarationTransformer extends Transformer {
1169
1219
  this.ensureTypeParams(fn, getTypeParameters(fn)),
1170
1220
  this.updateParamList(fn, getParameters(fn)!),
1171
1221
  this.ensureType(fn, false),
1172
- fullSignature === undefined ? undefined : this.visitNode(fullSignature),
1222
+ undefined,
1173
1223
  undefined,
1174
1224
  ),
1175
1225
  );
@@ -1236,11 +1286,6 @@ export class DeclarationTransformer extends Transformer {
1236
1286
  return input;
1237
1287
  }
1238
1288
 
1239
- private tryGetResolutionModeOverride(node: ImportAttributes | undefined): ImportAttributes | undefined {
1240
- if (node === undefined) return undefined;
1241
- return this.resolver.getResolutionModeOverride(node) !== undefined ? node : undefined;
1242
- }
1243
-
1244
1289
  /** The replacement statements for a direct child of a source file or module block. */
1245
1290
  private transformTopLevelDeclaration(input: Node): Node | undefined {
1246
1291
  if (input === undefined) return undefined;
@@ -1280,7 +1325,8 @@ export class DeclarationTransformer extends Transformer {
1280
1325
  if (isDeclaration(input) && this.isDeclarationAndNotVisible(input)) return undefined;
1281
1326
  if (isFunctionLike(input) && this.resolver.isImplementationOfOverload(input)) return undefined;
1282
1327
  const original = this.context.mostOriginal(input);
1283
- if (this.expandoHosts.has(original)) return this.createFullExpandoBlock(original);
1328
+ if (this.expandoHosts.has(original) || this.deferredExpandoAssignments.has(original))
1329
+ return this.createFullExpandoBlock(original);
1284
1330
  const previousEnclosingDeclaration = this.enclosingDeclaration;
1285
1331
  if (isEnclosingDeclaration(input)) this.enclosingDeclaration = input;
1286
1332
  const oldContext = tracker.diagnosticContext;
@@ -1349,7 +1395,8 @@ export class DeclarationTransformer extends Transformer {
1349
1395
  this.ensureModifiers(input),
1350
1396
  input.name,
1351
1397
  this.visitNodes(input.typeParameters),
1352
- this.visitNode(input.type)!,
1398
+ // stripInternal can elide an `@internal` type on the right; it falls back to `any`, as index signatures do.
1399
+ this.visitNode(input.type) ?? this.keyword(SyntaxKind.AnyKeyword),
1353
1400
  );
1354
1401
  }
1355
1402
 
@@ -1384,6 +1431,7 @@ export class DeclarationTransformer extends Transformer {
1384
1431
  const saveNeedsDeclare = this.needsDeclare;
1385
1432
  this.needsDeclare = false;
1386
1433
  const body = input.body;
1434
+ const attributes = this.visitNode(input.attributes) as TypeLiteralNode | undefined;
1387
1435
  let keyword = input.keyword;
1388
1436
  if (keyword !== SyntaxKind.GlobalKeyword && !(input.name instanceof StringLiteral))
1389
1437
  keyword = SyntaxKind.NamespaceKeyword;
@@ -1409,7 +1457,7 @@ export class DeclarationTransformer extends Transformer {
1409
1457
  this.needsDeclare = saveNeedsDeclare;
1410
1458
  this.needsScopeFixMarker = oldNeedsScopeFix;
1411
1459
  this.resultHasScopeMarker = oldHasScopeFix;
1412
- return this.factory.updateModuleDeclaration(input, modifiers, keyword, input.name, updatedBody);
1460
+ return this.factory.updateModuleDeclaration(input, modifiers, keyword, input.name, attributes, updatedBody);
1413
1461
  }
1414
1462
  if (body !== undefined) {
1415
1463
  // A nested `namespace a.b` is transformed now: it needs no visibility painting.
@@ -1418,10 +1466,10 @@ export class DeclarationTransformer extends Transformer {
1418
1466
  const inner = this.lateStatementReplacements.get(original);
1419
1467
  this.lateStatementReplacements.delete(original);
1420
1468
  this.needsDeclare = saveNeedsDeclare;
1421
- return this.factory.updateModuleDeclaration(input, modifiers, keyword, input.name, inner);
1469
+ return this.factory.updateModuleDeclaration(input, modifiers, keyword, input.name, attributes, inner);
1422
1470
  }
1423
1471
  this.needsDeclare = saveNeedsDeclare;
1424
- return this.factory.updateModuleDeclaration(input, modifiers, keyword, input.name, undefined);
1472
+ return this.factory.updateModuleDeclaration(input, modifiers, keyword, input.name, attributes, undefined);
1425
1473
  }
1426
1474
 
1427
1475
  private stripExportModifiersOfList(list: NodeList): NodeList {
@@ -1489,7 +1537,7 @@ export class DeclarationTransformer extends Transformer {
1489
1537
  return factory.updateTypeAliasDeclaration(node, modifiers, node.name, node.typeParameters, node.type);
1490
1538
  if (node instanceof EnumDeclaration) return factory.updateEnumDeclaration(node, modifiers, node.name, node.members);
1491
1539
  if (node instanceof ModuleDeclaration)
1492
- return factory.updateModuleDeclaration(node, modifiers, node.keyword, node.name, node.body);
1540
+ return factory.updateModuleDeclaration(node, modifiers, node.keyword, node.name, node.attributes, node.body);
1493
1541
  if (node instanceof ImportDeclaration)
1494
1542
  return factory.updateImportDeclaration(node, modifiers, node.importClause, node.moduleSpecifier, node.attributes);
1495
1543
  if (node instanceof ExportDeclaration)
@@ -2004,6 +2052,7 @@ export class DeclarationTransformer extends Transformer {
2004
2052
  this.declareModifiers(),
2005
2053
  SyntaxKind.NamespaceKeyword,
2006
2054
  namespaceName,
2055
+ undefined,
2007
2056
  factory.created(new ModuleBlock(factory.createNodeList([classDeclaration]))),
2008
2057
  ),
2009
2058
  );
@@ -2084,6 +2133,7 @@ export class DeclarationTransformer extends Transformer {
2084
2133
  this.declareModifiers(),
2085
2134
  SyntaxKind.NamespaceKeyword,
2086
2135
  name,
2136
+ undefined,
2087
2137
  this.factory.created(new ModuleBlock(this.factory.createNodeList(stripped))),
2088
2138
  ),
2089
2139
  );
@@ -2119,7 +2169,17 @@ export class DeclarationTransformer extends Transformer {
2119
2169
  const name = this.factory.createIdentifier(namespace.text);
2120
2170
  const property = this.tryGetPropertyName(left);
2121
2171
  if (property === '' || !isIdentifierText(property)) return false;
2122
- if (isDeclaration(declaration) && this.isDeclarationAndNotVisible(declaration)) return false;
2172
+ const hostId = this.getExpandoHostId(declaration);
2173
+ if (isDeclaration(declaration) && this.isDeclarationAndNotVisible(declaration)) {
2174
+ // Writing the type of a visible declaration, such as `typeof f`, can make the host visible later.
2175
+ let deferred = this.deferredExpandoAssignments.get(hostId);
2176
+ if (deferred === undefined) {
2177
+ deferred = [];
2178
+ this.deferredExpandoAssignments.set(hostId, deferred);
2179
+ }
2180
+ deferred.push(node);
2181
+ return false;
2182
+ }
2123
2183
  if (declaration instanceof FunctionDeclaration && !shouldEmitFunctionProperties(declaration)) return false;
2124
2184
  this.transformExpandoHost(name, declaration);
2125
2185
  const exportName = this.factory.createIdentifier(property);
@@ -2133,21 +2193,21 @@ export class DeclarationTransformer extends Transformer {
2133
2193
  localName = exportName;
2134
2194
  if (localName === undefined || isNonContextualKeyword(stringToToken(localName.text)))
2135
2195
  localName = this.factory.createGeneratedNameForNode(node, GeneratedIdentifierFlags.None, '', '');
2136
- const hostId = this.getExpandoHostId(declaration);
2137
2196
  const scope = this.enterDiagnosticContext(node);
2138
2197
  let members = this.expandoMembers.get(hostId);
2139
2198
  if (members === undefined) {
2140
2199
  members = [];
2141
2200
  this.expandoMembers.set(hostId, members);
2142
2201
  }
2202
+ let hasExport = false;
2203
+ for (const member of members) if (member.kind === SyntaxKind.ExportDeclaration) hasExport = true;
2143
2204
  if (node.right instanceof Identifier) {
2144
- // Alias-like: `export { name }` or `export { name as alias }`.
2205
+ // Alias-like: `export { name }` or `export { name as alias }`; the other members stay exported.
2206
+ if (!hasExport) this.addExportModifierToExpandoMembers(members);
2145
2207
  members.push(this.transformBinaryExpressionToExportDeclaration(node, exportName));
2146
2208
  this.exitDiagnosticContext(scope);
2147
2209
  return true;
2148
2210
  }
2149
- let hasExport = false;
2150
- for (const member of members) if (member.kind === SyntaxKind.ExportDeclaration) hasExport = true;
2151
2211
  const variable = this.factory.createVariableStatement(
2152
2212
  hasExport ? this.factory.createModifierList([this.factory.createToken(SyntaxKind.ExportKeyword)]) : undefined,
2153
2213
  this.factory.createVariableDeclarationList(
@@ -2162,17 +2222,21 @@ export class DeclarationTransformer extends Transformer {
2162
2222
  if (local.text !== exportName.text || this.context.hasAutoGenerateInfo(local))
2163
2223
  statements.push(this.createExportDeclaration(local, exportName));
2164
2224
  // Members stay exported after an `export {}` is added.
2165
- if (statements.length > 1 && !hasExport)
2166
- for (let i = 0; i < members.length; i++)
2167
- members[i] = this.replaceModifiers(
2168
- members[i],
2169
- this.createModifiers(ModifierFlags.Export | getCombinedModifierFlags(members[i])),
2170
- );
2225
+ if (statements.length > 1 && !hasExport) this.addExportModifierToExpandoMembers(members);
2171
2226
  for (const statement of statements) members.push(statement);
2172
2227
  this.exitDiagnosticContext(scope);
2173
2228
  return true;
2174
2229
  }
2175
2230
 
2231
+ /** Adds `export` to a host's members, before the first `export {}` is added to them. */
2232
+ private addExportModifierToExpandoMembers(members: Node[]): void {
2233
+ for (let i = 0; i < members.length; i++)
2234
+ members[i] = this.replaceModifiers(
2235
+ members[i],
2236
+ this.createModifiers(ModifierFlags.Export | getCombinedModifierFlags(members[i])),
2237
+ );
2238
+ }
2239
+
2176
2240
  private tryGetPropertyName(node: Node): string {
2177
2241
  if (node instanceof ElementAccessExpression) return this.resolver.getElementAccessExpressionName(node);
2178
2242
  if (node instanceof PropertyAccessExpression && node.name instanceof Identifier) return node.name.text;
@@ -2251,6 +2315,12 @@ export class DeclarationTransformer extends Transformer {
2251
2315
 
2252
2316
  /** A function with its assigned properties as a namespace of the same name. */
2253
2317
  private createFullExpandoBlock(id: Node): Node | undefined {
2318
+ // Assignments deferred while the host wasn't visible; they are deferred again if it still isn't.
2319
+ const deferred = this.deferredExpandoAssignments.get(id);
2320
+ if (deferred !== undefined) {
2321
+ this.deferredExpandoAssignments.delete(id);
2322
+ for (const assignment of deferred) this.transformExpandoAssignment(assignment);
2323
+ }
2254
2324
  const host = this.expandoHosts.get(id);
2255
2325
  const addOns = this.expandoMembers.get(id);
2256
2326
  if (addOns === undefined || host === undefined) return host;
@@ -2274,6 +2344,7 @@ export class DeclarationTransformer extends Transformer {
2274
2344
  modifiers,
2275
2345
  SyntaxKind.NamespaceKeyword,
2276
2346
  name,
2347
+ undefined,
2277
2348
  this.factory.created(new ModuleBlock(this.factory.createNodeList(addOns))),
2278
2349
  ),
2279
2350
  ),
@@ -2314,7 +2385,7 @@ export class DeclarationTransformer extends Transformer {
2314
2385
  return false;
2315
2386
  this.seenProperties.add(key);
2316
2387
  const heritage = getHeritageClauses(classNode);
2317
- if (heritage !== undefined && heritage.nodes.length > 0 && !isClassExtendingNull(heritage)) {
2388
+ if (heritage !== undefined && heritage.nodes.length > 0 && !isClassExtendingNull(classNode)) {
2318
2389
  // A base class may provide the member; that needs types.
2319
2390
  this.tracker.reportInferenceFallback(classNode);
2320
2391
  if (this.resolver.isThisPropertyAssignmentDeclarationRedundant(node)) return false;
@@ -2323,11 +2394,12 @@ export class DeclarationTransformer extends Transformer {
2323
2394
  if (getTextOfPropertyName(name) === 'constructor') return false;
2324
2395
  if (name instanceof Identifier && !isIdentifierText(name.text))
2325
2396
  name = this.factory.createStringLiteralFromNode(name);
2397
+ // JSDoc modifiers such as `@readonly` and `@private` apply to the property.
2398
+ let modifierFlags = this.ensureModifierFlags(node);
2399
+ if (isStaticMember) modifierFlags |= ModifierFlags.Static;
2326
2400
  const property = this.factory.created(
2327
2401
  new PropertyDeclaration(
2328
- isStaticMember
2329
- ? this.factory.createModifierList([this.factory.createToken(SyntaxKind.StaticKeyword)])
2330
- : undefined,
2402
+ this.createModifiers(modifierFlags),
2331
2403
  name,
2332
2404
  undefined,
2333
2405
  this.ensureType(node, false),
@@ -2636,7 +2708,7 @@ export class DeclarationTransformer extends Transformer {
2636
2708
  declaration.modifiers,
2637
2709
  clause,
2638
2710
  this.rewriteModuleSpecifier(declaration, declaration.moduleSpecifier)!,
2639
- this.tryGetResolutionModeOverride(declaration.attributes),
2711
+ declaration.attributes,
2640
2712
  );
2641
2713
  }
2642
2714
 
@@ -3031,10 +3103,15 @@ function isNonContextualKeyword(kind: SyntaxKind): boolean {
3031
3103
  );
3032
3104
  }
3033
3105
 
3034
- function isClassExtendingNull(heritage: NodeList): boolean {
3035
- if (heritage.nodes.length !== 1) return false;
3036
- for (const type of (heritage.nodes[0] as HeritageClause).types.nodes)
3037
- if (getExpression(type)!.kind === SyntaxKind.NullKeyword) return true;
3106
+ /** Whether a class's `extends` clause names exactly `null`. */
3107
+ function isClassExtendingNull(node: Node): boolean {
3108
+ const heritage = getHeritageClauses(node);
3109
+ if (heritage === undefined) return false;
3110
+ for (const clause of heritage.nodes) {
3111
+ if ((clause as HeritageClause).token !== SyntaxKind.ExtendsKeyword) continue;
3112
+ const types = (clause as HeritageClause).types.nodes;
3113
+ return types.length === 1 && getExpression(types[0]!)?.kind === SyntaxKind.NullKeyword;
3114
+ }
3038
3115
  return false;
3039
3116
  }
3040
3117
 
@@ -3118,3 +3195,12 @@ function getTextOfJSDocComment(comment: NodeList | undefined): string {
3118
3195
  }
3119
3196
  return text.trimEnd();
3120
3197
  }
3198
+
3199
+ function hasAnyBindingInitializers(pattern: BindingPattern): boolean {
3200
+ for (const element of pattern.elements.nodes) {
3201
+ if (!(element instanceof BindingElement)) continue;
3202
+ if (element.initializer !== undefined) return true;
3203
+ if (element.name instanceof BindingPattern && hasAnyBindingInitializers(element.name)) return true;
3204
+ }
3205
+ return false;
3206
+ }
@@ -67,7 +67,7 @@ export class DecoratorMetadata extends Transformer {
67
67
  private readonly legacyDecorators: boolean;
68
68
  private readonly facts: SyntaxFacts;
69
69
  private readonly serializer: MetadataSerializer;
70
- /** The class whose members are visited. */
70
+ /** The class, or object literal, whose members are visited. */
71
71
  private parentClass: Node | undefined;
72
72
 
73
73
  constructor(context: EmitContext, options: CompilerOptions, resolver: EmitResolver, facts: SyntaxFacts) {
@@ -89,6 +89,14 @@ export class DecoratorMetadata extends Transformer {
89
89
  case SyntaxKind.ClassDeclaration:
90
90
  case SyntaxKind.ClassExpression:
91
91
  return this.visitClass(node);
92
+ case SyntaxKind.ObjectLiteralExpression: {
93
+ // Members of an object literal are not class elements and get no metadata.
94
+ const saved = this.parentClass;
95
+ this.parentClass = node;
96
+ const updated = this.visitEachChild(node);
97
+ this.parentClass = saved;
98
+ return updated;
99
+ }
92
100
  case SyntaxKind.PropertyDeclaration:
93
101
  if (node instanceof PropertyDeclaration) {
94
102
  if (!hasDecorators(node)) return this.visitEachChild(node);
@@ -189,7 +189,8 @@ class Flattener {
189
189
  if (this.hoistTempVariables) {
190
190
  const value = factory.inlineExpressions(this.expressions)!;
191
191
  this.expressions = [];
192
- this.emitBinding(temp, value, -1, -1, undefined);
192
+ // tsgo gives this declaration the empty range at the start of the file (core.TextRange{}), not a synthesized one.
193
+ this.emitBinding(temp, value, 0, 0, undefined);
193
194
  } else {
194
195
  this.visitor.context.addVariableDeclaration(temp);
195
196
  const last = this.declarations[this.declarations.length - 1]!;
@@ -674,9 +675,9 @@ function convertToArrayElement(visitor: VisitorHooks, element: BindingElement):
674
675
  const factory = visitor.factory;
675
676
  const name = element.name;
676
677
  if (name === undefined) return converted(visitor, factory.created(new OmittedExpression()), element);
677
- if (element.dotDotDotToken !== undefined)
678
- return converted(visitor, factory.created(new SpreadElement(name)), element);
679
678
  const target = convertBindingNameToTarget(visitor, name);
679
+ if (element.dotDotDotToken !== undefined)
680
+ return converted(visitor, factory.created(new SpreadElement(target)), element);
680
681
  if (element.initializer === undefined) return target;
681
682
  return converted(visitor, factory.createAssignment(target, element.initializer), element);
682
683
  }
@@ -366,7 +366,7 @@ export function createExternalHelpersImportDeclarationIfNeeded(
366
366
  const name = names[i];
367
367
  // Aliased when the name is used in the file.
368
368
  specifiers.push(
369
- isFileLevelUniqueName(file, name)
369
+ isFileLevelUniqueName(context.mostOriginal(file) as SourceFile, name)
370
370
  ? factory.created(new ImportSpecifier(false, undefined, factory.createIdentifier(name)))
371
371
  : factory.created(
372
372
  new ImportSpecifier(false, factory.createIdentifier(name), factory.createUnscopedHelperName(name)),
@@ -30,6 +30,7 @@ import {
30
30
  ArrayLiteralExpression,
31
31
  VariableDeclaration,
32
32
  getTagName,
33
+ getText,
33
34
  } from '../ast.js';
34
35
  import { isExternalOrCommonJSModule } from '../binder-utilities.js';
35
36
  import { isLineBreak, isWhiteSpaceSingleLine } from '../character-codes.js';
@@ -545,7 +546,7 @@ export class JsxTransformer extends Transformer {
545
546
  private expressionFromEntityName(entity: Node, parent: Node): Node {
546
547
  if (entity instanceof QualifiedName) {
547
548
  const left = this.expressionFromEntityName(entity.left, parent);
548
- return this.factory.createPropertyAccessExpression(left, this.factory.createIdentifier(entity.right.text));
549
+ return this.factory.createPropertyAccessExpression(left, this.factory.createIdentifier(getText(entity.right)));
549
550
  }
550
551
  return this.createReactNamespace((entity as Identifier).text, parent);
551
552
  }
@@ -527,26 +527,45 @@ export class ReferenceResolver {
527
527
  const moduleDeclaration = moduleDeclarationOfSpecifier(declaration);
528
528
  if (imported === undefined || moduleDeclaration === undefined) return false;
529
529
  const moduleSymbol = this.resolveModuleSpecifier(declaration, getModuleSpecifierOf(moduleDeclaration));
530
- return moduleSymbol !== undefined && this.isExportedThroughTypeOnlyStar(moduleSymbol, imported, new Set<Symbol>());
530
+ return moduleSymbol !== undefined && this.isExportedThroughTypeOnlyStar(moduleSymbol, imported);
531
531
  }
532
532
 
533
- /** Whether a module's export `name` comes from another module through an `export type *` on the way. */
534
- private isExportedThroughTypeOnlyStar(moduleSymbol: Symbol, name: string, visited: Set<Symbol>): boolean {
535
- if (visited.has(moduleSymbol)) return false;
536
- visited.add(moduleSymbol);
537
- const exports = moduleSymbol.exports;
538
- if (exports === undefined || exports.has(name) || name === InternalSymbolName.Default) return false;
533
+ /**
534
+ * Whether a module's export `name` comes from another module through an `export type *`, as tsgo's
535
+ * getExportsOfModuleWorker decides: a module reached through a type-only `export *` has its exports marked, and a
536
+ * module reached without one, even if already visited, clears the mark of its own exports.
537
+ */
538
+ private isExportedThroughTypeOnlyStar(moduleSymbol: Symbol, name: string): boolean {
539
+ if (name === InternalSymbolName.Default) return false;
540
+ const walk = new TypeOnlyStarWalk(name);
541
+ this.visitExportStars(walk, moduleSymbol, false, false);
542
+ return walk.typeOnly && !walk.nonTypeOnly;
543
+ }
544
+
545
+ /** Visits a module of an `export *` walk; returns whether it exports the walk's name. */
546
+ private visitExportStars(
547
+ walk: TypeOnlyStarWalk,
548
+ symbol: Symbol | undefined,
549
+ starIsTypeOnly: boolean,
550
+ isTypeOnly: boolean,
551
+ ): boolean {
552
+ const exports = symbol === undefined ? undefined : symbol.exports;
553
+ if (!isTypeOnly && exports !== undefined && exports.has(walk.name)) walk.nonTypeOnly = true;
554
+ if (symbol === undefined || exports === undefined || walk.visited.has(symbol)) return false;
555
+ walk.visited.add(symbol);
556
+ let found = exports.has(walk.name);
539
557
  const star = exports.get(InternalSymbolName.ExportStar);
540
- if (star === undefined) return false;
541
- for (const declaration of getDeclarations(star)) {
542
- if (!(declaration instanceof ExportDeclaration)) continue;
543
- const target = this.resolveExternalModuleSymbol(
544
- this.resolveModuleSpecifier(declaration, declaration.moduleSpecifier),
545
- );
546
- if (target === undefined || this.getExportFromTable(target, name, new Set<Symbol>()) === undefined) continue;
547
- return declaration.isTypeOnly || this.isExportedThroughTypeOnlyStar(target, name, visited);
548
- }
549
- return false;
558
+ if (star !== undefined)
559
+ for (const declaration of getDeclarations(star)) {
560
+ if (!(declaration instanceof ExportDeclaration)) continue;
561
+ const target = this.resolveExternalModuleSymbol(
562
+ this.resolveModuleSpecifier(declaration, declaration.moduleSpecifier),
563
+ );
564
+ if (this.visitExportStars(walk, target, declaration.isTypeOnly, isTypeOnly || declaration.isTypeOnly))
565
+ found = true;
566
+ }
567
+ if (starIsTypeOnly && found) walk.typeOnly = true;
568
+ return found;
550
569
  }
551
570
 
552
571
  /** Whether a symbol is declared in the global scope. */
@@ -803,6 +822,34 @@ export class ReferenceResolver {
803
822
 
804
823
  // Constant values
805
824
 
825
+ /**
826
+ * The symbol an entity name expression such as `E.A` refers to as an expression: tsgo takes the symbol its checker
827
+ * resolves the expression to, where each name on the left is a value, so a local `let E` hides a const enum `E`.
828
+ */
829
+ private resolveValueEntityName(name: Node): Symbol | undefined {
830
+ let symbol: Symbol | undefined;
831
+ if (name instanceof Identifier) {
832
+ const resolved = this.resolveName(name, name.text, SymbolFlags.Value | SymbolFlags.Alias);
833
+ symbol = resolved === undefined ? undefined : this.getMergedSymbol(resolved);
834
+ } else if (name instanceof PropertyAccessExpression) {
835
+ const left = this.resolveValueEntityName(name.expression);
836
+ const right = name.name;
837
+ if (left === undefined || !(right instanceof Identifier)) return undefined;
838
+ let member = left.exports === undefined ? undefined : left.exports.get(right.text);
839
+ // A namespace merged with an alias also has the members of what the alias names, as its type does.
840
+ if (member === undefined && (left.flags & SymbolFlags.Alias) !== 0) {
841
+ const target = this.resolveAlias(left);
842
+ const targetExports = target === undefined ? undefined : target.exports;
843
+ if (targetExports !== undefined) member = targetExports.get(right.text);
844
+ }
845
+ if (member === undefined || (member.flags & (SymbolFlags.Value | SymbolFlags.Alias)) === 0) return undefined;
846
+ symbol = this.getMergedSymbol(member);
847
+ } else return undefined;
848
+ if (symbol === undefined || (symbol.flags & SymbolFlags.Alias) === 0) return symbol;
849
+ const target = this.resolveAlias(symbol);
850
+ return target === undefined ? undefined : this.getMergedSymbol(target);
851
+ }
852
+
806
853
  /** The value of an enum member, computing the values of its whole declaration. */
807
854
  getEnumMemberValue(member: Node): Evaluation {
808
855
  const declaration = member.parent;
@@ -816,11 +863,11 @@ export class ReferenceResolver {
816
863
  if (node instanceof EnumMember) return this.getEnumMemberValue(node);
817
864
  let symbol: Symbol | undefined;
818
865
  if (node instanceof PropertyAccessExpression) {
819
- if (isEntityNameExpressionNode(node)) symbol = this.resolveEntityName(node, SymbolFlags.Value, false);
866
+ if (isEntityNameExpressionNode(node)) symbol = this.resolveValueEntityName(node);
820
867
  } else if (node instanceof ElementAccessExpression) {
821
868
  const argument = stringLiteralText(node.argumentExpression);
822
869
  if (isEntityNameExpressionNode(node.expression) && argument !== undefined) {
823
- const root = this.resolveEntityName(node.expression, SymbolFlags.Value, false);
870
+ const root = this.resolveValueEntityName(node.expression);
824
871
  const exports = root === undefined ? undefined : root.exports;
825
872
  const member = exports === undefined ? undefined : exports.get(argument);
826
873
  if (member !== undefined) symbol = this.getMergedSymbol(member);
@@ -1131,6 +1178,23 @@ export function getDeclarationOfAliasSymbol(symbol: Symbol): Node | undefined {
1131
1178
  return undefined;
1132
1179
  }
1133
1180
 
1181
+ /** The state of `isExportedThroughTypeOnlyStar`'s walk over the `export *` declarations of modules for one name. */
1182
+ class TypeOnlyStarWalk {
1183
+ readonly name: string;
1184
+ readonly visited: Set<Symbol>;
1185
+ /** Whether a module reached through a type-only `export *` exports the name. */
1186
+ typeOnly: boolean;
1187
+ /** Whether a module reached without one exports the name itself. */
1188
+ nonTypeOnly: boolean;
1189
+
1190
+ constructor(name: string) {
1191
+ this.name = name;
1192
+ this.visited = new Set<Symbol>();
1193
+ this.typeOnly = false;
1194
+ this.nonTypeOnly = false;
1195
+ }
1196
+ }
1197
+
1134
1198
  function isTypeOnlyAlias(symbol: Symbol): boolean {
1135
1199
  let node = getDeclarationOfAliasSymbol(symbol);
1136
1200
  while (node !== undefined) {