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
package/README.md CHANGED
@@ -31,9 +31,9 @@ npx tsc-ts -p tsconfig.json
31
31
  npx tsc-ts --noEmit src/index.ts
32
32
  ```
33
33
 
34
- `tsc-ts --api` serves the TypeScript API over stdin and stdout, like `tsc --api`. On Windows, `--api --pipe \\.\pipe\<name>` serves it over a named pipe it creates, as `tsc --api --pipe` does, for clients that connect to the pipe (such as scriptc under Node.js); only the native executable supports `--pipe`.
34
+ `tsc-ts --api` serves the TypeScript API over stdin and stdout, like `tsc --api`. On Windows, `--api --pipe \\.\pipe\<name>` serves it over a named pipe it creates, as `tsc --api --pipe` does, for clients that connect to the pipe (such as scriptc under Node.js); only the native executable supports `--pipe`. On macOS and Linux, `--api --listen <path>` serves it on a Unix socket it creates, with mode 0600, to one client of the same user at a time, each until the client closes its end. Each client gets the answers a new `tsc-ts --api` process would give, except that symbol ids continue from earlier clients, and the server reads every file through the client again, but it keeps parsed files between clients and reuses those whose text is unchanged, along with the encoding `getSourceFile` sends for each, so a client that opens the same project again loads it faster. The server exits when no client connects for 60 seconds (`--idle-exit <seconds>` sets the time), or after a client when its resident memory is above 2.5 times what it held after its first client (`TSC_TS_LISTEN_MEMORY` sets the limit in megabytes). To stop, it removes the socket file, serves the clients that had connected, and exits. It replaces a socket file that no server answers on, such as one left by a server that was killed. Only the native executable supports `--listen`. With `--default-libraries-from-disk`, the server reads the files in its default library directory (`TSC_TS_LIB_DIR`, or the executable's directory) from the disk itself, even when the client handles file system calls (`--callbacks`), which saves a round trip to the client for each library file.
35
35
 
36
- `--checkers N` checks the program on N threads. Unless `--checkers` or `--singleThreaded` is given, the native executable uses one checker per CPU it may run on (up to 16), and at least tsgo's four; it uses fewer than the CPUs, but never fewer than four, when the estimated peak memory of more checkers would not fit 85% of the machine's memory (`TSC_TS_CHECKERS=fixed` keeps tsgo's four), and checkers beyond the fourth stop taking files, one at a time, when the process's memory reaches that share; it shares one program between its threads and also parses and binds the program's files on them. Unless `--singleThreaded` is given, the program's files are parsed and bound on threads also with `--checkers 1`, as tsgo does. Files that share costly declarations, such as a large generated schema and the few files importing it, are checked together on one checker. Under Node.js, where every thread builds its own copy of the program, tsc-ts checks on one thread unless `--checkers` is given. `--incremental`, `--watch` and `--build` always check on one thread. The diagnostics are the same as with one checker.
36
+ `--checkers N` checks the program on N threads. Unless `--checkers` or `--singleThreaded` is given, the native executable uses one checker per CPU it may run on (up to 16), and at least tsgo's four; it uses fewer than the CPUs, but never fewer than four, when the estimated peak memory of more checkers would not fit 85% of the machine's memory (`TSC_TS_CHECKERS=fixed` keeps tsgo's four), and checkers beyond the fourth stop taking files, one at a time, when the process's memory reaches that share; it shares one program between its threads and also parses and binds the program's files on them. Unless `--singleThreaded` is given, the program's files are parsed and bound on threads also with `--checkers 1` and in the first build of `--watch`, with or without build info, as tsgo does. Files that share costly declarations, such as a large generated schema and the few files importing it, are checked together on one checker. Under Node.js, where every thread builds its own copy of the program, tsc-ts checks on one thread unless `--checkers` is given. `--incremental`, `--watch` and `--build` always check on one thread. The diagnostics are the same as with one checker.
37
37
 
38
38
  The native executable never frees syntax trees, types, signatures or symbols: it keeps them until it exits, which saves the cost of tracking them during a build. A one-shot build is unaffected, but a long-running process grows with each rebuild or project update. Native `--watch` (also with `--build`) runs in a child process, and when a change arrives while that process holds more than 2.5 times the memory it held after its first build, a new process replaces it and builds the change, reporting what the old process would have. `TSC_TS_WATCH_MEMORY` sets that limit in megabytes, and `TSC_TS_WATCH_MEMORY=0` turns the replacement off. A `--api` process grows with each project update; restart it to reclaim the memory.
39
39
 
package/bin/tsc-ts.js CHANGED
@@ -2,7 +2,20 @@
2
2
  // Runs the native tsc-ts executable from this platform's package. The lib
3
3
  // files sit next to the executable, where it looks for them.
4
4
  import { spawnSync } from 'node:child_process';
5
- import { accessSync, chmodSync, constants } from 'node:fs';
5
+ import { randomBytes } from 'node:crypto';
6
+ import {
7
+ accessSync,
8
+ chmodSync,
9
+ closeSync,
10
+ constants,
11
+ fchmodSync,
12
+ openSync,
13
+ readFileSync,
14
+ renameSync,
15
+ statSync,
16
+ unlinkSync,
17
+ writeSync,
18
+ } from 'node:fs';
6
19
  import { createRequire } from 'node:module';
7
20
  import { dirname, join } from 'node:path';
8
21
  import { executableName, hostDescription, hostPlatform, packageName } from './platforms.js';
@@ -31,11 +44,67 @@ if (process.platform !== 'win32') {
31
44
  }
32
45
  }
33
46
 
47
+ if (process.platform === 'linux') writeOnce(executable);
48
+
34
49
  const result = spawnSync(executable, process.argv.slice(2), { stdio: 'inherit' });
35
50
  if (result.error) fail(`could not run ${executable}: ${result.error.message}`);
36
51
  if (result.signal) process.kill(process.pid, result.signal);
37
52
  process.exitCode = result.status ?? 1;
38
53
 
54
+ // The executable's code maps with 2 MiB pages when the page cache holds the
55
+ // file in 2 MiB folios, which a file written with one write gets on file
56
+ // systems with large folios (XFS, ext4 from Linux 6.16). Package managers
57
+ // write it in chunks, which leaves 4 KiB folios until the file is read from
58
+ // disk again. The first run writes it again with one write and renames the
59
+ // copy into place; .tsc-ts-written beside it holds the size of the copy, so
60
+ // later runs only read it. When the directory is not writable, the
61
+ // executable runs as installed.
62
+ function writeOnce(file) {
63
+ const marker = join(dirname(file), '.tsc-ts-written');
64
+ let size;
65
+ try {
66
+ size = statSync(file).size;
67
+ if (readFileSync(marker, 'utf8') === String(size)) return;
68
+ } catch {
69
+ if (size === undefined) return;
70
+ }
71
+ try {
72
+ const bytes = readFileSync(file);
73
+ replaceFile(file, bytes, statSync(file).mode & 0o7777);
74
+ replaceFile(marker, Buffer.from(String(bytes.length)), 0o644);
75
+ } catch {
76
+ // The executable runs as installed.
77
+ }
78
+ }
79
+
80
+ // Replaces `file` with `bytes` and `mode` through a new file beside it. The copy
81
+ // has an unpredictable name and is created exclusively (an existing path, a
82
+ // symbolic link included, is never opened) with mode 0600, so no other user
83
+ // can open it while it is written; it gets `mode` from its own descriptor
84
+ // before it is renamed into place. Only a copy this run created is removed.
85
+ function replaceFile(file, bytes, mode) {
86
+ const temporary = `${file}.${randomBytes(8).toString('hex')}.tmp`;
87
+ const fd = openSync(
88
+ temporary,
89
+ constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW,
90
+ 0o600,
91
+ );
92
+ try {
93
+ for (let offset = 0; offset < bytes.length;) offset += writeSync(fd, bytes, offset, bytes.length - offset);
94
+ fchmodSync(fd, mode);
95
+ closeSync(fd);
96
+ renameSync(temporary, file);
97
+ } catch (error) {
98
+ try {
99
+ closeSync(fd);
100
+ } catch {
101
+ // Closed before the failure.
102
+ }
103
+ unlinkSync(temporary);
104
+ throw error;
105
+ }
106
+ }
107
+
39
108
  function fail(message) {
40
109
  process.stderr.write(`tsc-ts: ${message}\n`);
41
110
  process.exit(1);
@@ -58,11 +58,23 @@ export declare function canHaveDecorators(node: Node): boolean;
58
58
  export declare function isStringLiteralLike(node: Node): boolean;
59
59
  /** Whether two JSX tag names (identifiers, `this`, namespaced names or property accesses) are the same. */
60
60
  export declare function tagNamesAreEquivalent(lhs: Node, rhs: Node): boolean;
61
+ /** Whether `node` is a JSDoc type expression or a type node in one. */
62
+ export declare function isJSDocTypeExpressionOrChild(node: Node): boolean;
63
+ /** The text of a JSDoc type with the leading whitespace and `*` of each line removed, and LF line breaks. */
64
+ export declare function normalizeJSDocTypeSourceText(text: string): string;
61
65
  /** The source text of a node, without leading trivia. */
62
66
  export declare function getTextOfNodeFromSourceText(sourceText: string, node: Node): string;
63
67
  export declare function isImportMeta(node: Node): boolean;
64
- /** `import(…)` or `import.defer(…)`. */
68
+ /** `import(…)`, `import.defer(…)` or `import.source(…)`. */
65
69
  export declare function isImportCall(node: Node): boolean;
70
+ /** `import.defer` or `import.source`. */
71
+ export declare function isImportPhaseMetaProperty(node: Node): boolean;
72
+ export declare function isImportDeferMetaProperty(node: Node): boolean;
73
+ export declare function isImportSourceMetaProperty(node: Node): boolean;
74
+ /** `import source x from "m"` or `import.source("m")`. */
75
+ export declare function isSourcePhaseImport(node: Node): boolean;
76
+ /** `import.source(…)`. */
77
+ export declare function isSourcePhaseImportCall(node: Node): boolean;
66
78
  /** `require(x)` with one argument, a string literal if `requireStringLiteralLikeArgument`. */
67
79
  export declare function isRequireCall(node: Node, requireStringLiteralLikeArgument: boolean): boolean;
68
80
  /** The string literal of `import("x")` types. */
@@ -80,3 +92,9 @@ export declare function isAmbientModule(node: Node): boolean;
80
92
  export declare function isJSDocTypeAssertion(node: Node): boolean;
81
93
  /** The expression a check applies to: parentheses and `satisfies` are skipped, but not JavaScript casts. */
82
94
  export declare function getEffectiveCheckNode(argument: Node): Node;
95
+ /** The entity name of a heritage clause element: a type reference's type name, or an
96
+ * `ExpressionWithTypeArguments`'s expression. */
97
+ export declare function getHeritageClauseElementName(node: Node): Node;
98
+ /** Whether a name, or the rightmost name of a qualified name, is the type name of a type reference in a
99
+ * heritage clause. */
100
+ export declare function isNameOfHeritageClauseTypeReference(nodeIn: Node): boolean;
@@ -2,7 +2,9 @@
2
2
  //
3
3
  // Fields of `instanceof`-narrowed nodes are read through `as` casts: scriptc reads them
4
4
  // statically, but reads fields of a narrowed value dynamically.
5
- import { CallExpression, ExternalModuleReference, Identifier, ImportEqualsDeclaration, ImportTypeNode, JsxNamespacedName, LiteralTypeNode, MetaProperty, ModuleDeclaration, PropertyAccessExpression, StringLiteral, getExpression, getIsTypeOnly, getModuleSpecifier, getText, getType, } from './ast.js';
5
+ import { CallExpression, ExternalModuleReference, Identifier, ImportDeclaration, ImportEqualsDeclaration, ImportTypeNode, JsxNamespacedName, LiteralTypeNode, MetaProperty, ModuleDeclaration, PropertyAccessExpression, StringLiteral, getExpression, getIsTypeOnly, getModuleSpecifier, getText, getType, } from './ast.js';
6
+ import { isTypeNodeKind } from './binder-utilities.js';
7
+ import { isLineBreak, isWhiteSpaceLike } from './character-codes.js';
6
8
  import { skipTrivia } from './scanner.js';
7
9
  export function getBinaryOperatorPrecedence(kind) {
8
10
  switch (kind) {
@@ -51,7 +53,7 @@ export function getBinaryOperatorPrecedence(kind) {
51
53
  }
52
54
  // Tokens
53
55
  export function isKeyword(token) {
54
- return token >= 82 /* SyntaxKind.FirstKeyword */ && token <= 166 /* SyntaxKind.LastKeyword */;
56
+ return token >= 82 /* SyntaxKind.FirstKeyword */ && token <= 167 /* SyntaxKind.LastKeyword */;
55
57
  }
56
58
  export function isPunctuation(token) {
57
59
  return token >= 18 /* SyntaxKind.FirstPunctuation */ && token <= 78 /* SyntaxKind.LastPunctuation */;
@@ -121,7 +123,7 @@ export function modifierToFlag(kind) {
121
123
  return 8192 /* ModifierFlags.In */;
122
124
  case 147 /* SyntaxKind.OutKeyword */:
123
125
  return 16384 /* ModifierFlags.Out */;
124
- case 171 /* SyntaxKind.Decorator */:
126
+ case 172 /* SyntaxKind.Decorator */:
125
127
  return 32768 /* ModifierFlags.Decorator */;
126
128
  }
127
129
  return 0 /* ModifierFlags.None */;
@@ -180,19 +182,19 @@ export function compareNodePositions(a, b) {
180
182
  }
181
183
  function isLeftHandSideExpressionKind(kind) {
182
184
  switch (kind) {
183
- case 212 /* SyntaxKind.PropertyAccessExpression */:
184
- case 213 /* SyntaxKind.ElementAccessExpression */:
185
- case 215 /* SyntaxKind.NewExpression */:
186
- case 214 /* SyntaxKind.CallExpression */:
187
- case 285 /* SyntaxKind.JsxElement */:
188
- case 286 /* SyntaxKind.JsxSelfClosingElement */:
189
- case 289 /* SyntaxKind.JsxFragment */:
190
- case 216 /* SyntaxKind.TaggedTemplateExpression */:
191
- case 210 /* SyntaxKind.ArrayLiteralExpression */:
192
- case 218 /* SyntaxKind.ParenthesizedExpression */:
193
- case 211 /* SyntaxKind.ObjectLiteralExpression */:
194
- case 232 /* SyntaxKind.ClassExpression */:
195
- case 219 /* SyntaxKind.FunctionExpression */:
185
+ case 213 /* SyntaxKind.PropertyAccessExpression */:
186
+ case 214 /* SyntaxKind.ElementAccessExpression */:
187
+ case 216 /* SyntaxKind.NewExpression */:
188
+ case 215 /* SyntaxKind.CallExpression */:
189
+ case 286 /* SyntaxKind.JsxElement */:
190
+ case 287 /* SyntaxKind.JsxSelfClosingElement */:
191
+ case 290 /* SyntaxKind.JsxFragment */:
192
+ case 217 /* SyntaxKind.TaggedTemplateExpression */:
193
+ case 211 /* SyntaxKind.ArrayLiteralExpression */:
194
+ case 219 /* SyntaxKind.ParenthesizedExpression */:
195
+ case 212 /* SyntaxKind.ObjectLiteralExpression */:
196
+ case 233 /* SyntaxKind.ClassExpression */:
197
+ case 220 /* SyntaxKind.FunctionExpression */:
196
198
  case 79 /* SyntaxKind.Identifier */:
197
199
  case 80 /* SyntaxKind.PrivateIdentifier */:
198
200
  case 13 /* SyntaxKind.RegularExpressionLiteral */:
@@ -200,17 +202,17 @@ function isLeftHandSideExpressionKind(kind) {
200
202
  case 9 /* SyntaxKind.BigIntLiteral */:
201
203
  case 10 /* SyntaxKind.StringLiteral */:
202
204
  case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */:
203
- case 229 /* SyntaxKind.TemplateExpression */:
205
+ case 230 /* SyntaxKind.TemplateExpression */:
204
206
  case 96 /* SyntaxKind.FalseKeyword */:
205
207
  case 105 /* SyntaxKind.NullKeyword */:
206
208
  case 109 /* SyntaxKind.ThisKeyword */:
207
209
  case 111 /* SyntaxKind.TrueKeyword */:
208
210
  case 107 /* SyntaxKind.SuperKeyword */:
209
- case 236 /* SyntaxKind.NonNullExpression */:
210
- case 234 /* SyntaxKind.ExpressionWithTypeArguments */:
211
- case 237 /* SyntaxKind.MetaProperty */:
211
+ case 237 /* SyntaxKind.NonNullExpression */:
212
+ case 235 /* SyntaxKind.ExpressionWithTypeArguments */:
213
+ case 238 /* SyntaxKind.MetaProperty */:
212
214
  case 101 /* SyntaxKind.ImportKeyword */:
213
- case 283 /* SyntaxKind.MissingDeclaration */:
215
+ case 284 /* SyntaxKind.MissingDeclaration */:
214
216
  return true;
215
217
  }
216
218
  return false;
@@ -218,32 +220,32 @@ function isLeftHandSideExpressionKind(kind) {
218
220
  /** Partially emitted expressions, created by transforms, are skipped. */
219
221
  export function isLeftHandSideExpression(node) {
220
222
  let expression = node;
221
- while (expression.kind === 348 /* SyntaxKind.PartiallyEmittedExpression */)
223
+ while (expression.kind === 349 /* SyntaxKind.PartiallyEmittedExpression */)
222
224
  expression = expression.expression;
223
225
  return isLeftHandSideExpressionKind(expression.kind);
224
226
  }
225
227
  export function isFunctionLikeDeclarationKind(kind) {
226
228
  switch (kind) {
227
- case 263 /* SyntaxKind.FunctionDeclaration */:
228
- case 175 /* SyntaxKind.MethodDeclaration */:
229
- case 177 /* SyntaxKind.Constructor */:
230
- case 178 /* SyntaxKind.GetAccessor */:
231
- case 179 /* SyntaxKind.SetAccessor */:
232
- case 219 /* SyntaxKind.FunctionExpression */:
233
- case 220 /* SyntaxKind.ArrowFunction */:
229
+ case 264 /* SyntaxKind.FunctionDeclaration */:
230
+ case 176 /* SyntaxKind.MethodDeclaration */:
231
+ case 178 /* SyntaxKind.Constructor */:
232
+ case 179 /* SyntaxKind.GetAccessor */:
233
+ case 180 /* SyntaxKind.SetAccessor */:
234
+ case 220 /* SyntaxKind.FunctionExpression */:
235
+ case 221 /* SyntaxKind.ArrowFunction */:
234
236
  return true;
235
237
  }
236
238
  return false;
237
239
  }
238
240
  export function isFunctionLikeKind(kind) {
239
241
  switch (kind) {
240
- case 174 /* SyntaxKind.MethodSignature */:
241
- case 180 /* SyntaxKind.CallSignature */:
242
- case 318 /* SyntaxKind.JSDocSignature */:
243
- case 181 /* SyntaxKind.ConstructSignature */:
244
- case 182 /* SyntaxKind.IndexSignature */:
245
- case 185 /* SyntaxKind.FunctionType */:
246
- case 186 /* SyntaxKind.ConstructorType */:
242
+ case 175 /* SyntaxKind.MethodSignature */:
243
+ case 181 /* SyntaxKind.CallSignature */:
244
+ case 319 /* SyntaxKind.JSDocSignature */:
245
+ case 182 /* SyntaxKind.ConstructSignature */:
246
+ case 183 /* SyntaxKind.IndexSignature */:
247
+ case 186 /* SyntaxKind.FunctionType */:
248
+ case 187 /* SyntaxKind.ConstructorType */:
247
249
  return true;
248
250
  }
249
251
  return isFunctionLikeDeclarationKind(kind);
@@ -253,37 +255,37 @@ export function isFunctionLike(node) {
253
255
  }
254
256
  export function canHaveIllegalDecorators(node) {
255
257
  switch (node.kind) {
256
- case 303 /* SyntaxKind.PropertyAssignment */:
257
- case 304 /* SyntaxKind.ShorthandPropertyAssignment */:
258
- case 263 /* SyntaxKind.FunctionDeclaration */:
259
- case 177 /* SyntaxKind.Constructor */:
260
- case 182 /* SyntaxKind.IndexSignature */:
261
- case 176 /* SyntaxKind.ClassStaticBlockDeclaration */:
262
- case 283 /* SyntaxKind.MissingDeclaration */:
263
- case 244 /* SyntaxKind.VariableStatement */:
264
- case 265 /* SyntaxKind.InterfaceDeclaration */:
265
- case 266 /* SyntaxKind.TypeAliasDeclaration */:
266
- case 267 /* SyntaxKind.EnumDeclaration */:
267
- case 268 /* SyntaxKind.ModuleDeclaration */:
268
- case 272 /* SyntaxKind.ImportEqualsDeclaration */:
269
- case 273 /* SyntaxKind.ImportDeclaration */:
270
- case 346 /* SyntaxKind.JSImportDeclaration */:
271
- case 271 /* SyntaxKind.NamespaceExportDeclaration */:
272
- case 279 /* SyntaxKind.ExportDeclaration */:
273
- case 278 /* SyntaxKind.ExportAssignment */:
258
+ case 304 /* SyntaxKind.PropertyAssignment */:
259
+ case 305 /* SyntaxKind.ShorthandPropertyAssignment */:
260
+ case 264 /* SyntaxKind.FunctionDeclaration */:
261
+ case 178 /* SyntaxKind.Constructor */:
262
+ case 183 /* SyntaxKind.IndexSignature */:
263
+ case 177 /* SyntaxKind.ClassStaticBlockDeclaration */:
264
+ case 284 /* SyntaxKind.MissingDeclaration */:
265
+ case 245 /* SyntaxKind.VariableStatement */:
266
+ case 266 /* SyntaxKind.InterfaceDeclaration */:
267
+ case 267 /* SyntaxKind.TypeAliasDeclaration */:
268
+ case 268 /* SyntaxKind.EnumDeclaration */:
269
+ case 269 /* SyntaxKind.ModuleDeclaration */:
270
+ case 273 /* SyntaxKind.ImportEqualsDeclaration */:
271
+ case 274 /* SyntaxKind.ImportDeclaration */:
272
+ case 347 /* SyntaxKind.JSImportDeclaration */:
273
+ case 272 /* SyntaxKind.NamespaceExportDeclaration */:
274
+ case 280 /* SyntaxKind.ExportDeclaration */:
275
+ case 279 /* SyntaxKind.ExportAssignment */:
274
276
  return true;
275
277
  }
276
278
  return false;
277
279
  }
278
280
  export function canHaveDecorators(node) {
279
281
  switch (node.kind) {
280
- case 170 /* SyntaxKind.Parameter */:
281
- case 173 /* SyntaxKind.PropertyDeclaration */:
282
- case 175 /* SyntaxKind.MethodDeclaration */:
283
- case 178 /* SyntaxKind.GetAccessor */:
284
- case 179 /* SyntaxKind.SetAccessor */:
285
- case 232 /* SyntaxKind.ClassExpression */:
286
- case 264 /* SyntaxKind.ClassDeclaration */:
282
+ case 171 /* SyntaxKind.Parameter */:
283
+ case 174 /* SyntaxKind.PropertyDeclaration */:
284
+ case 176 /* SyntaxKind.MethodDeclaration */:
285
+ case 179 /* SyntaxKind.GetAccessor */:
286
+ case 180 /* SyntaxKind.SetAccessor */:
287
+ case 233 /* SyntaxKind.ClassExpression */:
288
+ case 265 /* SyntaxKind.ClassDeclaration */:
287
289
  return true;
288
290
  }
289
291
  return false;
@@ -307,11 +309,53 @@ export function tagNamesAreEquivalent(lhs, rhs) {
307
309
  tagNamesAreEquivalent(lhs.expression, rhs.expression));
308
310
  throw new Error('Unhandled case in tagNamesAreEquivalent');
309
311
  }
312
+ /** Whether `node` is a JSDoc type expression or a type node in one. */
313
+ export function isJSDocTypeExpressionOrChild(node) {
314
+ if (node.kind === 309 /* SyntaxKind.JSDocTypeExpression */)
315
+ return true;
316
+ if ((node.flags & (4194304 /* NodeFlags.JSDoc */ | 8 /* NodeFlags.Reparsed */)) === 0)
317
+ return false;
318
+ for (let current = node; current !== undefined; current = current.parent)
319
+ if (isTypeNodeKind(current.kind))
320
+ return true;
321
+ return false;
322
+ }
323
+ /** The text of a JSDoc type with the leading whitespace and `*` of each line removed, and LF line breaks. */
324
+ export function normalizeJSDocTypeSourceText(text) {
325
+ let result = '';
326
+ let lineStart = 0;
327
+ let multiline = false;
328
+ for (let i = 0; i < text.length; i++) {
329
+ const ch = text.charCodeAt(i);
330
+ if (!isLineBreak(ch))
331
+ continue;
332
+ result += stripLeadingJSDocComment(text.substring(lineStart, i)) + '\n';
333
+ multiline = true;
334
+ if (ch === 13 /* CharacterCodes.carriageReturn */ && text.charCodeAt(i + 1) === 10 /* CharacterCodes.lineFeed */)
335
+ i++;
336
+ lineStart = i + 1;
337
+ }
338
+ if (!multiline)
339
+ return stripLeadingJSDocComment(text);
340
+ return result + stripLeadingJSDocComment(text.substring(lineStart));
341
+ }
342
+ function stripLeadingJSDocComment(line) {
343
+ let start = 0;
344
+ while (start < line.length && isWhiteSpaceLike(line.charCodeAt(start)))
345
+ start++;
346
+ if (start < line.length && line.charCodeAt(start) === 42 /* CharacterCodes.asterisk */)
347
+ start++;
348
+ while (start < line.length && isWhiteSpaceLike(line.charCodeAt(start)))
349
+ start++;
350
+ return start === 0 ? line : line.substring(start);
351
+ }
310
352
  /** The source text of a node, without leading trivia. */
311
353
  export function getTextOfNodeFromSourceText(sourceText, node) {
312
354
  if (nodeIsMissing(node))
313
355
  return '';
314
- const text = sourceText.substring(skipTrivia(sourceText, node.pos), node.end);
356
+ let text = sourceText.substring(skipTrivia(sourceText, node.pos), node.end);
357
+ if (isJSDocTypeExpressionOrChild(node))
358
+ text = normalizeJSDocTypeSourceText(text);
315
359
  if ((node.flags & 268435456 /* NodeFlags.ReparserTransformedLiteral */) !== 0) {
316
360
  if (node instanceof StringLiteral)
317
361
  return (node.tokenFlags & 65536 /* TokenFlags.SingleQuote */) !== 0 ? "'" + text + "'" : '"' + text + '"';
@@ -326,17 +370,39 @@ export function isImportMeta(node) {
326
370
  node.keywordToken === 101 /* SyntaxKind.ImportKeyword */ &&
327
371
  node.name.text === 'meta');
328
372
  }
329
- /** `import(…)` or `import.defer(…)`. */
373
+ /** `import(…)`, `import.defer(…)` or `import.source(…)`. */
330
374
  export function isImportCall(node) {
331
375
  if (!(node instanceof CallExpression))
332
376
  return false;
333
377
  const e = node.expression;
334
- if (e.kind === 101 /* SyntaxKind.ImportKeyword */)
335
- return true;
336
- if (!(e instanceof MetaProperty))
337
- return false;
338
- const meta = e;
339
- return meta.keywordToken === 101 /* SyntaxKind.ImportKeyword */ && meta.name.text === 'defer';
378
+ return e.kind === 101 /* SyntaxKind.ImportKeyword */ || isImportPhaseMetaProperty(e);
379
+ }
380
+ /** `import.defer` or `import.source`. */
381
+ export function isImportPhaseMetaProperty(node) {
382
+ return isImportMetaPropertyNamed(node, 'defer') || isImportMetaPropertyNamed(node, 'source');
383
+ }
384
+ export function isImportDeferMetaProperty(node) {
385
+ return isImportMetaPropertyNamed(node, 'defer');
386
+ }
387
+ export function isImportSourceMetaProperty(node) {
388
+ return isImportMetaPropertyNamed(node, 'source');
389
+ }
390
+ function isImportMetaPropertyNamed(node, name) {
391
+ return (node instanceof MetaProperty &&
392
+ node.keywordToken === 101 /* SyntaxKind.ImportKeyword */ &&
393
+ node.name.text === name);
394
+ }
395
+ /** `import source x from "m"` or `import.source("m")`. */
396
+ export function isSourcePhaseImport(node) {
397
+ if (node instanceof ImportDeclaration) {
398
+ const clause = node.importClause;
399
+ return clause !== undefined && clause.phaseModifier === 167 /* SyntaxKind.SourceKeyword */;
400
+ }
401
+ return isSourcePhaseImportCall(node);
402
+ }
403
+ /** `import.source(…)`. */
404
+ export function isSourcePhaseImportCall(node) {
405
+ return node instanceof CallExpression && isImportSourceMetaProperty(node.expression);
340
406
  }
341
407
  /** `require(x)` with one argument, a string literal if `requireStringLiteralLikeArgument`. */
342
408
  export function isRequireCall(node, requireStringLiteralLikeArgument) {
@@ -365,36 +431,36 @@ export function isLiteralImportTypeNode(node) {
365
431
  }
366
432
  export function isAnyImportOrReExport(node) {
367
433
  switch (node.kind) {
368
- case 273 /* SyntaxKind.ImportDeclaration */:
369
- case 272 /* SyntaxKind.ImportEqualsDeclaration */:
370
- case 346 /* SyntaxKind.JSImportDeclaration */:
371
- case 279 /* SyntaxKind.ExportDeclaration */:
434
+ case 274 /* SyntaxKind.ImportDeclaration */:
435
+ case 273 /* SyntaxKind.ImportEqualsDeclaration */:
436
+ case 347 /* SyntaxKind.JSImportDeclaration */:
437
+ case 280 /* SyntaxKind.ExportDeclaration */:
372
438
  return true;
373
439
  }
374
440
  return false;
375
441
  }
376
442
  export function getExternalModuleName(node) {
377
443
  switch (node.kind) {
378
- case 273 /* SyntaxKind.ImportDeclaration */:
379
- case 346 /* SyntaxKind.JSImportDeclaration */:
380
- case 279 /* SyntaxKind.ExportDeclaration */:
444
+ case 274 /* SyntaxKind.ImportDeclaration */:
445
+ case 347 /* SyntaxKind.JSImportDeclaration */:
446
+ case 280 /* SyntaxKind.ExportDeclaration */:
381
447
  return getModuleSpecifier(node);
382
- case 272 /* SyntaxKind.ImportEqualsDeclaration */:
448
+ case 273 /* SyntaxKind.ImportEqualsDeclaration */:
383
449
  if (node instanceof ImportEqualsDeclaration) {
384
450
  const reference = node.moduleReference;
385
451
  if (reference instanceof ExternalModuleReference)
386
452
  return reference.expression;
387
453
  }
388
454
  return undefined;
389
- case 206 /* SyntaxKind.ImportType */:
455
+ case 207 /* SyntaxKind.ImportType */:
390
456
  return getImportTypeNodeLiteral(node);
391
- case 214 /* SyntaxKind.CallExpression */:
457
+ case 215 /* SyntaxKind.CallExpression */:
392
458
  if (node instanceof CallExpression) {
393
459
  const args = node.arguments.nodes;
394
460
  return args.length > 0 ? args[0] : undefined;
395
461
  }
396
462
  return undefined;
397
- case 268 /* SyntaxKind.ModuleDeclaration */:
463
+ case 269 /* SyntaxKind.ModuleDeclaration */:
398
464
  if (node instanceof ModuleDeclaration) {
399
465
  const name = node.name;
400
466
  if (name.kind === 10 /* SyntaxKind.StringLiteral */)
@@ -409,24 +475,25 @@ export function isGlobalScopeAugmentation(node) {
409
475
  }
410
476
  /** Whether a node is written type-only: an `import type` clause, or a `type` specifier, import or export. */
411
477
  export function isTypeOnly(node) {
412
- if (node.kind === 274 /* SyntaxKind.ImportClause */)
478
+ if (node.kind === 275 /* SyntaxKind.ImportClause */)
413
479
  return node.phaseModifier === 156 /* SyntaxKind.TypeKeyword */;
414
480
  return getIsTypeOnly(node);
415
481
  }
416
482
  /** Whether a declaration declares only a type. */
417
483
  export function isTypeDeclaration(node) {
418
484
  switch (node.kind) {
419
- case 169 /* SyntaxKind.TypeParameter */:
420
- case 264 /* SyntaxKind.ClassDeclaration */:
421
- case 265 /* SyntaxKind.InterfaceDeclaration */:
422
- case 266 /* SyntaxKind.TypeAliasDeclaration */:
423
- case 345 /* SyntaxKind.JSTypeAliasDeclaration */:
424
- case 267 /* SyntaxKind.EnumDeclaration */:
485
+ case 170 /* SyntaxKind.TypeParameter */:
486
+ case 265 /* SyntaxKind.ClassDeclaration */:
487
+ case 266 /* SyntaxKind.InterfaceDeclaration */:
488
+ case 267 /* SyntaxKind.TypeAliasDeclaration */:
489
+ case 346 /* SyntaxKind.JSTypeAliasDeclaration */:
490
+ case 268 /* SyntaxKind.EnumDeclaration */:
425
491
  return true;
426
- case 274 /* SyntaxKind.ImportClause */:
427
- return isTypeOnly(node);
428
- case 277 /* SyntaxKind.ImportSpecifier */:
429
- case 282 /* SyntaxKind.ExportSpecifier */:
492
+ case 275 /* SyntaxKind.ImportClause */:
493
+ // `import type { a } from "m"` declares no type of its own.
494
+ return isTypeOnly(node) && node.name !== undefined;
495
+ case 278 /* SyntaxKind.ImportSpecifier */:
496
+ case 283 /* SyntaxKind.ExportSpecifier */:
430
497
  return isTypeOnly(node.parent.parent);
431
498
  }
432
499
  return false;
@@ -439,10 +506,10 @@ export function isAmbientModule(node) {
439
506
  }
440
507
  /** Whether `node` is a JavaScript `/** @type {T} *\/ (x)` cast, reparsed as a parenthesized `as` expression. */
441
508
  export function isJSDocTypeAssertion(node) {
442
- if (node.kind !== 218 /* SyntaxKind.ParenthesizedExpression */ || !isInJSFile(node))
509
+ if (node.kind !== 219 /* SyntaxKind.ParenthesizedExpression */ || !isInJSFile(node))
443
510
  return false;
444
511
  const expression = getExpression(node);
445
- if (expression === undefined || expression.kind !== 235 /* SyntaxKind.AsExpression */)
512
+ if (expression === undefined || expression.kind !== 236 /* SyntaxKind.AsExpression */)
446
513
  return false;
447
514
  const type = getType(expression);
448
515
  return type !== undefined && (type.flags & 8 /* NodeFlags.Reparsed */) !== 0;
@@ -452,11 +519,29 @@ export function getEffectiveCheckNode(argument) {
452
519
  const inJS = isInJSFile(argument);
453
520
  let node = argument;
454
521
  for (;;) {
455
- if (node.kind === 218 /* SyntaxKind.ParenthesizedExpression */ && !(inJS && isJSDocTypeAssertion(node)))
522
+ if (node.kind === 219 /* SyntaxKind.ParenthesizedExpression */ && !(inJS && isJSDocTypeAssertion(node)))
456
523
  node = getExpression(node);
457
- else if (node.kind === 239 /* SyntaxKind.SatisfiesExpression */)
524
+ else if (node.kind === 240 /* SyntaxKind.SatisfiesExpression */)
458
525
  node = getExpression(node);
459
526
  else
460
527
  return node;
461
528
  }
462
529
  }
530
+ /** The entity name of a heritage clause element: a type reference's type name, or an
531
+ * `ExpressionWithTypeArguments`'s expression. */
532
+ export function getHeritageClauseElementName(node) {
533
+ if (node.kind === 185 /* SyntaxKind.TypeReference */)
534
+ return node.typeName;
535
+ return getExpression(node);
536
+ }
537
+ /** Whether a name, or the rightmost name of a qualified name, is the type name of a type reference in a
538
+ * heritage clause. */
539
+ export function isNameOfHeritageClauseTypeReference(nodeIn) {
540
+ let node = nodeIn;
541
+ while (node.parent.kind === 168 /* SyntaxKind.QualifiedName */)
542
+ node = node.parent;
543
+ const parent = node.parent;
544
+ return (parent.kind === 185 /* SyntaxKind.TypeReference */ &&
545
+ parent.typeName === node &&
546
+ parent.parent?.kind === 300 /* SyntaxKind.HeritageClause */);
547
+ }