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
@@ -43,11 +43,26 @@ export declare abstract class ModuleSpecifierHost {
43
43
  /** For output paths of `package.json` `imports` targets. */
44
44
  abstract getOutputPathsHost(): OutputPathsHost;
45
45
  }
46
+ /** Where a module specifier came from: an existing import (None), `node_modules`, `paths`, a redirect, a relative path, or an ambient module. */
47
+ export declare const enum ModuleSpecifierResultKind {
48
+ None = 0,
49
+ NodeModules = 1,
50
+ Paths = 2,
51
+ Redirect = 3,
52
+ Relative = 4,
53
+ Ambient = 5
54
+ }
55
+ export interface ModuleSpecifiersResult {
56
+ readonly specifiers: string[];
57
+ readonly kind: ModuleSpecifierResultKind;
58
+ }
46
59
  /**
47
60
  * Specifiers `importingFile` can import `moduleFileName` with, best first, as tsgo's
48
61
  * `GetModuleSpecifiersForFileWithInfo`. `overrideImportMode` is `None` for the file's own mode.
49
62
  */
50
63
  export declare function getModuleSpecifiersForFile(importingFile: SourceFile, moduleFileName: string, options: CompilerOptions, host: ModuleSpecifierHost, preferences: ModuleSpecifierPreferences, overrideImportMode: ModuleKind, forAutoImports: boolean): string[];
64
+ /** The specifiers `getModuleSpecifiersForFile` gives, and where they came from. */
65
+ export declare function getModuleSpecifiersForFileWithInfo(importingFile: SourceFile, moduleFileName: string, options: CompilerOptions, host: ModuleSpecifierHost, preferences: ModuleSpecifierPreferences, overrideImportMode: ModuleKind, forAutoImports: boolean): ModuleSpecifiersResult;
51
66
  /** Number of `/` in a specifier, ignoring a leading `./`. */
52
67
  export declare function countPathComponents(path: string): number;
53
68
  /** The package name of a file or directory in `node_modules`, or `''`. */
@@ -65,12 +65,15 @@ class ResolvedPreferences {
65
65
  return getAllowedEndingsInPreferredOrder(this.preferences, this.host, this.options, this.importingFile, this.oldImportSpecifier, syntaxImpliedNodeFormat);
66
66
  }
67
67
  }
68
- //// Entry points
69
68
  /**
70
69
  * Specifiers `importingFile` can import `moduleFileName` with, best first, as tsgo's
71
70
  * `GetModuleSpecifiersForFileWithInfo`. `overrideImportMode` is `None` for the file's own mode.
72
71
  */
73
72
  export function getModuleSpecifiersForFile(importingFile, moduleFileName, options, host, preferences, overrideImportMode, forAutoImports) {
73
+ return getModuleSpecifiersForFileWithInfo(importingFile, moduleFileName, options, host, preferences, overrideImportMode, forAutoImports).specifiers;
74
+ }
75
+ /** The specifiers `getModuleSpecifiersForFile` gives, and where they came from. */
76
+ export function getModuleSpecifiersForFileWithInfo(importingFile, moduleFileName, options, host, preferences, overrideImportMode, forAutoImports) {
74
77
  const modulePaths = getAllModulePaths(new ImporterInfo(host.getSourceOfProjectReferenceIfOutputIncluded(importingFile), host.useCaseSensitiveFileNames()), moduleFileName, host);
75
78
  return computeModuleSpecifiers(modulePaths, options, importingFile, host, preferences, overrideImportMode, forAutoImports);
76
79
  }
@@ -231,7 +234,7 @@ function computeModuleSpecifiers(modulePaths, options, importingFile, host, user
231
234
  // An import resolved in another mode may not resolve the same way.
232
235
  if (existingMode !== targetMode && existingMode !== ModuleKind.None && targetMode !== ModuleKind.None)
233
236
  continue;
234
- return [text];
237
+ return { specifiers: [text], kind: 0 /* ModuleSpecifierResultKind.None */ };
235
238
  }
236
239
  let importedFileIsInNodeModules = false;
237
240
  for (const p of modulePaths)
@@ -251,7 +254,7 @@ function computeModuleSpecifiers(modulePaths, options, importingFile, host, user
251
254
  nodeModulesSpecifiers.push(specifier);
252
255
  // A specifier for a redirect is a bare package name; nothing beats it.
253
256
  if (modulePath.isRedirect)
254
- return nodeModulesSpecifiers;
257
+ return { specifiers: nodeModulesSpecifiers, kind: 1 /* ModuleSpecifierResultKind.NodeModules */ };
255
258
  }
256
259
  const local = getLocalModuleSpecifier(modulePath.fileName, info, options, host, targetMode, preferences, modulePath.isRedirect || specifier !== '');
257
260
  if (local === '')
@@ -275,12 +278,12 @@ function computeModuleSpecifiers(modulePaths, options, importingFile, host, user
275
278
  }
276
279
  }
277
280
  if (pathsSpecifiers.length > 0)
278
- return pathsSpecifiers;
281
+ return { specifiers: pathsSpecifiers, kind: 2 /* ModuleSpecifierResultKind.Paths */ };
279
282
  if (redirectPathsSpecifiers.length > 0)
280
- return redirectPathsSpecifiers;
283
+ return { specifiers: redirectPathsSpecifiers, kind: 3 /* ModuleSpecifierResultKind.Redirect */ };
281
284
  if (nodeModulesSpecifiers.length > 0)
282
- return nodeModulesSpecifiers;
283
- return relativeSpecifiers;
285
+ return { specifiers: nodeModulesSpecifiers, kind: 1 /* ModuleSpecifierResultKind.NodeModules */ };
286
+ return { specifiers: relativeSpecifiers, kind: 4 /* ModuleSpecifierResultKind.Relative */ };
284
287
  }
285
288
  /** A specifier through `paths`, `package.json` `imports`, `rootDirs` or a relative path. */
286
289
  function getLocalModuleSpecifier(moduleFileName, info, options, host, importMode, preferences, pathsOnly) {
@@ -489,9 +492,17 @@ function tryGetModuleNameAsNodeModule(modulePath, info, importingFile, host, opt
489
492
  const parts = getNodeModulePathParts(modulePath.fileName);
490
493
  if (parts === undefined)
491
494
  return '';
495
+ // Only a `node_modules` in the importing file's directory or above can be used, and not the global typings
496
+ // cache. This is checked before `exports`, which can give a bare specifier directly.
497
+ const caseSensitive = host.useCaseSensitiveFileNames();
498
+ const globalTypingsCacheLocation = host.getGlobalTypingsCacheLocation();
499
+ const pathToTopLevelNodeModules = modulePath.fileName.slice(0, parts.topLevelNodeModulesIndex);
500
+ if (!hasPrefix(info.sourceDirectory, pathToTopLevelNodeModules, caseSensitive) ||
501
+ (globalTypingsCacheLocation !== '' &&
502
+ hasPrefix(globalTypingsCacheLocation, pathToTopLevelNodeModules, caseSensitive)))
503
+ return '';
492
504
  const preferences = resolvePreferences(userPreferences, host, options, importingFile, '');
493
505
  const allowedEndings = preferences.allowedEndings(ModuleKind.None);
494
- const caseSensitive = host.useCaseSensitiveFileNames();
495
506
  let moduleSpecifier = modulePath.fileName;
496
507
  let isPackageRootPath = false;
497
508
  if (!packageNameOnly) {
@@ -512,14 +523,6 @@ function tryGetModuleNameAsNodeModule(modulePath, info, importingFile, host, opt
512
523
  }
513
524
  if (modulePath.isRedirect && !isPackageRootPath)
514
525
  return '';
515
- // Only a `node_modules` in the importing file's directory or above can be used, and not the
516
- // global typings cache.
517
- const globalTypingsCacheLocation = host.getGlobalTypingsCacheLocation();
518
- const pathToTopLevelNodeModules = moduleSpecifier.slice(0, parts.topLevelNodeModulesIndex);
519
- if (!hasPrefix(info.sourceDirectory, pathToTopLevelNodeModules, caseSensitive) ||
520
- (globalTypingsCacheLocation !== '' &&
521
- hasPrefix(globalTypingsCacheLocation, pathToTopLevelNodeModules, caseSensitive)))
522
- return '';
523
526
  // A package found in `@types` is imported by its own name.
524
527
  return getPackageNameFromTypesPackageName(moduleSpecifier.slice(parts.topLevelPackageNameIndex + 1));
525
528
  }
@@ -914,10 +917,13 @@ function getPreferredEnding(preferences, host, options, importingFile, oldImport
914
917
  /** The endings a specifier from `importingFile` may have, most preferred first. */
915
918
  export function getAllowedEndingsInPreferredOrder(preferences, host, options, importingFile, oldImportSpecifier, syntaxImpliedNodeFormat) {
916
919
  let preferred = getPreferredEnding(preferences, host, options, importingFile, oldImportSpecifier, ModuleKind.None);
917
- if (host.getDefaultResolutionModeForFile(importingFile) !== syntaxImpliedNodeFormat)
920
+ const resolutionMode = host.getDefaultResolutionModeForFile(importingFile);
921
+ if (resolutionMode !== syntaxImpliedNodeFormat)
918
922
  preferred = getPreferredEnding(preferences, host, options, importingFile, oldImportSpecifier, syntaxImpliedNodeFormat);
919
923
  const allowTs = shouldAllowImportingTsExtension(options, importingFile.fileName);
920
- if (syntaxImpliedNodeFormat === ModuleKind.ESNext && isNodeNext(options))
924
+ // Without a mode implied by the syntax, the file's default resolution mode applies.
925
+ const effectiveSyntaxMode = syntaxImpliedNodeFormat !== ModuleKind.None ? syntaxImpliedNodeFormat : resolutionMode;
926
+ if (effectiveSyntaxMode === ModuleKind.ESNext && isNodeNext(options))
921
927
  return allowTs
922
928
  ? [3 /* ModuleSpecifierEnding.TsExtension */, 2 /* ModuleSpecifierEnding.JsExtension */]
923
929
  : [2 /* ModuleSpecifierEnding.JsExtension */];
@@ -76,7 +76,7 @@ export class NameResolver {
76
76
  if (nameIsConst && isConstAssertion(current))
77
77
  return undefined;
78
78
  // From the name of a namespace or enum, skip its own scope: its locals could conflict.
79
- if ((current.kind === 268 /* SyntaxKind.ModuleDeclaration */ || current.kind === 267 /* SyntaxKind.EnumDeclaration */) &&
79
+ if ((current.kind === 269 /* SyntaxKind.ModuleDeclaration */ || current.kind === 268 /* SyntaxKind.EnumDeclaration */) &&
80
80
  lastLocation !== undefined &&
81
81
  getName(current) === lastLocation) {
82
82
  lastLocation = current;
@@ -84,25 +84,32 @@ export class NameResolver {
84
84
  if (current === undefined)
85
85
  break;
86
86
  }
87
+ // A module's import attributes type sees neither the module's locals nor its exports.
88
+ const isModuleAttributes = current.kind === 269 /* SyntaxKind.ModuleDeclaration */ &&
89
+ current.attributes !== undefined &&
90
+ lastLocation === current.attributes;
87
91
  const locals = getLocalsOf(current);
88
92
  // Locals of a global source file are merged into the globals.
89
93
  if (locals !== undefined && !isGlobalSourceFile(current)) {
90
94
  result = this.lookup(locals, name, meaning);
91
95
  if (result !== undefined) {
92
96
  let useResult = true;
93
- if (isFunctionLike(current) && lastLocation !== undefined && lastLocation !== getBody(current)) {
97
+ if (isModuleAttributes) {
98
+ useResult = false;
99
+ }
100
+ else if (isFunctionLike(current) && lastLocation !== undefined && lastLocation !== getBody(current)) {
94
101
  // Type parameters are in scope in the whole signature, but local types only in the
95
102
  // body; parameters only in the body, parameter list and return type. JSDoc types
96
103
  // are parented above type parameters, so this doesn't apply to them.
97
- if ((meaning & result.flags & 788968 /* SymbolFlags.Type */) !== 0 && lastLocation.kind !== 315 /* SyntaxKind.JSDoc */) {
104
+ if ((meaning & result.flags & 788968 /* SymbolFlags.Type */) !== 0 && lastLocation.kind !== 316 /* SyntaxKind.JSDoc */) {
98
105
  useResult =
99
106
  (result.flags & 262144 /* SymbolFlags.TypeParameter */) !== 0 &&
100
107
  ((lastLocation.flags & 16 /* NodeFlags.Synthesized */) !== 0 ||
101
108
  lastLocation === getType(current) ||
102
- lastLocation.kind === 170 /* SyntaxKind.Parameter */ ||
103
- lastLocation.kind === 333 /* SyntaxKind.JSDocParameterTag */ ||
104
- lastLocation.kind === 334 /* SyntaxKind.JSDocReturnTag */ ||
105
- lastLocation.kind === 169 /* SyntaxKind.TypeParameter */);
109
+ lastLocation.kind === 171 /* SyntaxKind.Parameter */ ||
110
+ lastLocation.kind === 334 /* SyntaxKind.JSDocParameterTag */ ||
111
+ lastLocation.kind === 335 /* SyntaxKind.JSDocReturnTag */ ||
112
+ lastLocation.kind === 170 /* SyntaxKind.TypeParameter */);
106
113
  }
107
114
  if ((meaning & result.flags & 3 /* SymbolFlags.Variable */) !== 0) {
108
115
  if (this.useOuterVariableScopeInParameter(result, current, lastLocation))
@@ -110,7 +117,7 @@ export class NameResolver {
110
117
  else if ((result.flags & 1 /* SymbolFlags.FunctionScopedVariable */) !== 0) {
111
118
  // Initializers referencing later parameters are checked separately.
112
119
  useResult =
113
- lastLocation.kind === 170 /* SyntaxKind.Parameter */ ||
120
+ lastLocation.kind === 171 /* SyntaxKind.Parameter */ ||
114
121
  (lastLocation.flags & 16 /* NodeFlags.Synthesized */) !== 0 ||
115
122
  (lastLocation === getType(current) && isInParameter(result.valueDeclaration));
116
123
  }
@@ -127,15 +134,17 @@ export class NameResolver {
127
134
  }
128
135
  withinDeferredContext = withinDeferredContext || isDeferredContext(current, lastLocation);
129
136
  switch (current.kind) {
130
- case 307 /* SyntaxKind.SourceFile */:
131
- case 268 /* SyntaxKind.ModuleDeclaration */: {
132
- if (current.kind === 307 /* SyntaxKind.SourceFile */ && !isExternalOrCommonJSModule(current))
137
+ case 308 /* SyntaxKind.SourceFile */:
138
+ case 269 /* SyntaxKind.ModuleDeclaration */: {
139
+ if (current.kind === 308 /* SyntaxKind.SourceFile */ && !isExternalOrCommonJSModule(current))
140
+ break;
141
+ if (isModuleAttributes)
133
142
  break;
134
143
  const moduleSymbol = this.getSymbolOfDeclaration(current);
135
144
  if (moduleSymbol === undefined)
136
145
  break;
137
146
  const moduleExports = moduleSymbol.exports ?? emptyTable;
138
- if (current.kind === 307 /* SyntaxKind.SourceFile */ ||
147
+ if (current.kind === 308 /* SyntaxKind.SourceFile */ ||
139
148
  ((current.flags & 8388608 /* NodeFlags.Ambient */) !== 0 && !isGlobalScopeAugmentationNode(current))) {
140
149
  // An external module: the local name of its default export is in scope.
141
150
  result = moduleExports.get("default" /* InternalSymbolName.Default */);
@@ -150,14 +159,14 @@ export class NameResolver {
150
159
  const moduleExport = moduleExports.get(name);
151
160
  if (moduleExport !== undefined &&
152
161
  moduleExport.flags === 2097152 /* SymbolFlags.Alias */ &&
153
- (getDeclarationOfKind(moduleExport, 282 /* SyntaxKind.ExportSpecifier */) !== undefined ||
154
- getDeclarationOfKind(moduleExport, 281 /* SyntaxKind.NamespaceExport */) !== undefined))
162
+ (getDeclarationOfKind(moduleExport, 283 /* SyntaxKind.ExportSpecifier */) !== undefined ||
163
+ getDeclarationOfKind(moduleExport, 282 /* SyntaxKind.NamespaceExport */) !== undefined))
155
164
  break;
156
165
  }
157
166
  if (name !== "default" /* InternalSymbolName.Default */) {
158
167
  result = this.lookup(moduleExports, name, meaning & 2623475 /* SymbolFlags.ModuleMember */);
159
168
  if (result !== undefined) {
160
- if (current.kind === 307 /* SyntaxKind.SourceFile */ &&
169
+ if (current.kind === 308 /* SyntaxKind.SourceFile */ &&
161
170
  current.commonJSModuleIndicator !== undefined &&
162
171
  (result.flags & 788968 /* SymbolFlags.Type */) === 0)
163
172
  result = undefined;
@@ -167,7 +176,7 @@ export class NameResolver {
167
176
  }
168
177
  break;
169
178
  }
170
- case 267 /* SyntaxKind.EnumDeclaration */: {
179
+ case 268 /* SyntaxKind.EnumDeclaration */: {
171
180
  const enumSymbol = this.getSymbolOfDeclaration(current);
172
181
  if (enumSymbol === undefined)
173
182
  break;
@@ -185,7 +194,7 @@ export class NameResolver {
185
194
  }
186
195
  break;
187
196
  }
188
- case 173 /* SyntaxKind.PropertyDeclaration */:
197
+ case 174 /* SyntaxKind.PropertyDeclaration */:
189
198
  if (!isStatic(current)) {
190
199
  const ctor = findConstructorDeclaration(current.parent);
191
200
  if (ctor !== undefined) {
@@ -196,9 +205,9 @@ export class NameResolver {
196
205
  }
197
206
  }
198
207
  break;
199
- case 264 /* SyntaxKind.ClassDeclaration */:
200
- case 232 /* SyntaxKind.ClassExpression */:
201
- case 265 /* SyntaxKind.InterfaceDeclaration */: {
208
+ case 265 /* SyntaxKind.ClassDeclaration */:
209
+ case 233 /* SyntaxKind.ClassExpression */:
210
+ case 266 /* SyntaxKind.InterfaceDeclaration */: {
202
211
  const classSymbol = this.getSymbolOfDeclaration(current);
203
212
  result =
204
213
  classSymbol === undefined
@@ -213,12 +222,12 @@ export class NameResolver {
213
222
  // Type parameters aren't in scope in static members.
214
223
  if (lastLocation !== undefined && isStatic(lastLocation)) {
215
224
  if (nameNotFoundMessage !== undefined)
216
- this.error(originalLocation, 480 /* Diagnostics.Static_members_cannot_reference_class_type_parameters */, noArgs);
225
+ this.error(originalLocation, 487 /* Diagnostics.Static_members_cannot_reference_class_type_parameters */, noArgs);
217
226
  return undefined;
218
227
  }
219
228
  break loop;
220
229
  }
221
- if (current.kind === 232 /* SyntaxKind.ClassExpression */ && (meaning & 32 /* SymbolFlags.Class */) !== 0) {
230
+ if (current.kind === 233 /* SyntaxKind.ClassExpression */ && (meaning & 32 /* SymbolFlags.Class */) !== 0) {
222
231
  const className = getName(current);
223
232
  if (className !== undefined && name === getText(className)) {
224
233
  result = symbolOfNode(current);
@@ -227,7 +236,7 @@ export class NameResolver {
227
236
  }
228
237
  break;
229
238
  }
230
- case 234 /* SyntaxKind.ExpressionWithTypeArguments */: {
239
+ case 235 /* SyntaxKind.ExpressionWithTypeArguments */: {
231
240
  const heritage = current.parent;
232
241
  if (lastLocation === current.expression &&
233
242
  heritage instanceof HeritageClause &&
@@ -241,17 +250,17 @@ export class NameResolver {
241
250
  : this.lookup(classSymbol.members ?? emptyTable, name, meaning & 788968 /* SymbolFlags.Type */);
242
251
  if (result !== undefined) {
243
252
  if (nameNotFoundMessage !== undefined)
244
- this.error(originalLocation, 716 /* Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters */, noArgs);
253
+ this.error(originalLocation, 723 /* Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters */, noArgs);
245
254
  return undefined;
246
255
  }
247
256
  }
248
257
  }
249
258
  break;
250
259
  }
251
- case 168 /* SyntaxKind.ComputedPropertyName */: {
260
+ case 169 /* SyntaxKind.ComputedPropertyName */: {
252
261
  // A class's computed property names can't reference its own type parameters.
253
262
  const grandparent = current.parent.parent;
254
- if (isClassLike(grandparent) || grandparent.kind === 265 /* SyntaxKind.InterfaceDeclaration */) {
263
+ if (isClassLike(grandparent) || grandparent.kind === 266 /* SyntaxKind.InterfaceDeclaration */) {
255
264
  const containerSymbol = this.getSymbolOfDeclaration(grandparent);
256
265
  result =
257
266
  containerSymbol === undefined
@@ -259,23 +268,23 @@ export class NameResolver {
259
268
  : this.lookup(containerSymbol.members ?? emptyTable, name, meaning & 788968 /* SymbolFlags.Type */);
260
269
  if (result !== undefined) {
261
270
  if (nameNotFoundMessage !== undefined)
262
- this.error(originalLocation, 633 /* Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type */, noArgs);
271
+ this.error(originalLocation, 640 /* Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type */, noArgs);
263
272
  return undefined;
264
273
  }
265
274
  }
266
275
  break;
267
276
  }
268
- case 175 /* SyntaxKind.MethodDeclaration */:
269
- case 177 /* SyntaxKind.Constructor */:
270
- case 178 /* SyntaxKind.GetAccessor */:
271
- case 179 /* SyntaxKind.SetAccessor */:
272
- case 263 /* SyntaxKind.FunctionDeclaration */:
277
+ case 176 /* SyntaxKind.MethodDeclaration */:
278
+ case 178 /* SyntaxKind.Constructor */:
279
+ case 179 /* SyntaxKind.GetAccessor */:
280
+ case 180 /* SyntaxKind.SetAccessor */:
281
+ case 264 /* SyntaxKind.FunctionDeclaration */:
273
282
  if ((meaning & 3 /* SymbolFlags.Variable */) !== 0 && name === 'arguments') {
274
283
  result = this.getArgumentsSymbol();
275
284
  break loop;
276
285
  }
277
286
  break;
278
- case 219 /* SyntaxKind.FunctionExpression */: {
287
+ case 220 /* SyntaxKind.FunctionExpression */: {
279
288
  if ((meaning & 3 /* SymbolFlags.Variable */) !== 0 && name === 'arguments') {
280
289
  result = this.getArgumentsSymbol();
281
290
  break loop;
@@ -287,18 +296,18 @@ export class NameResolver {
287
296
  }
288
297
  break;
289
298
  }
290
- case 171 /* SyntaxKind.Decorator */: {
299
+ case 172 /* SyntaxKind.Decorator */: {
291
300
  // Decorators resolve at the class: a parameter's at its class member, a member's at the class.
292
301
  let parent = current.parent;
293
- if (parent !== undefined && parent.kind === 170 /* SyntaxKind.Parameter */) {
302
+ if (parent !== undefined && parent.kind === 171 /* SyntaxKind.Parameter */) {
294
303
  current = parent;
295
304
  parent = current.parent;
296
305
  }
297
- if (parent !== undefined && (isClassElement(parent) || parent.kind === 264 /* SyntaxKind.ClassDeclaration */))
306
+ if (parent !== undefined && (isClassElement(parent) || parent.kind === 265 /* SyntaxKind.ClassDeclaration */))
298
307
  current = parent;
299
308
  break;
300
309
  }
301
- case 170 /* SyntaxKind.Parameter */: {
310
+ case 171 /* SyntaxKind.Parameter */: {
302
311
  const parameter = current;
303
312
  if (lastLocation !== undefined &&
304
313
  (lastLocation === parameter.initializer ||
@@ -307,7 +316,7 @@ export class NameResolver {
307
316
  associatedDeclarationForContainingInitializerOrBindingName = current;
308
317
  break;
309
318
  }
310
- case 209 /* SyntaxKind.BindingElement */: {
319
+ case 210 /* SyntaxKind.BindingElement */: {
311
320
  const element = current;
312
321
  if (lastLocation !== undefined &&
313
322
  (lastLocation === element.initializer ||
@@ -317,7 +326,7 @@ export class NameResolver {
317
326
  associatedDeclarationForContainingInitializerOrBindingName = current;
318
327
  break;
319
328
  }
320
- case 196 /* SyntaxKind.InferType */:
329
+ case 197 /* SyntaxKind.InferType */:
321
330
  if ((meaning & 262144 /* SymbolFlags.TypeParameter */) !== 0) {
322
331
  const typeParameter = current.typeParameter;
323
332
  if (name === typeParameter.name.text) {
@@ -326,7 +335,7 @@ export class NameResolver {
326
335
  }
327
336
  }
328
337
  break;
329
- case 282 /* SyntaxKind.ExportSpecifier */: {
338
+ case 283 /* SyntaxKind.ExportSpecifier */: {
330
339
  // `export { a as b } from "m"`: `a` resolves outside this module.
331
340
  const specifier = current;
332
341
  const exportDeclaration = current.parent.parent;
@@ -371,7 +380,7 @@ export class NameResolver {
371
380
  * aren't in scope there unless emit moves the parameter into the body.
372
381
  */
373
382
  useOuterVariableScopeInParameter(result, location, lastLocation) {
374
- if (lastLocation.kind !== 170 /* SyntaxKind.Parameter */)
383
+ if (lastLocation.kind !== 171 /* SyntaxKind.Parameter */)
375
384
  return false;
376
385
  const body = getBody(location);
377
386
  const declaration = result.valueDeclaration;
@@ -407,17 +416,17 @@ class ScopeChangeFinder extends NodeVisitor {
407
416
  }
408
417
  requiresScopeChange(node) {
409
418
  switch (node.kind) {
410
- case 220 /* SyntaxKind.ArrowFunction */:
411
- case 219 /* SyntaxKind.FunctionExpression */:
412
- case 263 /* SyntaxKind.FunctionDeclaration */:
413
- case 177 /* SyntaxKind.Constructor */:
419
+ case 221 /* SyntaxKind.ArrowFunction */:
420
+ case 220 /* SyntaxKind.FunctionExpression */:
421
+ case 264 /* SyntaxKind.FunctionDeclaration */:
422
+ case 178 /* SyntaxKind.Constructor */:
414
423
  return false;
415
- case 175 /* SyntaxKind.MethodDeclaration */:
416
- case 178 /* SyntaxKind.GetAccessor */:
417
- case 179 /* SyntaxKind.SetAccessor */:
418
- case 303 /* SyntaxKind.PropertyAssignment */:
424
+ case 176 /* SyntaxKind.MethodDeclaration */:
425
+ case 179 /* SyntaxKind.GetAccessor */:
426
+ case 180 /* SyntaxKind.SetAccessor */:
427
+ case 304 /* SyntaxKind.PropertyAssignment */:
419
428
  return this.requiresScopeChange(getName(node));
420
- case 173 /* SyntaxKind.PropertyDeclaration */:
429
+ case 174 /* SyntaxKind.PropertyDeclaration */:
421
430
  if (hasStaticModifier(node))
422
431
  return !getEmitStandardClassFields(this.options);
423
432
  return this.requiresScopeChange(getName(node));
@@ -426,7 +435,7 @@ class ScopeChangeFinder extends NodeVisitor {
426
435
  return getEmitScriptTarget(this.options) < 7 /* ScriptTarget.ES2020 */;
427
436
  if (node instanceof BindingElement &&
428
437
  node.dotDotDotToken !== undefined &&
429
- node.parent.kind === 207 /* SyntaxKind.ObjectBindingPattern */)
438
+ node.parent.kind === 208 /* SyntaxKind.ObjectBindingPattern */)
430
439
  return getEmitScriptTarget(this.options) < 4 /* ScriptTarget.ES2017 */;
431
440
  if (isTypeNodeKind(node.kind))
432
441
  return false;
@@ -446,14 +455,14 @@ function getLocalsOf(node) {
446
455
  return getLocals(node);
447
456
  }
448
457
  function isBindingPattern(node) {
449
- return node.kind === 207 /* SyntaxKind.ObjectBindingPattern */ || node.kind === 208 /* SyntaxKind.ArrayBindingPattern */;
458
+ return node.kind === 208 /* SyntaxKind.ObjectBindingPattern */ || node.kind === 209 /* SyntaxKind.ArrayBindingPattern */;
450
459
  }
451
460
  function isGlobalScopeAugmentationNode(node) {
452
461
  return node instanceof ModuleDeclaration && node.keyword === 162 /* SyntaxKind.GlobalKeyword */;
453
462
  }
454
463
  function isInParameter(declaration) {
455
464
  for (let current = declaration; current !== undefined; current = current.parent)
456
- if (current.kind === 170 /* SyntaxKind.Parameter */)
465
+ if (current.kind === 171 /* SyntaxKind.Parameter */)
457
466
  return true;
458
467
  return false;
459
468
  }
@@ -471,11 +480,11 @@ export function getLocalSymbolForExportDefault(symbol) {
471
480
  }
472
481
  /** Whether a reference at `location` runs later than its scope's own code, like in a function body. */
473
482
  function isDeferredContext(location, lastLocation) {
474
- if (location.kind !== 220 /* SyntaxKind.ArrowFunction */ && location.kind !== 219 /* SyntaxKind.FunctionExpression */) {
483
+ if (location.kind !== 221 /* SyntaxKind.ArrowFunction */ && location.kind !== 220 /* SyntaxKind.FunctionExpression */) {
475
484
  // Instance property initializers run in the constructor; a declaration's name runs in its scope.
476
- return (location.kind === 187 /* SyntaxKind.TypeQuery */ ||
485
+ return (location.kind === 188 /* SyntaxKind.TypeQuery */ ||
477
486
  ((isFunctionLikeDeclarationKind(location.kind) ||
478
- (location.kind === 173 /* SyntaxKind.PropertyDeclaration */ && !isStatic(location))) &&
487
+ (location.kind === 174 /* SyntaxKind.PropertyDeclaration */ && !isStatic(location))) &&
479
488
  (lastLocation === undefined || lastLocation !== getName(location))));
480
489
  }
481
490
  if (lastLocation !== undefined && lastLocation === getName(location))
@@ -487,21 +496,21 @@ function isDeferredContext(location, lastLocation) {
487
496
  }
488
497
  function isTypeParameterSymbolDeclaredInContainer(symbol, container) {
489
498
  for (const declaration of getDeclarations(symbol))
490
- if (declaration.kind === 169 /* SyntaxKind.TypeParameter */ && declaration.parent === container)
499
+ if (declaration.kind === 170 /* SyntaxKind.TypeParameter */ && declaration.parent === container)
491
500
  return true;
492
501
  return false;
493
502
  }
494
503
  function isSelfReferenceLocation(node, lastLocation) {
495
504
  switch (node.kind) {
496
- case 170 /* SyntaxKind.Parameter */:
505
+ case 171 /* SyntaxKind.Parameter */:
497
506
  return lastLocation !== undefined && lastLocation === getName(node);
498
- case 263 /* SyntaxKind.FunctionDeclaration */:
499
- case 264 /* SyntaxKind.ClassDeclaration */:
500
- case 265 /* SyntaxKind.InterfaceDeclaration */:
501
- case 267 /* SyntaxKind.EnumDeclaration */:
502
- case 266 /* SyntaxKind.TypeAliasDeclaration */:
503
- case 345 /* SyntaxKind.JSTypeAliasDeclaration */:
504
- case 268 /* SyntaxKind.ModuleDeclaration */:
507
+ case 264 /* SyntaxKind.FunctionDeclaration */:
508
+ case 265 /* SyntaxKind.ClassDeclaration */:
509
+ case 266 /* SyntaxKind.InterfaceDeclaration */:
510
+ case 268 /* SyntaxKind.EnumDeclaration */:
511
+ case 267 /* SyntaxKind.TypeAliasDeclaration */:
512
+ case 346 /* SyntaxKind.JSTypeAliasDeclaration */:
513
+ case 269 /* SyntaxKind.ModuleDeclaration */:
505
514
  // `namespace N { N; }`
506
515
  return true;
507
516
  }
@@ -1,4 +1,5 @@
1
1
  import { type Node, type NodeList, SourceFile } from './ast.js';
2
+ import { type Type } from './checker-types.js';
2
3
  import type { Checker } from './checker.js';
3
4
  import { ModuleSpecifierPreferences } from './module-specifiers.js';
4
5
  import { ModuleKind } from './options.js';
@@ -21,12 +22,19 @@ export declare function symbolToExpression(b: NodeBuilder, symbol: Symbol, meani
21
22
  */
22
23
  export declare function getNameOfSymbolAsWritten(b: NodeBuilder, symbol: Symbol): string;
23
24
  /** The name node of a property. */
24
- export declare function getPropertyNameNodeForSymbol(b: NodeBuilder, symbol: Symbol): Node;
25
+ export declare function getPropertyNameNodeForSymbol(b: NodeBuilder, symbol: Symbol, enclosingDeclaration: Node | undefined): Node;
26
+ /** A module specifier, and the import attributes type an `import()` type with it needs. */
27
+ export declare class ModuleSpecifierResult {
28
+ readonly specifier: string;
29
+ readonly importAttributesType: Type | undefined;
30
+ constructor(specifier: string, importAttributesType: Type | undefined);
31
+ }
25
32
  /**
26
33
  * The specifier an `import("…")` type names a module with: an ambient module's name, the file
27
34
  * name without an enclosing file, else what module specifier generation gives for the enclosing
28
- * file. `overrideImportMode` is `None` for the mode of the enclosing import or file.
35
+ * file. `overrideImportMode` is `None` for the mode of the enclosing import or file. A pattern
36
+ * ambient module's specifier comes with the attributes type that resolves it.
29
37
  */
30
- export declare function getSpecifierForModuleSymbol(b: NodeBuilder, symbol: Symbol, overrideImportMode: ModuleKind): string;
38
+ export declare function getSpecifierForModuleSymbol(b: NodeBuilder, symbol: Symbol, overrideImportMode: ModuleKind): ModuleSpecifierResult;
31
39
  /** Specifiers `importingFile` can import the module `moduleSymbol` with, best first. */
32
40
  export declare function getModuleSpecifiers(c: Checker, moduleSymbol: Symbol, importingFile: SourceFile, preferences: ModuleSpecifierPreferences, overrideImportMode: ModuleKind): string[];