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
@@ -6,7 +6,7 @@ import { parentPort } from 'node:worker_threads';
6
6
  import { publish, sharesPublishedGraphs } from '@scriptc/threads';
7
7
  import { reserveNodeIds, shareNodeIds } from './ast.js';
8
8
  import type { OutputWriter } from './compile-program.js';
9
- import { useThreadTextCaches } from './diagnostics.js';
9
+ import { type DiagnosticFormatOptions, formattedReports, useThreadTextCaches } from './diagnostics.js';
10
10
  import { compareReferencesOfThread, type ReferenceJob, referenceThreads } from './incremental.js';
11
11
  import {
12
12
  CheckerResult,
@@ -16,6 +16,7 @@ import {
16
16
  parallelCheck,
17
17
  recycleFiles,
18
18
  } from './parallel-check.js';
19
+ import { emitFromQueue, parallelEmit, postedEmitResult } from './parallel-emit.js';
19
20
  import { type LoadMessage, parallelParse } from './parallel-parse.js';
20
21
  import type { ParseThread } from './parse-thread.js';
21
22
  import { useLazyJSDocTable } from './parser.js';
@@ -23,6 +24,7 @@ import { CheckedProgram } from './program-checker.js';
23
24
  import type { Program } from './program.js';
24
25
  import { assignSymbolIdsAtCreation, reserveSymbolIds, shareSymbolIds } from './symbol.js';
25
26
  import { mark, setTimelineThread } from './timeline.js';
27
+ import { setThreadSharingData, type ThreadSharingData } from './shared-results.js';
26
28
 
27
29
  /** What threads need from the command line that starts them. */
28
30
  export interface ThreadDrivers {
@@ -38,7 +40,7 @@ export interface ThreadDrivers {
38
40
  export type ThreadSpawn = (data: ThreadData) => Worker;
39
41
 
40
42
  /** The `workerData` of a thread of tsc-ts. */
41
- export type ThreadData = CheckerThreadData | ParseThreadData | ReferenceThreadData;
43
+ export type ThreadData = CheckerThreadData | EmitThreadData | ParseThreadData | ReferenceThreadData;
42
44
 
43
45
  export interface CheckerThreadData {
44
46
  readonly kind: 'check';
@@ -55,6 +57,24 @@ export interface CheckerThreadData {
55
57
  readonly emitKinds: number[] | undefined;
56
58
  readonly checking: boolean;
57
59
  readonly units: number[];
60
+ /** See `CheckedProgram.globalsInFileDiagnostics`. */
61
+ readonly globalsInFileDiagnostics: boolean;
62
+ /** The main thread's report format (`formattedReports`), which the thread formats its diagnostics in. */
63
+ readonly reportFormat: DiagnosticFormatOptions | undefined;
64
+ /** TSC_TS_SHARE: what the thread shares results with the other checker threads through. */
65
+ readonly sharing: ThreadSharingData | undefined;
66
+ }
67
+
68
+ export interface EmitThreadData {
69
+ readonly kind: 'emit';
70
+ /** The shared, published program. */
71
+ readonly program: Program;
72
+ readonly index: number;
73
+ readonly counter: SharedArrayBuffer;
74
+ readonly files: number[];
75
+ readonly kinds: number[];
76
+ readonly nodeIds: number;
77
+ readonly symbolIds: number;
58
78
  }
59
79
 
60
80
  export interface ParseThreadData {
@@ -88,6 +108,8 @@ export function startThreads(spawn: ThreadSpawn, drivers: ThreadDrivers, args: r
88
108
  emitKinds,
89
109
  checking,
90
110
  units,
111
+ globalsInFileDiagnostics,
112
+ sharing,
91
113
  ) =>
92
114
  spawn({
93
115
  kind: 'check',
@@ -103,8 +125,13 @@ export function startThreads(spawn: ThreadSpawn, drivers: ThreadDrivers, args: r
103
125
  emitKinds,
104
126
  checking,
105
127
  units,
128
+ globalsInFileDiagnostics,
129
+ reportFormat: formattedReports.format,
130
+ sharing,
106
131
  });
107
132
  if (sharesPublishedGraphs) {
133
+ parallelEmit.spawn = (program, index, counter, files, kinds, nodeIds, symbolIds) =>
134
+ spawn({ kind: 'emit', program, index, counter, files, kinds, nodeIds, symbolIds });
108
135
  parallelParse.spawn = (configFileName, counter, index) =>
109
136
  spawn({ kind: 'parse', configFileName, args, counter, index });
110
137
  // The main thread compares the files a reference thread that failed did not.
@@ -123,6 +150,7 @@ export function runThread(data: unknown, drivers: ThreadDrivers): void {
123
150
  const kind = (data as { kind: string }).kind;
124
151
  if (kind === 'parse') runParseThread(data as ParseThreadData, drivers);
125
152
  else if (kind === 'references') runReferenceThread(data as ReferenceThreadData);
153
+ else if (kind === 'emit') runEmitThread(data as EmitThreadData, drivers);
126
154
  else runCheckerThread(data as CheckerThreadData, drivers);
127
155
  }
128
156
 
@@ -141,12 +169,36 @@ function runReferenceThread(data: ReferenceThreadData): void {
141
169
  mark('references compared');
142
170
  }
143
171
 
172
+ /** An emit thread (parallel-emit.ts): emits JavaScript, without a checker. */
173
+ function runEmitThread(job: EmitThreadData, drivers: ThreadDrivers): void {
174
+ setTimelineThread('e' + String(job.index));
175
+ mark('thread start');
176
+ // As on a checker thread, the shared program is never written.
177
+ reserveNodeIds(job.nodeIds);
178
+ reserveSymbolIds(job.symbolIds);
179
+ assignSymbolIdsAtCreation();
180
+ useLazyJSDocTable();
181
+ useThreadTextCaches();
182
+ const program = publish(job.program);
183
+ const result = emitFromQueue(
184
+ program,
185
+ job.index,
186
+ new Int32Array(job.counter),
187
+ job.files,
188
+ job.kinds,
189
+ drivers.outputWriter(),
190
+ );
191
+ parentPort!.postMessage(postedEmitResult(result, program));
192
+ mark('result posted');
193
+ }
194
+
144
195
  /** A checker thread (parallel-check.ts). */
145
196
  function runCheckerThread(job: CheckerThreadData, drivers: ThreadDrivers): void {
146
197
  const startedAt = Date.now();
147
198
  setTimelineThread('c' + String(job.index));
148
199
  mark('thread start');
149
200
  parallelCheck.writer = drivers.outputWriter();
201
+ formattedReports.format = job.reportFormat;
150
202
  let program: Program | undefined = undefined;
151
203
  if (job.program !== undefined) {
152
204
  // The shared program is never written: new ids continue above its own, and lazily parsed JSDoc
@@ -160,11 +212,18 @@ function runCheckerThread(job: CheckerThreadData, drivers: ThreadDrivers): void
160
212
  mark('program received');
161
213
  } else program = drivers.programOfCommandLine(job.args);
162
214
  // Without a program this thread checks nothing; the main thread checks the files it would have.
215
+ let checked: CheckedProgram | undefined = undefined;
216
+ if (program !== undefined) {
217
+ // The checker the program creates shares results with the other checker threads.
218
+ setThreadSharingData(job.sharing);
219
+ checked = new CheckedProgram(program);
220
+ checked.globalsInFileDiagnostics = job.globalsInFileDiagnostics;
221
+ }
163
222
  const result =
164
- program === undefined
223
+ checked === undefined
165
224
  ? new CheckerResult(job.index, [], [], [], [], 0, [])
166
225
  : checkFromQueue(
167
- new CheckedProgram(program),
226
+ checked,
168
227
  job.index,
169
228
  new Int32Array(job.counter),
170
229
  job.order,
@@ -176,6 +235,7 @@ function runCheckerThread(job: CheckerThreadData, drivers: ThreadDrivers): void
176
235
  job.emitKinds,
177
236
  job.checking,
178
237
  job.units,
238
+ job.sharing,
179
239
  );
180
240
  // Packed results are copied: nothing this thread allocated stays reachable after it ends.
181
241
  if (packsResults) parentPort!.postMessage(packResult(result, program!));
@@ -5,6 +5,7 @@
5
5
  // namespace, enum or module counts as a use.
6
6
  import {
7
7
  BinaryExpression,
8
+ ComputedPropertyName,
8
9
  ConditionalTypeNode,
9
10
  ExportAssignment,
10
11
  ExportDeclaration,
@@ -32,13 +33,16 @@ import {
32
33
  UnionTypeNode,
33
34
  getDotDotDotToken,
34
35
  getExpression,
36
+ getHeritageClauses,
35
37
  getInitializer,
38
+ getName,
36
39
  getParameters,
37
40
  getTagName,
38
41
  getType,
39
42
  getTypeArguments,
40
43
  } from '../ast.js';
41
44
  import { canHaveDecorators, isImportCall } from '../ast-utilities.js';
45
+ import { isAssignmentTarget, isClassLike } from '../binder-utilities.js';
42
46
  import {
43
47
  type CompilerOptions,
44
48
  JsxEmit,
@@ -52,6 +56,7 @@ import {
52
56
  getFirstConstructorWithBody,
53
57
  getRestParameterElementType,
54
58
  getSetAccessorValueParameter,
59
+ isAccessor,
55
60
  nodeCanBeDecorated,
56
61
  } from './decorator-utilities.js';
57
62
  import { hasDecorators, hasSyntacticModifier } from './utilities.js';
@@ -105,10 +110,16 @@ export class AliasReferences extends NodeVisitor {
105
110
  node.kind !== SyntaxKind.PropertyDeclaration
106
111
  )
107
112
  return false;
113
+ // tsgo doesn't answer semantic questions inside a `with` statement.
114
+ if ((node.flags & NodeFlags.InWithStatement) !== 0) return false;
108
115
  if (node instanceof Identifier) {
109
116
  const parent = node.parent;
110
117
  if (
111
118
  parent === undefined ||
119
+ isUnresolvedIdentifier(node as Identifier, this.options.experimentalDecorators === true)
120
+ )
121
+ return false;
122
+ if (
112
123
  !(
113
124
  isExpressionNode(node) ||
114
125
  parent instanceof ShorthandPropertyAssignment ||
@@ -120,7 +131,6 @@ export class AliasReferences extends NodeVisitor {
120
131
  // Only the left of a property access or qualified name; the right is a property lookup.
121
132
  if (parent instanceof PropertyAccessExpression && parent.expression !== node) return false;
122
133
  if (parent instanceof QualifiedName && parent.left !== node) return false;
123
- if (isInsideMetaProperty(node)) return false;
124
134
  return this.markIdentifier(node as Identifier);
125
135
  }
126
136
  if (node.kind === SyntaxKind.PropertyAccessExpression || node.kind === SyntaxKind.QualifiedName) {
@@ -129,7 +139,9 @@ export class AliasReferences extends NodeVisitor {
129
139
  top !== undefined && isPropertyAccessOrQualifiedName(top);
130
140
  top = top.parent
131
141
  )
132
- if (isPartOfTypeNode(top)) return false;
142
+ // Names in an import type's qualifier, `ns.y` in `typeof import("./b").ns.y`, are exports of the
143
+ // imported module, not references to this file's imports.
144
+ if (isPartOfTypeNode(top) || isImportTypeQualifierPart(top)) return false;
133
145
  return this.markProperty(node);
134
146
  }
135
147
  if (node instanceof ExportAssignment) {
@@ -411,6 +423,17 @@ export class AliasReferences extends NodeVisitor {
411
423
  }
412
424
  }
413
425
 
426
+ /** Whether `node` is the qualifier of an import type, or a part of one. */
427
+ function isImportTypeQualifierPart(node: Node): boolean {
428
+ let current = node;
429
+ let parent = current.parent;
430
+ while (parent !== undefined && parent.kind === SyntaxKind.QualifiedName) {
431
+ current = parent;
432
+ parent = parent.parent;
433
+ }
434
+ return parent instanceof ImportTypeNode && parent.qualifier === current;
435
+ }
436
+
414
437
  function isPropertyAccessOrQualifiedName(node: Node): boolean {
415
438
  return node.kind === SyntaxKind.PropertyAccessExpression || node.kind === SyntaxKind.QualifiedName;
416
439
  }
@@ -446,9 +469,101 @@ function shouldMarkIdentifier(node: Identifier): boolean {
446
469
  return !(exportDeclaration instanceof ExportDeclaration && exportDeclaration.isTypeOnly);
447
470
  }
448
471
 
449
- function isInsideMetaProperty(node: Node): boolean {
450
- for (let current: Node | undefined = node; current !== undefined; current = current.parent)
472
+ /**
473
+ * Whether checking never resolves identifier `node`, so tsgo doesn't mark it: in a meta property, the name of a
474
+ * shorthand property with an initializer outside a destructuring assignment, in a decorator of a node that can't be
475
+ * decorated, in the expression of `for (var of x)`, in an invalid computed property name, in an interface's heritage
476
+ * clause, or in a class's `extends` types after the first.
477
+ */
478
+ function isUnresolvedIdentifier(node: Identifier, legacyDecorators: boolean): boolean {
479
+ const parent = node.parent!;
480
+ if (
481
+ parent instanceof ShorthandPropertyAssignment &&
482
+ parent.name === node &&
483
+ parent.objectAssignmentInitializer !== undefined &&
484
+ !isAssignmentTarget(parent.parent!)
485
+ )
486
+ return true;
487
+ let decorator: Node | undefined = undefined;
488
+ let forNode: Node | undefined = undefined;
489
+ let computedName: Node | undefined = undefined;
490
+ let heritageClause: Node | undefined = undefined;
491
+ for (let current: Node | undefined = node; current !== undefined; current = current.parent) {
451
492
  if (current instanceof MetaProperty) return true;
493
+ if (current.kind === SyntaxKind.Decorator) {
494
+ if (decorator === undefined) decorator = current;
495
+ } else if (current instanceof ForInOrOfStatement) {
496
+ if (forNode === undefined) forNode = current;
497
+ } else if (current instanceof ComputedPropertyName) {
498
+ if (computedName === undefined) computedName = current;
499
+ } else if (current instanceof HeritageClause) {
500
+ if (heritageClause === undefined) heritageClause = current;
501
+ }
502
+ }
503
+ if (decorator !== undefined) {
504
+ const decorated = decorator.parent;
505
+ if (
506
+ decorated !== undefined &&
507
+ !nodeCanBeDecorated(
508
+ legacyDecorators,
509
+ decorated,
510
+ decorated.parent,
511
+ decorated.parent === undefined ? undefined : decorated.parent.parent,
512
+ )
513
+ )
514
+ return true;
515
+ }
516
+ if (forNode !== undefined) {
517
+ const statement = forNode as ForInOrOfStatement;
518
+ if (
519
+ statement.initializer instanceof VariableDeclarationList &&
520
+ statement.initializer.declarations.nodes.length === 0 &&
521
+ (node === statement.expression || isNodeDescendantOf(node, statement.expression))
522
+ )
523
+ return true;
524
+ }
525
+ if (computedName !== undefined) {
526
+ const grandparent = computedName.parent!.parent!;
527
+ if (
528
+ (grandparent.kind === SyntaxKind.TypeLiteral ||
529
+ isClassLike(grandparent) ||
530
+ grandparent.kind === SyntaxKind.InterfaceDeclaration) &&
531
+ (computedName as ComputedPropertyName).expression instanceof BinaryExpression &&
532
+ ((computedName as ComputedPropertyName).expression as BinaryExpression).operatorToken.kind ===
533
+ SyntaxKind.InKeyword &&
534
+ !isAccessor(computedName.parent!)
535
+ )
536
+ return true;
537
+ }
538
+ if (heritageClause !== undefined) {
539
+ const declaration = heritageClause.parent!;
540
+ // An interface's heritage clauses are types.
541
+ if (declaration.kind === SyntaxKind.InterfaceDeclaration) return true;
542
+ // Only a class's first `extends` type is its base class; checking never resolves the others.
543
+ if (isClassLike(declaration) && (heritageClause as HeritageClause).token === SyntaxKind.ExtendsKeyword) {
544
+ const first = getClassExtendsHeritageElement(declaration);
545
+ if (first !== undefined && node !== first && !isNodeDescendantOf(node, first)) return true;
546
+ }
547
+ }
548
+ return false;
549
+ }
550
+
551
+ /** The first type of a class's first `extends` clause. */
552
+ function getClassExtendsHeritageElement(node: Node): Node | undefined {
553
+ const clauses = getHeritageClauses(node);
554
+ if (clauses === undefined) return undefined;
555
+ for (const clause of clauses.nodes)
556
+ if ((clause as HeritageClause).token === SyntaxKind.ExtendsKeyword) {
557
+ const types = (clause as HeritageClause).types.nodes;
558
+ return types.length > 0 ? types[0] : undefined;
559
+ }
560
+ return undefined;
561
+ }
562
+
563
+ /** Whether `node` is inside `ancestor`. */
564
+ function isNodeDescendantOf(node: Node, ancestor: Node): boolean {
565
+ for (let current = node.parent; current !== undefined; current = current.parent)
566
+ if (current === ancestor) return true;
452
567
  return false;
453
568
  }
454
569
 
@@ -631,6 +746,10 @@ function isInExpressionContext(node: Node): boolean {
631
746
  return getExpression(parent) === node && !isPartOfTypeNode(parent);
632
747
  case SyntaxKind.ShorthandPropertyAssignment:
633
748
  return parent instanceof ShorthandPropertyAssignment && parent.objectAssignmentInitializer === node;
749
+ case SyntaxKind.FunctionExpression:
750
+ case SyntaxKind.ClassExpression:
751
+ // The name of a function or class expression is a declaration name, not an expression.
752
+ return getName(parent) !== node;
634
753
  }
635
754
  return isExpressionNode(parent);
636
755
  }
@@ -28,7 +28,6 @@ import {
28
28
  getParameters,
29
29
  ArrayLiteralExpression,
30
30
  SpreadElement,
31
- ReturnStatement,
32
31
  AwaitExpression,
33
32
  QualifiedName,
34
33
  Token,
@@ -721,7 +720,8 @@ export class AsyncFunctions extends Transformer {
721
720
  } else {
722
721
  result = createAwaiterHelper(factory, hasLexicalThis, argumentsExpression, innerParameters, asyncBody);
723
722
  if (captureLexicalArguments && this.argumentsUsed) {
724
- const block = this.convertToFunctionBlock(result);
723
+ const block = context.convertToFunctionBlock(result, true);
724
+ if (!(result instanceof Block)) context.setOriginal(block.statements.nodes[0]!, result);
725
725
  result = factory.updateBlock(
726
726
  block,
727
727
  context.mergeEnvironmentList(block.statements, [this.createCaptureArgumentsStatement()]),
@@ -762,21 +762,6 @@ export class AsyncFunctions extends Transformer {
762
762
  return block;
763
763
  }
764
764
 
765
- private convertToFunctionBlock(node: Node): Block {
766
- if (node instanceof Block) return node as Block;
767
- const factory = this.factory;
768
- const statement = factory.created(new ReturnStatement(node));
769
- statement.pos = node.pos;
770
- statement.end = node.end;
771
- this.context.setOriginal(statement, node);
772
- const block = factory.createBlock([statement], true);
773
- block.statements.pos = node.pos;
774
- block.statements.end = node.end;
775
- block.pos = node.pos;
776
- block.end = node.end;
777
- return block;
778
- }
779
-
780
765
  private getOriginalIfFunctionLike(node: Node): Node {
781
766
  const original = this.context.mostOriginal(node);
782
767
  return isFunctionLikeDeclaration(original) ? original : node;
@@ -418,7 +418,7 @@ export class ClassFieldsTransformer extends Transformer {
418
418
  private visitForSubstitution(node: Node): Node | undefined {
419
419
  if (node instanceof Identifier) return this.visitIdentifier(node as Identifier);
420
420
  if (node instanceof PropertyAccessExpression && node.name instanceof Identifier)
421
- return this.visitPropertyAccessExpressionForSubstitution(node);
421
+ return this.visitPropertyAccessExpressionForSubstitution(node, this.substitutionMode);
422
422
  return this.substitutionMode.visitEachChild(node);
423
423
  }
424
424
 
@@ -763,9 +763,10 @@ export class ClassFieldsTransformer extends Transformer {
763
763
  private visitMethodOrAccessorDeclaration(node: Node): Node | undefined {
764
764
  if (!isPrivateIdentifierClassElementDeclaration(node) || !this.shouldTransformClassElementToWeakMap(node))
765
765
  return this.classElementMode.visitEachChild(node);
766
- const info = this.accessPrivateIdentifier(getName(node)!);
766
+ // The member's own class declares it; an untransformed or duplicate name leaves the member as written.
767
+ const info = this.getPrivateIdentifier(this.getPrivateEnvironment(), getName(node)!);
767
768
  if (info === undefined) throw new Error('Undeclared private name for property declaration.');
768
- if (!info.isValid) return node;
769
+ if (info.kind === PrivateKind.Untransformed || !info.isValid) return node;
769
770
  const functionName = this.getHoistedFunctionName(node, info);
770
771
  if (functionName !== undefined) {
771
772
  const factory = this.factory;
@@ -878,9 +879,9 @@ export class ClassFieldsTransformer extends Transformer {
878
879
  const factory = this.factory;
879
880
  if (this.shouldTransformClassElementToWeakMap(node)) {
880
881
  // Fields become WeakMaps: the declaration goes.
881
- const info = this.accessPrivateIdentifier(node.name);
882
+ const info = this.getPrivateIdentifier(this.getPrivateEnvironment(), node.name);
882
883
  if (info === undefined) throw new Error('Undeclared private name for property declaration.');
883
- if (!info.isValid) return node;
884
+ if (info.kind === PrivateKind.Untransformed || !info.isValid) return node;
884
885
  // A static field of a class whose static blocks stay becomes a static block.
885
886
  if (info.isStatic && !this.shouldTransformPrivateElementsOrClassStaticBlocks) {
886
887
  const statement = this.transformPropertyOrClassStaticBlock(node, factory.createThisExpression());
@@ -1039,12 +1040,13 @@ export class ClassFieldsTransformer extends Transformer {
1039
1040
  }
1040
1041
  }
1041
1042
  // Property names are not references and are never substituted.
1042
- if (node.name instanceof Identifier) return this.visitPropertyAccessExpressionForSubstitution(node);
1043
+ if (node.name instanceof Identifier) return this.visitPropertyAccessExpressionForSubstitution(node, this);
1043
1044
  return this.visitEachChild(node);
1044
1045
  }
1045
1046
 
1046
- private visitPropertyAccessExpressionForSubstitution(node: PropertyAccessExpression): Node {
1047
- const expression = this.visitNode(node.expression)!;
1047
+ /** Visits only the expression of a property access, with `visitor`, so that its name is never substituted. */
1048
+ private visitPropertyAccessExpressionForSubstitution(node: PropertyAccessExpression, visitor: VisitorBase): Node {
1049
+ const expression = visitor.visitNode(node.expression)!;
1048
1050
  if (expression === node.expression) return node;
1049
1051
  return this.factory.updatePropertyAccessExpression(node, expression, node.questionDotToken, node.name, node.flags);
1050
1052
  }
@@ -1745,12 +1747,11 @@ export class ClassFieldsTransformer extends Transformer {
1745
1747
  }
1746
1748
  const statics = staticPropertiesAndClassStaticBlocks(node);
1747
1749
  // Aliases must be known before visiting members, so predict whether a temporary will wrap the class.
1750
+ const hasTransformableStatics = this.hasTransformableStatics(node, statics);
1748
1751
  let isClassWithConstructorReference = false;
1749
- let hasTransformableStatics = false;
1750
1752
  let deferTempDeclaration = false;
1751
1753
  if (!isDecoratedClassDeclaration) {
1752
1754
  isClassWithConstructorReference = this.classContainsConstructorReference(node);
1753
- hasTransformableStatics = this.hasTransformableStatics(node, statics);
1754
1755
  let willHavePrivatePendingExpressions = false;
1755
1756
  if (this.shouldTransformPrivateElementsOrClassStaticBlocks) {
1756
1757
  const members = node.members.nodes;
@@ -1810,7 +1811,7 @@ export class ClassFieldsTransformer extends Transformer {
1810
1811
  for (let i = 0; i < initializers.length; i++) expressions.push(initializers[i]);
1811
1812
  expressions.push(factory.cloneIdentifier(temp));
1812
1813
  } else expressions.push(classExpression as Node);
1813
- } else {
1814
+ } else if (hasTransformableStatics || this.pendingExpressions.length > 0) {
1814
1815
  for (let i = 0; i < this.pendingExpressions.length; i++)
1815
1816
  this.pendingStatements.push(factory.createExpressionStatement(this.pendingExpressions[i]));
1816
1817
  if (statics.length > 0) {
@@ -1821,7 +1822,7 @@ export class ClassFieldsTransformer extends Transformer {
1821
1822
  else if (this.shouldTransformPrivateElementsOrClassStaticBlocks && classThis !== undefined)
1822
1823
  expressions.push(factory.createAssignment(classThis, classExpression));
1823
1824
  else expressions.push(classExpression as Node);
1824
- }
1825
+ } else expressions.push(classExpression as Node);
1825
1826
  if (expressions.length > 1) {
1826
1827
  context.addEmitFlags(classExpression, EmitFlags.Indented);
1827
1828
  for (let i = 0; i < expressions.length; i++) context.addEmitFlags(expressions[i], EmitFlags.StartOnNewLine);
@@ -259,12 +259,14 @@ export class CommonJSModuleTransformer extends Transformer {
259
259
  statement !== undefined ? statement : factory.created(new EmptyStatement()),
260
260
  );
261
261
  }
262
- if (node instanceof WithStatement)
262
+ if (node instanceof WithStatement) {
263
+ const statement = nested.visitStatement(node.statement);
263
264
  return factory.updateWithStatement(
264
265
  node as WithStatement,
265
266
  this.visitNode(node.expression)!,
266
- nested.visitStatement(node.statement)!,
267
+ statement !== undefined ? statement : factory.created(new EmptyStatement()),
267
268
  );
269
+ }
268
270
  if (node instanceof IfStatement) {
269
271
  const thenStatement = nested.visitStatement(node.thenStatement);
270
272
  return factory.updateIfStatement(
@@ -310,7 +312,7 @@ export class CommonJSModuleTransformer extends Transformer {
310
312
  this.discarded.visitNode(node.initializer),
311
313
  this.visitNode(node.condition),
312
314
  this.discarded.visitNode(node.incrementor),
313
- this.topLevelNested.visitIterationBody(node.statement)!,
315
+ this.visitIterationBody(node.statement)!,
314
316
  );
315
317
  if (node instanceof ForInOrOfStatement)
316
318
  return this.factory.updateForInOrOfStatement(
@@ -318,7 +320,7 @@ export class CommonJSModuleTransformer extends Transformer {
318
320
  node.awaitModifier,
319
321
  this.discarded.visitNode(node.initializer)!,
320
322
  this.visitNode(node.expression)!,
321
- this.topLevelNested.visitIterationBody(node.statement)!,
323
+ this.visitIterationBody(node.statement)!,
322
324
  );
323
325
  if (node instanceof ExpressionStatement || node instanceof VoidExpression)
324
326
  return this.discarded.visitEachChild(node);
@@ -1241,7 +1243,9 @@ export class CommonJSModuleTransformer extends Transformer {
1241
1243
  const rewrite =
1242
1244
  this.options.rewriteRelativeImportExtensions === true &&
1243
1245
  ((isImportCall(node) && node.arguments.nodes.length > 0) || (isInJSFile(node) && isRequireCall(node, false)));
1244
- if (isImportCall(node) && this.shouldTransformImportCall()) return this.visitImportCallExpression(node, rewrite);
1246
+ // `import.source()` and the other phase imports stay as written.
1247
+ if (node.expression.kind === SyntaxKind.ImportKeyword && this.shouldTransformImportCall())
1248
+ return this.visitImportCallExpression(node, rewrite);
1245
1249
  if (rewrite) return this.rewriteImportOrRequireCall(node);
1246
1250
  const callee = node.expression;
1247
1251
  if (callee instanceof Identifier) {
@@ -1331,14 +1335,14 @@ export class CommonJSModuleTransformer extends Transformer {
1331
1335
  let args = node.arguments;
1332
1336
  const nodes = args.nodes;
1333
1337
  if (nodes.length > 0) {
1334
- const first = nodes[0];
1338
+ const first = this.visitNode(nodes[0])!;
1335
1339
  const rewritten =
1336
1340
  first instanceof StringLiteral || first.kind === SyntaxKind.NoSubstitutionTemplateLiteral
1337
1341
  ? rewriteModuleSpecifier(this.context, first, this.options)
1338
1342
  : factory.createRewriteRelativeImportExtensionsHelper(first, this.options.jsx === JsxEmit.Preserve);
1339
1343
  const rest = nodes.slice(1);
1340
1344
  const visitedRest = this.visitArray(rest);
1341
- if (rewritten !== first || visitedRest !== rest)
1345
+ if (rewritten !== nodes[0] || visitedRest !== rest)
1342
1346
  args = new NodeList(args.pos, args.end, [rewritten].concat(visitedRest));
1343
1347
  }
1344
1348
  return factory.updateCallExpression(node, expression, callQuestionDotToken(node), undefined, args, node.flags);
@@ -21,13 +21,13 @@ import {
21
21
  hasSyntacticModifier,
22
22
  isEntityNameExpression,
23
23
  isStatic,
24
- isTypeNodeKind,
25
24
  } from '../binder-utilities.js';
26
25
  import { isFunctionLikeDeclarationKind } from '../ast-utilities.js';
27
26
  import { Diagnostic, type DiagnosticMessage, Diagnostics } from '../diagnostics.js';
28
27
  import { ModifierFlags } from '../ast.js';
29
28
  import { isStatement } from '../printer/utilities.js';
30
29
  import { SyntaxKind } from '../syntax-kind.js';
30
+ import { isPartOfTypeNode } from './alias-references.js';
31
31
  import { isParameterPropertyDeclaration } from './utilities.js';
32
32
  import { SymbolAccessibility, type SymbolAccessibilityResult } from './declarations-resolver.js';
33
33
  import { getDeclarations } from '../symbol.js';
@@ -482,6 +482,8 @@ function parameterTypeMessage(node: Node, result: SymbolAccessibilityResult): Di
482
482
  );
483
483
  case SyntaxKind.FunctionDeclaration:
484
484
  case SyntaxKind.FunctionType:
485
+ case SyntaxKind.ArrowFunction:
486
+ case SyntaxKind.FunctionExpression:
485
487
  return byModuleName(
486
488
  result,
487
489
  Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named,
@@ -713,7 +715,7 @@ export function createIsolatedDeclarationError(node: Node, requiresAddingUndefin
713
715
  Diagnostics.Extends_clause_can_t_contain_an_expression_with_isolatedDeclarations,
714
716
  [],
715
717
  );
716
- if (isTypeNodeKind(node.kind) || node.kind === SyntaxKind.TypeQuery || isEntityNameExpression(node, false))
718
+ if (isPartOfTypeNode(node) || node.kind === SyntaxKind.TypeQuery || isEntityNameExpression(node, false))
717
719
  return addParentDeclarationRelatedInfo(
718
720
  node,
719
721
  createDiagnosticForNode(
@@ -758,7 +760,7 @@ export function createIsolatedDeclarationError(node: Node, requiresAddingUndefin
758
760
  case SyntaxKind.BindingElement:
759
761
  return createDiagnosticForNode(
760
762
  node,
761
- Diagnostics.Binding_elements_can_t_be_exported_directly_with_isolatedDeclarations,
763
+ Diagnostics.Binding_elements_with_initializers_can_t_be_exported_directly_with_isolatedDeclarations,
762
764
  [],
763
765
  );
764
766
  case SyntaxKind.PropertyDeclaration:
@@ -389,10 +389,8 @@ export class PseudoChecker {
389
389
  const initializer = declaration.initializer;
390
390
  // As tsgo, the file's own declarations; merged ones are left to the checker's type comparison.
391
391
  const symbol = declaration.symbol;
392
- if (
393
- initializer !== undefined &&
394
- (symbol === undefined || countVariableDeclarations(getDeclarations(symbol)) === 1)
395
- ) {
392
+ // A binding pattern has no symbol, and its initializer's type isn't the variable's.
393
+ if (initializer !== undefined && symbol !== undefined && countVariableDeclarations(getDeclarations(symbol)) === 1) {
396
394
  if (!isContextuallyTyped(declaration)) {
397
395
  // Const template literals may become literal types, so they aren't inferred.
398
396
  if (
@@ -3,7 +3,6 @@
3
3
  // binder, and the checker answers them with types.
4
4
  import type { ImportDeclaration, ModifierFlags, Node, SourceFile, FileReference } from '../ast.js';
5
5
  import type { EmitContext } from '../printer/emit-context.js';
6
- import type { ModuleKind } from '../options.js';
7
6
  import type { Symbol, SymbolFlags } from '../symbol.js';
8
7
  import { EmitResolver } from './emit-resolver.js';
9
8
 
@@ -180,8 +179,6 @@ export abstract class DeclarationEmitResolver extends EmitResolver {
180
179
  abstract isExpandoFunctionDeclaration(node: Node): boolean;
181
180
  /** Types: the declarations of properties assigned to a function. */
182
181
  abstract getExpandoPropertyDeclarations(node: Node): Node[];
183
- /** The `resolution-mode` of import attributes, or undefined. */
184
- abstract getResolutionModeOverride(node: Node): ModuleKind | undefined;
185
182
  /** The program file a `/// <reference path>` names. */
186
183
  abstract getSourceFileFromReference(file: SourceFile, reference: FileReference): SourceFile | undefined;
187
184
 
@@ -16,8 +16,6 @@ import {
16
16
  FileReference,
17
17
  FunctionTypeNode,
18
18
  Identifier,
19
- ImportAttribute,
20
- ImportAttributes,
21
19
  type ImportDeclaration,
22
20
  ImportEqualsDeclaration,
23
21
  KeywordTypeNode,
@@ -59,7 +57,6 @@ import {
59
57
  getInitializer,
60
58
  getMembers,
61
59
  getName,
62
- getText,
63
60
  getParameters,
64
61
  getSymbol,
65
62
  getType,
@@ -83,8 +80,7 @@ import {
83
80
  skipParentheses,
84
81
  } from '../binder-utilities.js';
85
82
  import { NameResolver } from '../name-resolver.js';
86
- import type { CompilerOptions, ModuleKind } from '../options.js';
87
- import { ModuleKind as ModuleKinds } from '../options.js';
83
+ import type { CompilerOptions } from '../options.js';
88
84
  import { combinePaths, getDirectoryPath, getNormalizedAbsolutePath, normalizePath } from '../path.js';
89
85
  import type { EmitContext } from '../printer/emit-context.js';
90
86
  import { EmitFlags } from '../printer/emit-flags.js';
@@ -737,22 +733,6 @@ export class SyntacticDeclarationEmitResolver extends DeclarationEmitResolver {
737
733
  return this.emitResolver.getTypeReferenceSerializationKind(typeName, location);
738
734
  }
739
735
 
740
- getResolutionModeOverride(node: Node): ModuleKind | undefined {
741
- if (!(node instanceof ImportAttributes)) return undefined;
742
- for (const element of node.attributes.nodes) {
743
- if (!(element instanceof ImportAttribute)) continue;
744
- const name = element.name;
745
- if (name === undefined || (name.kind !== SyntaxKind.StringLiteral && name.kind !== SyntaxKind.Identifier))
746
- continue;
747
- if (getText(name) !== 'resolution-mode') continue;
748
- const value = element.value;
749
- if (!(value instanceof StringLiteral)) return undefined;
750
- if (value.text === 'import') return ModuleKinds.ESNext;
751
- if (value.text === 'require') return ModuleKinds.CommonJS;
752
- }
753
- return undefined;
754
- }
755
-
756
736
  getSourceFileFromReference(file: SourceFile, reference: FileReference): SourceFile | undefined {
757
737
  const path = normalizePath(combinePaths(getDirectoryPath(file.fileName), reference.fileName));
758
738
  for (const candidate of [path, path + '.ts', path + '.tsx', path + '.d.ts']) {