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
@@ -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,
@@ -161,6 +161,7 @@ import { ConstantKind } from './reference-resolver.js';
161
161
  import { DeclarationTracker } from './declarations-tracker.js';
162
162
  import { Transformer } from './transformer.js';
163
163
  import { declarationCount, getDeclarations, SymbolFlags } from '../symbol.js';
164
+ import { IdentifierName } from '../identifier-name.js';
164
165
 
165
166
  export class DeclarationTransformer extends Transformer {
166
167
  readonly host: OutputPathsHost;
@@ -183,6 +184,8 @@ export class DeclarationTransformer extends Transformer {
183
184
  private readonly expandoHosts: Map<Node, Node | undefined>;
184
185
  /** The namespace members for the assigned properties of each function, by statement. */
185
186
  private readonly expandoMembers: Map<Node, Node[]>;
187
+ /** Assigned properties of hosts that weren't visible when found, by host; written if the host becomes visible. */
188
+ private readonly deferredExpandoAssignments: Map<Node, BinaryExpression[]>;
186
189
  /** The `export =` for a CommonJS `module.exports = …`. */
187
190
  private cjsExportAssignment: Node | undefined;
188
191
  /** The exports for CommonJS `exports.x = …` assignments. */
@@ -221,6 +224,7 @@ export class DeclarationTransformer extends Transformer {
221
224
  this.lateStatementReplacements = new Map<Node, Node | undefined>();
222
225
  this.expandoHosts = new Map<Node, Node | undefined>();
223
226
  this.expandoMembers = new Map<Node, Node[]>();
227
+ this.deferredExpandoAssignments = new Map<Node, BinaryExpression[]>();
224
228
  this.cjsExportAssignment = undefined;
225
229
  this.cjsExportMembers = [];
226
230
  this.cjsExportAssignmentName = undefined;
@@ -293,6 +297,7 @@ export class DeclarationTransformer extends Transformer {
293
297
  this.lateStatementReplacements = new Map<Node, Node | undefined>();
294
298
  this.expandoHosts.clear();
295
299
  this.expandoMembers.clear();
300
+ this.deferredExpandoAssignments.clear();
296
301
  this.witnessedCjsExports.clear();
297
302
  this.cjsExportAssignment = undefined;
298
303
  this.cjsExportAssignmentName = undefined;
@@ -672,6 +677,19 @@ export class DeclarationTransformer extends Transformer {
672
677
  case SyntaxKind.TypeQuery:
673
678
  this.checkEntityNameVisibility((input as TypeQueryNode).exprName, this.enclosingDeclaration);
674
679
  return this.visitEachChild(input);
680
+ case SyntaxKind.QualifiedName: {
681
+ // `typeof this.#x`: the private member isn't in the declaration output.
682
+ const right = (input as QualifiedName).right;
683
+ if (right.kind === SyntaxKind.PrivateIdentifier)
684
+ this.tracker.addDiagnostic(
685
+ createDiagnosticForNode(
686
+ input,
687
+ Diagnostics.Declaration_emit_elides_private_members_but_0_refers_to_a_private_member_Write_an_explicit_type_here,
688
+ [getText(right)],
689
+ ),
690
+ );
691
+ return this.visitEachChild(input);
692
+ }
675
693
  case SyntaxKind.TupleType: {
676
694
  const result = this.visitEachChild(input);
677
695
  if (isOriginalNodeSingleLine(this.context, input)) this.context.addEmitFlags(result, EmitFlags.SingleLine);
@@ -774,10 +792,13 @@ export class DeclarationTransformer extends Transformer {
774
792
  const types = clause.types.nodes;
775
793
  const retained: Node[] = [];
776
794
  for (const type of types) {
777
- const expression = (type as ExpressionWithTypeArguments).expression;
795
+ const name = getHeritageClauseElementName(type);
778
796
  if (
779
- isEntityNameExpression(expression, false) ||
780
- (clause.token === SyntaxKind.ExtendsKeyword && expression.kind === SyntaxKind.NullKeyword)
797
+ name.kind === SyntaxKind.QualifiedName ||
798
+ isEntityNameExpression(name, false) ||
799
+ (clause.token === SyntaxKind.ExtendsKeyword &&
800
+ type.kind === SyntaxKind.ExpressionWithTypeArguments &&
801
+ name.kind === SyntaxKind.NullKeyword)
781
802
  )
782
803
  retained.push(type);
783
804
  }
@@ -861,12 +882,14 @@ export class DeclarationTransformer extends Transformer {
861
882
  isVariableDeclarationInitializedToRequire(input)
862
883
  )
863
884
  return this.transformCjsRequireVariableDeclaration(input);
864
- if (input.name instanceof BindingPattern) return this.recreateBindingPattern(input.name);
885
+ // A binding pattern with initializers becomes a declaration per name; without them it stays.
886
+ if (input.name instanceof BindingPattern && hasAnyBindingInitializers(input.name))
887
+ return this.recreateBindingPattern(input.name);
865
888
  // Variable types don't enter new diagnostic contexts.
866
889
  this.suppressNewDiagnosticContexts = true;
867
890
  return this.factory.updateVariableDeclaration(
868
891
  input,
869
- input.name,
892
+ this.visitBindingName(input.name),
870
893
  undefined,
871
894
  this.ensureType(input, false),
872
895
  this.ensureNoInitializer(input),
@@ -1038,9 +1061,16 @@ export class DeclarationTransformer extends Transformer {
1038
1061
  private omitPrivateMethodType(input: Node): Node | undefined {
1039
1062
  const symbol = getSymbol(input);
1040
1063
  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
- );
1064
+ // A method signature becomes a property signature, a method a property declaration.
1065
+ let result: Node;
1066
+ if (input.kind === SyntaxKind.MethodSignature)
1067
+ result = this.factory.created(
1068
+ new PropertySignatureDeclaration(this.ensureModifiers(input), getName(input)!, undefined, undefined, undefined),
1069
+ );
1070
+ else
1071
+ result = this.factory.created(
1072
+ new PropertyDeclaration(this.ensureModifiers(input), getName(input)!, undefined, undefined, undefined),
1073
+ );
1044
1074
  this.context.assignCommentRange(result, input);
1045
1075
  return result;
1046
1076
  }
@@ -1091,7 +1121,7 @@ export class DeclarationTransformer extends Transformer {
1091
1121
  input.isTypeOnly,
1092
1122
  input.exportClause,
1093
1123
  this.rewriteModuleSpecifier(input, input.moduleSpecifier),
1094
- this.tryGetResolutionModeOverride(input.attributes),
1124
+ input.attributes,
1095
1125
  );
1096
1126
  }
1097
1127
  if (input instanceof ExportAssignment)
@@ -1119,9 +1149,14 @@ export class DeclarationTransformer extends Transformer {
1119
1149
  (input.parent.kind === SyntaxKind.SourceFile || input.parent.kind === SyntaxKind.ModuleBlock)
1120
1150
  ) {
1121
1151
  const result = this.factory.created(new ExportAssignment(undefined, isExportEquals, undefined, expression));
1152
+ this.context.assignSourceMapRange(result, input);
1122
1153
  this.context.assignCommentRange(result, input);
1123
1154
  return result;
1124
1155
  }
1156
+ // Types the default export can't name are reported for it, as class and function declarations too.
1157
+ const tracker = this.tracker;
1158
+ tracker.diagnosticContext = new DiagnosticContext(DiagnosticContextKind.DefaultExport, input, undefined);
1159
+ tracker.pushErrorFallbackNode(assignment);
1125
1160
  const unwrapped = skipOuterExpressions(expression);
1126
1161
  const name = this.getNameOfExportedExpression(unwrapped, isExportEquals);
1127
1162
  // Class and function expressions become declarations.
@@ -1129,17 +1164,16 @@ export class DeclarationTransformer extends Transformer {
1129
1164
  const declaration =
1130
1165
  unwrapped instanceof ClassExpression
1131
1166
  ? this.transformClassExpressionToDeclaration(unwrapped, name, this.declareModifiers())
1132
- : this.transformFunctionLikeToDeclaration(unwrapped, name, this.declareModifiers());
1167
+ : this.transformFunctionLikeToDeclaration(unwrapped, name, this.declareModifiers(), getType(assignment));
1168
+ tracker.popErrorFallbackNode();
1133
1169
  this.context.assignCommentRange(declaration, input);
1134
1170
  const exportAssignment = this.factory.created(new ExportAssignment(undefined, isExportEquals, undefined, name));
1171
+ this.context.assignSourceMapRange(exportAssignment, input);
1135
1172
  this.context.addEmitFlags(exportAssignment, EmitFlags.NoComments);
1136
1173
  return this.factory.createSyntaxList([exportAssignment, declaration]);
1137
1174
  }
1138
1175
  // 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
1176
  this.cjsExportAssignmentName = name;
1142
- tracker.pushErrorFallbackNode(assignment);
1143
1177
  let initializer: Node | undefined = undefined;
1144
1178
  if (isPrimitiveLiteralValue(skipParenthesesOnly(expression), true))
1145
1179
  initializer = this.resolver.createLiteralConstValue(this.context, this.parseNode(assignment), tracker);
@@ -1148,6 +1182,7 @@ export class DeclarationTransformer extends Transformer {
1148
1182
  tracker.popErrorFallbackNode();
1149
1183
  const statement = this.createConstStatement(declaration);
1150
1184
  const exportAssignment = this.factory.created(new ExportAssignment(undefined, isExportEquals, undefined, name));
1185
+ this.context.assignSourceMapRange(exportAssignment, input);
1151
1186
  this.context.assignCommentRange(statement, input);
1152
1187
  return this.factory.createSyntaxList([statement, exportAssignment]);
1153
1188
  }
@@ -1159,8 +1194,24 @@ export class DeclarationTransformer extends Transformer {
1159
1194
  );
1160
1195
  }
1161
1196
 
1162
- private transformFunctionLikeToDeclaration(fn: Node, name: Identifier, modifiers: ModifierList): Node {
1163
- const fullSignature = getFullSignature(fn);
1197
+ private transformFunctionLikeToDeclaration(
1198
+ fn: Node,
1199
+ name: Identifier,
1200
+ modifiers: ModifierList,
1201
+ fullSignatureType: Node | undefined,
1202
+ ): Node {
1203
+ // A JSDoc signature, of the function or of the assignment, is reused as the type of a `const`.
1204
+ const fullSignature = getFullSignature(fn) ?? fullSignatureType;
1205
+ if (fullSignature !== undefined)
1206
+ return this.factory.createVariableStatement(
1207
+ modifiers,
1208
+ this.factory.createVariableDeclarationList(
1209
+ this.factory.createNodeList([
1210
+ this.factory.createVariableDeclaration(name, undefined, this.visitNode(fullSignature), undefined),
1211
+ ]),
1212
+ NodeFlags.Const,
1213
+ ),
1214
+ );
1164
1215
  return this.factory.created(
1165
1216
  new FunctionDeclaration(
1166
1217
  modifiers,
@@ -1169,7 +1220,7 @@ export class DeclarationTransformer extends Transformer {
1169
1220
  this.ensureTypeParams(fn, getTypeParameters(fn)),
1170
1221
  this.updateParamList(fn, getParameters(fn)!),
1171
1222
  this.ensureType(fn, false),
1172
- fullSignature === undefined ? undefined : this.visitNode(fullSignature),
1223
+ undefined,
1173
1224
  undefined,
1174
1225
  ),
1175
1226
  );
@@ -1236,11 +1287,6 @@ export class DeclarationTransformer extends Transformer {
1236
1287
  return input;
1237
1288
  }
1238
1289
 
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
1290
  /** The replacement statements for a direct child of a source file or module block. */
1245
1291
  private transformTopLevelDeclaration(input: Node): Node | undefined {
1246
1292
  if (input === undefined) return undefined;
@@ -1280,7 +1326,8 @@ export class DeclarationTransformer extends Transformer {
1280
1326
  if (isDeclaration(input) && this.isDeclarationAndNotVisible(input)) return undefined;
1281
1327
  if (isFunctionLike(input) && this.resolver.isImplementationOfOverload(input)) return undefined;
1282
1328
  const original = this.context.mostOriginal(input);
1283
- if (this.expandoHosts.has(original)) return this.createFullExpandoBlock(original);
1329
+ if (this.expandoHosts.has(original) || this.deferredExpandoAssignments.has(original))
1330
+ return this.createFullExpandoBlock(original);
1284
1331
  const previousEnclosingDeclaration = this.enclosingDeclaration;
1285
1332
  if (isEnclosingDeclaration(input)) this.enclosingDeclaration = input;
1286
1333
  const oldContext = tracker.diagnosticContext;
@@ -1349,7 +1396,8 @@ export class DeclarationTransformer extends Transformer {
1349
1396
  this.ensureModifiers(input),
1350
1397
  input.name,
1351
1398
  this.visitNodes(input.typeParameters),
1352
- this.visitNode(input.type)!,
1399
+ // stripInternal can elide an `@internal` type on the right; it falls back to `any`, as index signatures do.
1400
+ this.visitNode(input.type) ?? this.keyword(SyntaxKind.AnyKeyword),
1353
1401
  );
1354
1402
  }
1355
1403
 
@@ -1384,6 +1432,7 @@ export class DeclarationTransformer extends Transformer {
1384
1432
  const saveNeedsDeclare = this.needsDeclare;
1385
1433
  this.needsDeclare = false;
1386
1434
  const body = input.body;
1435
+ const attributes = this.visitNode(input.attributes) as TypeLiteralNode | undefined;
1387
1436
  let keyword = input.keyword;
1388
1437
  if (keyword !== SyntaxKind.GlobalKeyword && !(input.name instanceof StringLiteral))
1389
1438
  keyword = SyntaxKind.NamespaceKeyword;
@@ -1409,7 +1458,7 @@ export class DeclarationTransformer extends Transformer {
1409
1458
  this.needsDeclare = saveNeedsDeclare;
1410
1459
  this.needsScopeFixMarker = oldNeedsScopeFix;
1411
1460
  this.resultHasScopeMarker = oldHasScopeFix;
1412
- return this.factory.updateModuleDeclaration(input, modifiers, keyword, input.name, updatedBody);
1461
+ return this.factory.updateModuleDeclaration(input, modifiers, keyword, input.name, attributes, updatedBody);
1413
1462
  }
1414
1463
  if (body !== undefined) {
1415
1464
  // A nested `namespace a.b` is transformed now: it needs no visibility painting.
@@ -1418,10 +1467,10 @@ export class DeclarationTransformer extends Transformer {
1418
1467
  const inner = this.lateStatementReplacements.get(original);
1419
1468
  this.lateStatementReplacements.delete(original);
1420
1469
  this.needsDeclare = saveNeedsDeclare;
1421
- return this.factory.updateModuleDeclaration(input, modifiers, keyword, input.name, inner);
1470
+ return this.factory.updateModuleDeclaration(input, modifiers, keyword, input.name, attributes, inner);
1422
1471
  }
1423
1472
  this.needsDeclare = saveNeedsDeclare;
1424
- return this.factory.updateModuleDeclaration(input, modifiers, keyword, input.name, undefined);
1473
+ return this.factory.updateModuleDeclaration(input, modifiers, keyword, input.name, attributes, undefined);
1425
1474
  }
1426
1475
 
1427
1476
  private stripExportModifiersOfList(list: NodeList): NodeList {
@@ -1489,7 +1538,7 @@ export class DeclarationTransformer extends Transformer {
1489
1538
  return factory.updateTypeAliasDeclaration(node, modifiers, node.name, node.typeParameters, node.type);
1490
1539
  if (node instanceof EnumDeclaration) return factory.updateEnumDeclaration(node, modifiers, node.name, node.members);
1491
1540
  if (node instanceof ModuleDeclaration)
1492
- return factory.updateModuleDeclaration(node, modifiers, node.keyword, node.name, node.body);
1541
+ return factory.updateModuleDeclaration(node, modifiers, node.keyword, node.name, node.attributes, node.body);
1493
1542
  if (node instanceof ImportDeclaration)
1494
1543
  return factory.updateImportDeclaration(node, modifiers, node.importClause, node.moduleSpecifier, node.attributes);
1495
1544
  if (node instanceof ExportDeclaration)
@@ -1886,7 +1935,7 @@ export class DeclarationTransformer extends Transformer {
1886
1935
  keyword === SyntaxKind.DefaultKeyword
1887
1936
  ) {
1888
1937
  // A parse tree node, so names it uses are resolved where it's written.
1889
- const identifier = new Identifier(text);
1938
+ const identifier = new Identifier(new IdentifierName(text));
1890
1939
  identifier.parent = name.parent;
1891
1940
  return identifier;
1892
1941
  }
@@ -2004,6 +2053,7 @@ export class DeclarationTransformer extends Transformer {
2004
2053
  this.declareModifiers(),
2005
2054
  SyntaxKind.NamespaceKeyword,
2006
2055
  namespaceName,
2056
+ undefined,
2007
2057
  factory.created(new ModuleBlock(factory.createNodeList([classDeclaration]))),
2008
2058
  ),
2009
2059
  );
@@ -2084,6 +2134,7 @@ export class DeclarationTransformer extends Transformer {
2084
2134
  this.declareModifiers(),
2085
2135
  SyntaxKind.NamespaceKeyword,
2086
2136
  name,
2137
+ undefined,
2087
2138
  this.factory.created(new ModuleBlock(this.factory.createNodeList(stripped))),
2088
2139
  ),
2089
2140
  );
@@ -2119,7 +2170,17 @@ export class DeclarationTransformer extends Transformer {
2119
2170
  const name = this.factory.createIdentifier(namespace.text);
2120
2171
  const property = this.tryGetPropertyName(left);
2121
2172
  if (property === '' || !isIdentifierText(property)) return false;
2122
- if (isDeclaration(declaration) && this.isDeclarationAndNotVisible(declaration)) return false;
2173
+ const hostId = this.getExpandoHostId(declaration);
2174
+ if (isDeclaration(declaration) && this.isDeclarationAndNotVisible(declaration)) {
2175
+ // Writing the type of a visible declaration, such as `typeof f`, can make the host visible later.
2176
+ let deferred = this.deferredExpandoAssignments.get(hostId);
2177
+ if (deferred === undefined) {
2178
+ deferred = [];
2179
+ this.deferredExpandoAssignments.set(hostId, deferred);
2180
+ }
2181
+ deferred.push(node);
2182
+ return false;
2183
+ }
2123
2184
  if (declaration instanceof FunctionDeclaration && !shouldEmitFunctionProperties(declaration)) return false;
2124
2185
  this.transformExpandoHost(name, declaration);
2125
2186
  const exportName = this.factory.createIdentifier(property);
@@ -2133,21 +2194,21 @@ export class DeclarationTransformer extends Transformer {
2133
2194
  localName = exportName;
2134
2195
  if (localName === undefined || isNonContextualKeyword(stringToToken(localName.text)))
2135
2196
  localName = this.factory.createGeneratedNameForNode(node, GeneratedIdentifierFlags.None, '', '');
2136
- const hostId = this.getExpandoHostId(declaration);
2137
2197
  const scope = this.enterDiagnosticContext(node);
2138
2198
  let members = this.expandoMembers.get(hostId);
2139
2199
  if (members === undefined) {
2140
2200
  members = [];
2141
2201
  this.expandoMembers.set(hostId, members);
2142
2202
  }
2203
+ let hasExport = false;
2204
+ for (const member of members) if (member.kind === SyntaxKind.ExportDeclaration) hasExport = true;
2143
2205
  if (node.right instanceof Identifier) {
2144
- // Alias-like: `export { name }` or `export { name as alias }`.
2206
+ // Alias-like: `export { name }` or `export { name as alias }`; the other members stay exported.
2207
+ if (!hasExport) this.addExportModifierToExpandoMembers(members);
2145
2208
  members.push(this.transformBinaryExpressionToExportDeclaration(node, exportName));
2146
2209
  this.exitDiagnosticContext(scope);
2147
2210
  return true;
2148
2211
  }
2149
- let hasExport = false;
2150
- for (const member of members) if (member.kind === SyntaxKind.ExportDeclaration) hasExport = true;
2151
2212
  const variable = this.factory.createVariableStatement(
2152
2213
  hasExport ? this.factory.createModifierList([this.factory.createToken(SyntaxKind.ExportKeyword)]) : undefined,
2153
2214
  this.factory.createVariableDeclarationList(
@@ -2162,17 +2223,21 @@ export class DeclarationTransformer extends Transformer {
2162
2223
  if (local.text !== exportName.text || this.context.hasAutoGenerateInfo(local))
2163
2224
  statements.push(this.createExportDeclaration(local, exportName));
2164
2225
  // 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
- );
2226
+ if (statements.length > 1 && !hasExport) this.addExportModifierToExpandoMembers(members);
2171
2227
  for (const statement of statements) members.push(statement);
2172
2228
  this.exitDiagnosticContext(scope);
2173
2229
  return true;
2174
2230
  }
2175
2231
 
2232
+ /** Adds `export` to a host's members, before the first `export {}` is added to them. */
2233
+ private addExportModifierToExpandoMembers(members: Node[]): void {
2234
+ for (let i = 0; i < members.length; i++)
2235
+ members[i] = this.replaceModifiers(
2236
+ members[i],
2237
+ this.createModifiers(ModifierFlags.Export | getCombinedModifierFlags(members[i])),
2238
+ );
2239
+ }
2240
+
2176
2241
  private tryGetPropertyName(node: Node): string {
2177
2242
  if (node instanceof ElementAccessExpression) return this.resolver.getElementAccessExpressionName(node);
2178
2243
  if (node instanceof PropertyAccessExpression && node.name instanceof Identifier) return node.name.text;
@@ -2251,6 +2316,12 @@ export class DeclarationTransformer extends Transformer {
2251
2316
 
2252
2317
  /** A function with its assigned properties as a namespace of the same name. */
2253
2318
  private createFullExpandoBlock(id: Node): Node | undefined {
2319
+ // Assignments deferred while the host wasn't visible; they are deferred again if it still isn't.
2320
+ const deferred = this.deferredExpandoAssignments.get(id);
2321
+ if (deferred !== undefined) {
2322
+ this.deferredExpandoAssignments.delete(id);
2323
+ for (const assignment of deferred) this.transformExpandoAssignment(assignment);
2324
+ }
2254
2325
  const host = this.expandoHosts.get(id);
2255
2326
  const addOns = this.expandoMembers.get(id);
2256
2327
  if (addOns === undefined || host === undefined) return host;
@@ -2274,6 +2345,7 @@ export class DeclarationTransformer extends Transformer {
2274
2345
  modifiers,
2275
2346
  SyntaxKind.NamespaceKeyword,
2276
2347
  name,
2348
+ undefined,
2277
2349
  this.factory.created(new ModuleBlock(this.factory.createNodeList(addOns))),
2278
2350
  ),
2279
2351
  ),
@@ -2314,7 +2386,7 @@ export class DeclarationTransformer extends Transformer {
2314
2386
  return false;
2315
2387
  this.seenProperties.add(key);
2316
2388
  const heritage = getHeritageClauses(classNode);
2317
- if (heritage !== undefined && heritage.nodes.length > 0 && !isClassExtendingNull(heritage)) {
2389
+ if (heritage !== undefined && heritage.nodes.length > 0 && !isClassExtendingNull(classNode)) {
2318
2390
  // A base class may provide the member; that needs types.
2319
2391
  this.tracker.reportInferenceFallback(classNode);
2320
2392
  if (this.resolver.isThisPropertyAssignmentDeclarationRedundant(node)) return false;
@@ -2323,11 +2395,12 @@ export class DeclarationTransformer extends Transformer {
2323
2395
  if (getTextOfPropertyName(name) === 'constructor') return false;
2324
2396
  if (name instanceof Identifier && !isIdentifierText(name.text))
2325
2397
  name = this.factory.createStringLiteralFromNode(name);
2398
+ // JSDoc modifiers such as `@readonly` and `@private` apply to the property.
2399
+ let modifierFlags = this.ensureModifierFlags(node);
2400
+ if (isStaticMember) modifierFlags |= ModifierFlags.Static;
2326
2401
  const property = this.factory.created(
2327
2402
  new PropertyDeclaration(
2328
- isStaticMember
2329
- ? this.factory.createModifierList([this.factory.createToken(SyntaxKind.StaticKeyword)])
2330
- : undefined,
2403
+ this.createModifiers(modifierFlags),
2331
2404
  name,
2332
2405
  undefined,
2333
2406
  this.ensureType(node, false),
@@ -2636,7 +2709,7 @@ export class DeclarationTransformer extends Transformer {
2636
2709
  declaration.modifiers,
2637
2710
  clause,
2638
2711
  this.rewriteModuleSpecifier(declaration, declaration.moduleSpecifier)!,
2639
- this.tryGetResolutionModeOverride(declaration.attributes),
2712
+ declaration.attributes,
2640
2713
  );
2641
2714
  }
2642
2715
 
@@ -3031,10 +3104,15 @@ function isNonContextualKeyword(kind: SyntaxKind): boolean {
3031
3104
  );
3032
3105
  }
3033
3106
 
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;
3107
+ /** Whether a class's `extends` clause names exactly `null`. */
3108
+ function isClassExtendingNull(node: Node): boolean {
3109
+ const heritage = getHeritageClauses(node);
3110
+ if (heritage === undefined) return false;
3111
+ for (const clause of heritage.nodes) {
3112
+ if ((clause as HeritageClause).token !== SyntaxKind.ExtendsKeyword) continue;
3113
+ const types = (clause as HeritageClause).types.nodes;
3114
+ return types.length === 1 && getExpression(types[0]!)?.kind === SyntaxKind.NullKeyword;
3115
+ }
3038
3116
  return false;
3039
3117
  }
3040
3118
 
@@ -3118,3 +3196,12 @@ function getTextOfJSDocComment(comment: NodeList | undefined): string {
3118
3196
  }
3119
3197
  return text.trimEnd();
3120
3198
  }
3199
+
3200
+ function hasAnyBindingInitializers(pattern: BindingPattern): boolean {
3201
+ for (const element of pattern.elements.nodes) {
3202
+ if (!(element instanceof BindingElement)) continue;
3203
+ if (element.initializer !== undefined) return true;
3204
+ if (element.name instanceof BindingPattern && hasAnyBindingInitializers(element.name)) return true;
3205
+ }
3206
+ return false;
3207
+ }
@@ -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
  }