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
@@ -176,9 +176,12 @@ export class Resolver {
176
176
  /**
177
177
  * Called before the resolver is shared with other threads, which makes it immutable
178
178
  * (parallel-check.ts): from then on, each thread caches the results and `package.json` lookups the
179
- * resolver did not have yet in tables of its own.
179
+ * resolver did not have yet in tables of its own. A resolver already shared (by an earlier program of
180
+ * a watch, which a rebuild updates: `Program.updateFile`) is immutable and stays as it is.
180
181
  */
181
182
  prepareForSharing() {
183
+ if (this.shared)
184
+ return;
182
185
  this.getPathPatterns();
183
186
  this.packageJsonInfoCache.prepareForSharing();
184
187
  this.shared = true;
@@ -241,24 +244,24 @@ export class Resolver {
241
244
  return cached;
242
245
  }
243
246
  const options = optionsWithRedirect(this.options, redirect);
244
- tracer?.push(messageWithArgs(1255 /* Diagnostics.Resolving_module_0_from_1 */, moduleName, containingFile));
247
+ tracer?.push(messageWithArgs(1266 /* Diagnostics.Resolving_module_0_from_1 */, moduleName, containingFile));
245
248
  if (tracer !== undefined)
246
249
  traceRedirect(tracer, redirect);
247
250
  const kind = getModuleResolutionKind(options);
248
251
  tracer?.push(options.moduleResolution !== kind
249
- ? messageWithArgs(1257 /* Diagnostics.Module_resolution_kind_is_not_specified_using_0 */, moduleResolutionKindName(kind))
250
- : messageWithArgs(1256 /* Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0 */, moduleResolutionKindName(kind)));
252
+ ? messageWithArgs(1268 /* Diagnostics.Module_resolution_kind_is_not_specified_using_0 */, moduleResolutionKindName(kind))
253
+ : messageWithArgs(1267 /* Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0 */, moduleResolutionKindName(kind)));
251
254
  const state = new ResolutionState(this, tracer, moduleName, containingDirectory, false, mode, options);
252
255
  const result = state.resolveNodeLike();
253
256
  if (tracer !== undefined) {
254
257
  if (result.resolvedFileName === '') {
255
- tracer.push(messageWithArgs(1259 /* Diagnostics.Module_name_0_was_not_resolved */, moduleName));
258
+ tracer.push(messageWithArgs(1270 /* Diagnostics.Module_name_0_was_not_resolved */, moduleName));
256
259
  }
257
260
  else if (result.packageId !== undefined) {
258
- tracer.push(messageWithArgs(1371 /* Diagnostics.Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2 */, moduleName, result.resolvedFileName, packageIdToString(result.packageId)));
261
+ tracer.push(messageWithArgs(1382 /* Diagnostics.Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2 */, moduleName, result.resolvedFileName, packageIdToString(result.packageId)));
259
262
  }
260
263
  else {
261
- tracer.push(messageWithArgs(1258 /* Diagnostics.Module_name_0_was_successfully_resolved_to_1 */, moduleName, result.resolvedFileName));
264
+ tracer.push(messageWithArgs(1269 /* Diagnostics.Module_name_0_was_successfully_resolved_to_1 */, moduleName, result.resolvedFileName));
262
265
  }
263
266
  }
264
267
  const final = this.tryResolveFromTypingsLocation(moduleName, containingDirectory, result, tracer);
@@ -287,20 +290,20 @@ export class Resolver {
287
290
  const typeRoots = getEffectiveTypeRoots(options, this.host.getCurrentDirectory());
288
291
  const fromConfig = options.typeRoots !== undefined;
289
292
  if (tracer !== undefined) {
290
- tracer.push(messageWithArgs(1284 /* Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2 */, name, containingFile, typeRoots.join(',')));
293
+ tracer.push(messageWithArgs(1295 /* Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2 */, name, containingFile, typeRoots.join(',')));
291
294
  traceRedirect(tracer, redirect);
292
295
  }
293
296
  const state = new ResolutionState(this, tracer, name, containingDirectory, true, mode, options);
294
297
  const result = state.resolveTypeReferenceDirective(typeRoots, fromConfig, fromInferredTypes);
295
298
  if (tracer !== undefined) {
296
299
  if (result.resolvedFileName === '') {
297
- tracer.push(messageWithArgs(1286 /* Diagnostics.Type_reference_directive_0_was_not_resolved */, name));
300
+ tracer.push(messageWithArgs(1297 /* Diagnostics.Type_reference_directive_0_was_not_resolved */, name));
298
301
  }
299
302
  else if (result.packageId !== undefined) {
300
- tracer.push(messageWithArgs(1372 /* Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3 */, name, result.resolvedFileName, packageIdToString(result.packageId), String(result.primary)));
303
+ tracer.push(messageWithArgs(1383 /* Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3 */, name, result.resolvedFileName, packageIdToString(result.packageId), String(result.primary)));
301
304
  }
302
305
  else {
303
- tracer.push(messageWithArgs(1285 /* Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2 */, name, result.resolvedFileName, String(result.primary)));
306
+ tracer.push(messageWithArgs(1296 /* Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2 */, name, result.resolvedFileName, String(result.primary)));
304
307
  }
305
308
  }
306
309
  this.cacheTypeReference(cacheKey, result);
@@ -321,6 +324,24 @@ export class Resolver {
321
324
  const state = new ResolutionState(this, undefined, '', directory, false, ModuleKind.None, this.options);
322
325
  return state.getPackageScopeForPath(directory);
323
326
  }
327
+ /**
328
+ * The TypeScript or declaration file a package's directory loads (its `typings`, `types` or `main` field, or
329
+ * an index file), as tsgo finds a package's main entrypoint; `''` for none.
330
+ */
331
+ loadPackageMainEntrypoint(info) {
332
+ const state = this.entrypointState(info.packageDirectory);
333
+ return state.loadPackageMainEntrypoint(info);
334
+ }
335
+ /** The TypeScript or declaration file an `exports` target path of a package loads; `''` for none. */
336
+ loadPackageExportTargetEntrypoint(packageDirectory, candidate, target) {
337
+ return this.entrypointState(packageDirectory).loadPackageExportTargetEntrypoint(candidate, target);
338
+ }
339
+ entrypointState(packageDirectory) {
340
+ const state = new ResolutionState(this, undefined, '', packageDirectory, false, ModuleKind.None, this.options);
341
+ state.extensions = 1 /* Extensions.TypeScript */ | 4 /* Extensions.Declaration */;
342
+ state.features = 31 /* Features.All */;
343
+ return state;
344
+ }
324
345
  /** Resolves an `extends` specifier of a tsconfig file. */
325
346
  resolveConfig(moduleName, containingFile) {
326
347
  const state = new ResolutionState(this, undefined, moduleName, getDirectoryPath(containingFile), false, ModuleKind.CommonJS, this.options);
@@ -335,7 +356,7 @@ export class Resolver {
335
356
  return original;
336
357
  }
337
358
  const state = new ResolutionState(this, tracer, moduleName, containingDirectory, false, ModuleKind.None, this.options);
338
- tracer?.push(messageWithArgs(1305 /* Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2 */, this.projectName, moduleName, this.typingsLocation));
359
+ tracer?.push(messageWithArgs(1316 /* Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2 */, this.projectName, moduleName, this.typingsLocation));
339
360
  const global = state.loadModuleFromImmediateNodeModulesDirectory(4 /* Extensions.Declaration */, this.typingsLocation, false);
340
361
  if (global === undefined)
341
362
  return original;
@@ -349,7 +370,7 @@ function optionsWithRedirect(options, redirect) {
349
370
  }
350
371
  function traceRedirect(tracer, redirect) {
351
372
  if (redirect !== undefined && redirect.options !== undefined) {
352
- tracer.push(messageWithArgs(1368 /* Diagnostics.Using_compiler_options_of_project_reference_redirect_0 */, redirect.configName));
373
+ tracer.push(messageWithArgs(1379 /* Diagnostics.Using_compiler_options_of_project_reference_redirect_0 */, redirect.configName));
353
374
  }
354
375
  }
355
376
  /** Resolves an `extends` specifier of a tsconfig file with `nodenext` rules. */
@@ -460,16 +481,17 @@ class ResolutionState {
460
481
  const traces = this.traces;
461
482
  if (typeRoots.length > 0) {
462
483
  if (traces !== undefined)
463
- this.trace(1287 /* Diagnostics.Resolving_with_primary_search_path_0 */, typeRoots.join(', '));
484
+ this.trace(1298 /* Diagnostics.Resolving_with_primary_search_path_0 */, typeRoots.join(', '));
464
485
  for (const typeRoot of typeRoots) {
465
486
  const candidate = this.getCandidateFromTypeRoot(typeRoot);
466
487
  if (!this.host.directoryExists(typeRoot)) {
467
488
  if (traces !== undefined)
468
- this.trace(1311 /* Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it */, typeRoot);
489
+ this.trace(1322 /* Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it */, typeRoot);
469
490
  continue;
470
491
  }
471
- if (fromConfig) {
472
- // Configured type roots resolve as files or directories, like modules.
492
+ // Configured type roots resolve as files or directories, like modules; a name ending in a separator
493
+ // only as a directory.
494
+ if (fromConfig && !hasTrailingDirectorySeparator(candidate)) {
473
495
  const fromFile = this.loadModuleFromFile(4 /* Extensions.Declaration */, candidate);
474
496
  if (fromFile !== undefined) {
475
497
  this.setPackageIdFromNodeModulesPath(fromFile);
@@ -482,12 +504,12 @@ class ResolutionState {
482
504
  }
483
505
  }
484
506
  else if (traces !== undefined) {
485
- this.trace(1288 /* Diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths */);
507
+ this.trace(1299 /* Diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths */);
486
508
  }
487
509
  let resolved;
488
510
  if (!fromConfig || !fromInferredTypes) {
489
511
  if (traces !== undefined)
490
- this.trace(1291 /* Diagnostics.Looking_up_in_node_modules_folder_initial_location_0 */, this.containingDirectory);
512
+ this.trace(1302 /* Diagnostics.Looking_up_in_node_modules_folder_initial_location_0 */, this.containingDirectory);
491
513
  if (!isExternalModuleNameRelative(this.name)) {
492
514
  resolved = this.loadModuleFromNearestNodeModulesDirectory(false);
493
515
  }
@@ -497,7 +519,7 @@ class ResolutionState {
497
519
  }
498
520
  }
499
521
  else if (traces !== undefined) {
500
- this.trace(1417 /* Diagnostics.Resolving_type_reference_directive_for_program_that_specifies_custom_typeRoots_skipping_lookup_in_node_modules_folder */);
522
+ this.trace(1428 /* Diagnostics.Resolving_type_reference_directive_for_program_that_specifies_custom_typeRoots_skipping_lookup_in_node_modules_folder */);
501
523
  }
502
524
  return this.createResolvedTypeReferenceDirective(resolved, false);
503
525
  }
@@ -507,16 +529,17 @@ class ResolutionState {
507
529
  resolved.packageId = this.getPackageId(resolved.path, this.getPackageJsonInfo(packageDirectory));
508
530
  }
509
531
  }
532
+ /** The type root's path for the name, resolved against the type root as tsgo does: `./css` in it is `css`. */
510
533
  getCandidateFromTypeRoot(typeRoot) {
511
534
  const name = typeRoot.endsWith('/node_modules/@types') || typeRoot.endsWith('/node_modules/@types/')
512
535
  ? this.mangleScopedPackageName(this.name)
513
536
  : this.name;
514
- return combinePaths(typeRoot, name);
537
+ return normalizePath(combinePaths(typeRoot, name));
515
538
  }
516
539
  mangleScopedPackageName(name) {
517
540
  const mangled = mangleScopedPackageName(name);
518
541
  if (this.traces !== undefined && mangled !== name)
519
- this.trace(1337 /* Diagnostics.Scoped_package_detected_looking_in_0 */, mangled);
542
+ this.trace(1348 /* Diagnostics.Scoped_package_detected_looking_in_0 */, mangled);
520
543
  return mangled;
521
544
  }
522
545
  /** Falls back to configured `typeRoots` for declaration lookups of bare names. */
@@ -528,13 +551,15 @@ class ResolutionState {
528
551
  const candidate = this.getCandidateFromTypeRoot(typeRoot);
529
552
  if (!this.host.directoryExists(typeRoot)) {
530
553
  if (this.traces !== undefined)
531
- this.trace(1311 /* Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it */, typeRoot);
554
+ this.trace(1322 /* Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it */, typeRoot);
532
555
  continue;
533
556
  }
534
- const fromFile = this.loadModuleFromFile(4 /* Extensions.Declaration */, candidate);
535
- if (fromFile !== undefined) {
536
- this.setPackageIdFromNodeModulesPath(fromFile);
537
- return fromFile;
557
+ if (!hasTrailingDirectorySeparator(candidate)) {
558
+ const fromFile = this.loadModuleFromFile(4 /* Extensions.Declaration */, candidate);
559
+ if (fromFile !== undefined) {
560
+ this.setPackageIdFromNodeModulesPath(fromFile);
561
+ return fromFile;
562
+ }
538
563
  }
539
564
  const fromDirectory = this.loadNodeModuleFromDirectory(4 /* Extensions.Declaration */, candidate, true);
540
565
  if (fromDirectory !== undefined)
@@ -558,7 +583,7 @@ class ResolutionState {
558
583
  resolveNodeLike() {
559
584
  if (this.traces !== undefined) {
560
585
  const conditions = this.conditions.map((c) => "'" + c + "'").join(', ');
561
- this.trace(1492 /* Diagnostics.Resolving_in_0_mode_with_conditions_1 */, this.esmMode ? 'ESM' : 'CJS', conditions);
586
+ this.trace(1503 /* Diagnostics.Resolving_in_0_mode_with_conditions_1 */, this.esmMode ? 'ESM' : 'CJS', conditions);
562
587
  }
563
588
  const result = this.resolveNodeLikeWorker();
564
589
  if (this.resolvedPackageDirectory &&
@@ -572,7 +597,7 @@ class ResolutionState {
572
597
  this.conditions.includes('import')) {
573
598
  // Find out whether the package would resolve to types without `exports`, to suggest a fix.
574
599
  if (this.traces !== undefined) {
575
- this.trace(1426 /* Diagnostics.Resolution_of_non_relative_name_failed_trying_with_modern_Node_resolution_features_disabled_to_see_if_npm_library_needs_configuration_update */);
600
+ this.trace(1437 /* Diagnostics.Resolution_of_non_relative_name_failed_trying_with_modern_Node_resolution_features_disabled_to_see_if_npm_library_needs_configuration_update */);
576
601
  }
577
602
  this.features &= ~4 /* Features.Exports */;
578
603
  this.extensions &= 1 /* Extensions.TypeScript */ | 4 /* Extensions.Declaration */;
@@ -608,12 +633,12 @@ class ResolutionState {
608
633
  }
609
634
  if (this.name.includes(':')) {
610
635
  if (this.traces !== undefined) {
611
- this.trace(1327 /* Diagnostics.Skipping_module_0_that_looks_like_an_absolute_URI_target_file_types_Colon_1 */, this.name, extensionsToString(this.extensions));
636
+ this.trace(1338 /* Diagnostics.Skipping_module_0_that_looks_like_an_absolute_URI_target_file_types_Colon_1 */, this.name, extensionsToString(this.extensions));
612
637
  }
613
638
  return this.createResolvedModule(undefined, false);
614
639
  }
615
640
  if (this.traces !== undefined) {
616
- this.trace(1267 /* Diagnostics.Loading_module_0_from_node_modules_folder_target_file_types_Colon_1 */, this.name, extensionsToString(this.extensions));
641
+ this.trace(1278 /* Diagnostics.Loading_module_0_from_node_modules_folder_target_file_types_Colon_1 */, this.name, extensionsToString(this.extensions));
617
642
  }
618
643
  const fromNodeModules = this.loadModuleFromNearestNodeModulesDirectory(false);
619
644
  if (fromNodeModules !== undefined)
@@ -662,7 +687,7 @@ class ResolutionState {
662
687
  loadModuleFromImports() {
663
688
  if (this.name === '#' || (this.name.startsWith('#/') && (this.features & 16 /* Features.ImportsPatternRoot */) === 0)) {
664
689
  if (this.traces !== undefined)
665
- this.trace(1421 /* Diagnostics.Invalid_import_specifier_0_has_no_possible_resolutions */, this.name);
690
+ this.trace(1432 /* Diagnostics.Invalid_import_specifier_0_has_no_possible_resolutions */, this.name);
666
691
  return undefined;
667
692
  }
668
693
  const directory = getNormalizedAbsolutePath(this.containingDirectory, this.host.getCurrentDirectory());
@@ -670,21 +695,21 @@ class ResolutionState {
670
695
  const contents = scope?.contents;
671
696
  if (scope === undefined || contents === undefined) {
672
697
  if (this.traces !== undefined) {
673
- this.trace(1419 /* Diagnostics.Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve */, directory);
698
+ this.trace(1430 /* Diagnostics.Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve */, directory);
674
699
  }
675
700
  return undefined;
676
701
  }
677
702
  const imports = contents.imports;
678
703
  if (imports === undefined || imports.type !== 'object') {
679
704
  if (this.traces !== undefined)
680
- this.trace(1422 /* Diagnostics.X_package_json_scope_0_has_no_imports_defined */, scope.packageDirectory);
705
+ this.trace(1433 /* Diagnostics.X_package_json_scope_0_has_no_imports_defined */, scope.packageDirectory);
681
706
  return undefined;
682
707
  }
683
708
  const result = this.loadModuleFromExportsOrImports(this.extensions, this.name, imports, scope, true);
684
709
  if (result !== undefined)
685
710
  return result;
686
711
  if (this.traces !== undefined) {
687
- this.trace(1420 /* Diagnostics.Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1 */, this.name, scope.packageDirectory);
712
+ this.trace(1431 /* Diagnostics.Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1 */, this.name, scope.packageDirectory);
688
713
  }
689
714
  return undefined;
690
715
  }
@@ -709,7 +734,7 @@ class ResolutionState {
709
734
  return result;
710
735
  }
711
736
  if (this.traces !== undefined) {
712
- this.trace(1425 /* Diagnostics.Export_specifier_0_does_not_exist_in_package_json_scope_at_path_1 */, subpath, scope.packageDirectory);
737
+ this.trace(1436 /* Diagnostics.Export_specifier_0_does_not_exist_in_package_json_scope_at_path_1 */, subpath, scope.packageDirectory);
713
738
  }
714
739
  return undefined;
715
740
  }
@@ -750,7 +775,7 @@ class ResolutionState {
750
775
  }
751
776
  invalidTarget(scope, moduleName) {
752
777
  if (this.traces !== undefined) {
753
- this.trace(1424 /* Diagnostics.X_package_json_scope_0_has_invalid_type_for_target_of_specifier_1 */, scope.packageDirectory, moduleName);
778
+ this.trace(1435 /* Diagnostics.X_package_json_scope_0_has_invalid_type_for_target_of_specifier_1 */, scope.packageDirectory, moduleName);
754
779
  }
755
780
  return undefined;
756
781
  }
@@ -779,7 +804,7 @@ class ResolutionState {
779
804
  return this.invalidTarget(scope, moduleName);
780
805
  }
781
806
  if (traces !== undefined) {
782
- this.trace(1494 /* Diagnostics.Using_0_subpath_1_with_target_2 */, isImports ? 'imports' : 'exports', key, isPattern ? replaceAllStars(targetString, subpath) : targetString + subpath);
807
+ this.trace(1505 /* Diagnostics.Using_0_subpath_1_with_target_2 */, isImports ? 'imports' : 'exports', key, isPattern ? replaceAllStars(targetString, subpath) : targetString + subpath);
783
808
  }
784
809
  const finalPath = getNormalizedAbsolutePath(isPattern ? replaceAllStars(resolvedTarget, subpath) : resolvedTarget + subpath, this.host.getCurrentDirectory());
785
810
  const inputLink = this.tryLoadInputFileForPath(finalPath, subpath, combinePaths(scope.packageDirectory, 'package.json'), isImports);
@@ -796,29 +821,29 @@ class ResolutionState {
796
821
  }
797
822
  case 'object': {
798
823
  if (traces !== undefined)
799
- this.trace(1503 /* Diagnostics.Entering_conditional_exports */);
824
+ this.trace(1514 /* Diagnostics.Entering_conditional_exports */);
800
825
  for (const [condition, subTarget] of target.entries) {
801
826
  if (!this.conditionMatches(condition)) {
802
827
  if (traces !== undefined)
803
- this.trace(1495 /* Diagnostics.Saw_non_matching_condition_0 */, condition);
828
+ this.trace(1506 /* Diagnostics.Saw_non_matching_condition_0 */, condition);
804
829
  continue;
805
830
  }
806
831
  if (traces !== undefined)
807
- this.trace(1493 /* Diagnostics.Matched_0_condition_1 */, isImports ? 'imports' : 'exports', condition);
832
+ this.trace(1504 /* Diagnostics.Matched_0_condition_1 */, isImports ? 'imports' : 'exports', condition);
808
833
  const result = this.loadModuleFromTargetExportOrImport(extensions, moduleName, scope, isImports, subTarget, subpath, isPattern, key);
809
834
  if (result !== undefined) {
810
835
  if (traces !== undefined) {
811
836
  if (result.path !== '')
812
- this.trace(1504 /* Diagnostics.Resolved_under_condition_0 */, condition);
813
- this.trace(1506 /* Diagnostics.Exiting_conditional_exports */);
837
+ this.trace(1515 /* Diagnostics.Resolved_under_condition_0 */, condition);
838
+ this.trace(1517 /* Diagnostics.Exiting_conditional_exports */);
814
839
  }
815
840
  return result;
816
841
  }
817
842
  if (traces !== undefined)
818
- this.trace(1505 /* Diagnostics.Failed_to_resolve_under_condition_0 */, condition);
843
+ this.trace(1516 /* Diagnostics.Failed_to_resolve_under_condition_0 */, condition);
819
844
  }
820
845
  if (traces !== undefined)
821
- this.trace(1506 /* Diagnostics.Exiting_conditional_exports */);
846
+ this.trace(1517 /* Diagnostics.Exiting_conditional_exports */);
822
847
  return undefined;
823
848
  }
824
849
  case 'array':
@@ -832,7 +857,7 @@ class ResolutionState {
832
857
  return this.invalidTarget(scope, moduleName);
833
858
  case 'null':
834
859
  if (traces !== undefined) {
835
- this.trace(1423 /* Diagnostics.X_package_json_scope_0_explicitly_maps_specifier_1_to_null */, scope.packageDirectory, moduleName);
860
+ this.trace(1434 /* Diagnostics.X_package_json_scope_0_explicitly_maps_specifier_1_to_null */, scope.packageDirectory, moduleName);
836
861
  }
837
862
  return unresolved();
838
863
  default:
@@ -844,8 +869,8 @@ class ResolutionState {
844
869
  const combinedLookup = isPattern ? replaceAllStars(targetString, subpath) : targetString + subpath;
845
870
  const scopeDirectory = ensureTrailingDirectorySeparator(scope.packageDirectory);
846
871
  if (this.traces !== undefined) {
847
- this.trace(1494 /* Diagnostics.Using_0_subpath_1_with_target_2 */, 'imports', key, combinedLookup);
848
- this.trace(1255 /* Diagnostics.Resolving_module_0_from_1 */, combinedLookup, scopeDirectory);
872
+ this.trace(1505 /* Diagnostics.Using_0_subpath_1_with_target_2 */, 'imports', key, combinedLookup);
873
+ this.trace(1266 /* Diagnostics.Resolving_module_0_from_1 */, combinedLookup, scopeDirectory);
849
874
  }
850
875
  const name = this.name;
851
876
  const containingDirectory = this.containingDirectory;
@@ -889,8 +914,8 @@ class ResolutionState {
889
914
  }
890
915
  else {
891
916
  this.diagnostics.push(createDiagnostic(undefined, 0, 0, isImports
892
- ? 475 /* Diagnostics.The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate */
893
- : 474 /* Diagnostics.The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate */, entry === '' ? '.' : entry, packagePath));
917
+ ? 482 /* Diagnostics.The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate */
918
+ : 481 /* Diagnostics.The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate */, entry === '' ? '.' : entry, packagePath));
894
919
  return unresolved();
895
920
  }
896
921
  // Output paths in a config are relative to the current directory; otherwise to the root.
@@ -931,7 +956,7 @@ class ResolutionState {
931
956
  const secondary = this.extensions & ~(1 /* Extensions.TypeScript */ | 4 /* Extensions.Declaration */);
932
957
  if (priority !== 0) {
933
958
  if (this.traces !== undefined) {
934
- this.trace(1507 /* Diagnostics.Searching_all_ancestor_node_modules_directories_for_preferred_extensions_Colon_0 */, extensionsToString(priority));
959
+ this.trace(1518 /* Diagnostics.Searching_all_ancestor_node_modules_directories_for_preferred_extensions_Colon_0 */, extensionsToString(priority));
935
960
  }
936
961
  const result = this.loadModuleFromAncestorNodeModules(priority, typesScopeOnly);
937
962
  if (result !== undefined)
@@ -939,7 +964,7 @@ class ResolutionState {
939
964
  }
940
965
  if (secondary !== 0 && !typesScopeOnly) {
941
966
  if (this.traces !== undefined) {
942
- this.trace(1508 /* Diagnostics.Searching_all_ancestor_node_modules_directories_for_fallback_extensions_Colon_0 */, extensionsToString(secondary));
967
+ this.trace(1519 /* Diagnostics.Searching_all_ancestor_node_modules_directories_for_fallback_extensions_Colon_0 */, extensionsToString(secondary));
943
968
  }
944
969
  return this.loadModuleFromAncestorNodeModules(secondary, typesScopeOnly);
945
970
  }
@@ -963,7 +988,7 @@ class ResolutionState {
963
988
  const nodeModules = combinePaths(directory, 'node_modules');
964
989
  if (!this.host.directoryExists(nodeModules)) {
965
990
  if (this.traces !== undefined)
966
- this.trace(1311 /* Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it */, nodeModules);
991
+ this.trace(1322 /* Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it */, nodeModules);
967
992
  return undefined;
968
993
  }
969
994
  if (!typesScopeOnly) {
@@ -975,7 +1000,7 @@ class ResolutionState {
975
1000
  const atTypes = combinePaths(nodeModules, '@types');
976
1001
  if (!this.host.directoryExists(atTypes)) {
977
1002
  if (this.traces !== undefined)
978
- this.trace(1311 /* Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it */, atTypes);
1003
+ this.trace(1322 /* Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it */, atTypes);
979
1004
  return undefined;
980
1005
  }
981
1006
  return this.loadModuleFromSpecificNodeModulesDirectory(4 /* Extensions.Declaration */, this.mangleScopedPackageName(this.name), atTypes);
@@ -1021,7 +1046,7 @@ class ResolutionState {
1021
1046
  const versionPaths = contents.getVersionPaths(this.traces);
1022
1047
  if (versionPaths !== undefined) {
1023
1048
  if (this.traces !== undefined) {
1024
- this.trace(1361 /* Diagnostics.X_package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2 */, versionPaths.version, typeScriptVersion, rest);
1049
+ this.trace(1372 /* Diagnostics.X_package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2 */, versionPaths.version, typeScriptVersion, rest);
1025
1050
  }
1026
1051
  const fromPaths = this.tryLoadModuleUsingPaths(extensions, rest, packageDirectory, versionPaths.paths, parsePatterns(versionPaths.paths), { kind: 'package', rest, packageInfo });
1027
1052
  if (fromPaths !== undefined)
@@ -1142,7 +1167,7 @@ class ResolutionState {
1142
1167
  if (paths === undefined || paths.size === 0 || pathIsRelative(this.name))
1143
1168
  return undefined;
1144
1169
  if (this.traces !== undefined) {
1145
- this.trace(1260 /* Diagnostics.X_paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0 */, this.name);
1170
+ this.trace(1271 /* Diagnostics.X_paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0 */, this.name);
1146
1171
  }
1147
1172
  const baseDirectory = this.options.pathsBasePath !== undefined && this.options.pathsBasePath !== ''
1148
1173
  ? this.options.pathsBasePath
@@ -1155,12 +1180,12 @@ class ResolutionState {
1155
1180
  return undefined;
1156
1181
  const star = matchedText(pattern, moduleName);
1157
1182
  if (this.traces !== undefined)
1158
- this.trace(1261 /* Diagnostics.Module_name_0_matched_pattern_1 */, moduleName, pattern.text);
1183
+ this.trace(1272 /* Diagnostics.Module_name_0_matched_pattern_1 */, moduleName, pattern.text);
1159
1184
  for (const substitution of paths.get(pattern.text) ?? []) {
1160
1185
  const path = replaceFirstStar(substitution, star);
1161
1186
  const candidate = normalizePath(combinePaths(containingDirectory, path));
1162
1187
  if (this.traces !== undefined) {
1163
- this.trace(1262 /* Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1 */, substitution, path);
1188
+ this.trace(1273 /* Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1 */, substitution, path);
1164
1189
  }
1165
1190
  // A substitution may name a file with its extension.
1166
1191
  const extension = tryGetExtensionFromPath(substitution);
@@ -1195,7 +1220,7 @@ class ResolutionState {
1195
1220
  return undefined;
1196
1221
  const traces = this.traces;
1197
1222
  if (traces !== undefined)
1198
- this.trace(1275 /* Diagnostics.X_rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0 */, this.name);
1223
+ this.trace(1286 /* Diagnostics.X_rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0 */, this.name);
1199
1224
  const candidate = normalizePath(combinePaths(this.containingDirectory, this.name));
1200
1225
  let matchedRootDir = '';
1201
1226
  let matchedPrefix = '';
@@ -1203,7 +1228,7 @@ class ResolutionState {
1203
1228
  const normalizedRoot = ensureTrailingDirectorySeparator(normalizePath(rootDir));
1204
1229
  const isLongest = candidate.startsWith(normalizedRoot) && (matchedPrefix === '' || matchedPrefix.length < normalizedRoot.length);
1205
1230
  if (traces !== undefined) {
1206
- this.trace(1272 /* Diagnostics.Checking_if_0_is_the_longest_matching_prefix_for_1_2 */, normalizedRoot, candidate, String(isLongest));
1231
+ this.trace(1283 /* Diagnostics.Checking_if_0_is_the_longest_matching_prefix_for_1_2 */, normalizedRoot, candidate, String(isLongest));
1207
1232
  }
1208
1233
  if (isLongest) {
1209
1234
  matchedPrefix = normalizedRoot;
@@ -1213,39 +1238,39 @@ class ResolutionState {
1213
1238
  if (matchedPrefix === '')
1214
1239
  return undefined;
1215
1240
  if (traces !== undefined)
1216
- this.trace(1276 /* Diagnostics.Longest_matching_prefix_for_0_is_1 */, candidate, matchedPrefix);
1241
+ this.trace(1287 /* Diagnostics.Longest_matching_prefix_for_0_is_1 */, candidate, matchedPrefix);
1217
1242
  const suffix = candidate.slice(matchedPrefix.length);
1218
1243
  if (traces !== undefined)
1219
- this.trace(1277 /* Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2 */, suffix, matchedPrefix, candidate);
1244
+ this.trace(1288 /* Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2 */, suffix, matchedPrefix, candidate);
1220
1245
  const initial = this.nodeLoadModuleByRelativeName(this.extensions, candidate, true);
1221
1246
  if (initial !== undefined)
1222
1247
  return initial;
1223
1248
  if (traces !== undefined)
1224
- this.trace(1278 /* Diagnostics.Trying_other_entries_in_rootDirs */);
1249
+ this.trace(1289 /* Diagnostics.Trying_other_entries_in_rootDirs */);
1225
1250
  for (const rootDir of rootDirs) {
1226
1251
  if (rootDir === matchedRootDir)
1227
1252
  continue;
1228
1253
  const other = combinePaths(normalizePath(rootDir), suffix);
1229
1254
  if (traces !== undefined)
1230
- this.trace(1277 /* Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2 */, suffix, rootDir, other);
1255
+ this.trace(1288 /* Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2 */, suffix, rootDir, other);
1231
1256
  const resolved = this.nodeLoadModuleByRelativeName(this.extensions, other, true);
1232
1257
  if (resolved !== undefined)
1233
1258
  return resolved;
1234
1259
  }
1235
1260
  if (traces !== undefined)
1236
- this.trace(1279 /* Diagnostics.Module_resolution_using_rootDirs_has_failed */);
1261
+ this.trace(1290 /* Diagnostics.Module_resolution_using_rootDirs_has_failed */);
1237
1262
  return undefined;
1238
1263
  }
1239
1264
  //// Files and directories
1240
1265
  nodeLoadModuleByRelativeName(extensions, candidate, considerPackageJson) {
1241
1266
  if (this.traces !== undefined) {
1242
- this.trace(1264 /* Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_types_Colon_1 */, candidate, extensionsToString(extensions));
1267
+ this.trace(1275 /* Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_types_Colon_1 */, candidate, extensionsToString(extensions));
1243
1268
  }
1244
1269
  if (!hasTrailingDirectorySeparator(candidate)) {
1245
1270
  const parent = getDirectoryPath(candidate);
1246
1271
  if (!this.host.directoryExists(parent)) {
1247
1272
  if (this.traces !== undefined)
1248
- this.trace(1311 /* Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it */, parent);
1273
+ this.trace(1322 /* Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it */, parent);
1249
1274
  return undefined;
1250
1275
  }
1251
1276
  const fromFile = this.loadModuleFromFile(extensions, candidate);
@@ -1257,7 +1282,7 @@ class ResolutionState {
1257
1282
  }
1258
1283
  if (!this.host.directoryExists(candidate)) {
1259
1284
  if (this.traces !== undefined)
1260
- this.trace(1311 /* Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it */, candidate);
1285
+ this.trace(1322 /* Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it */, candidate);
1261
1286
  return undefined;
1262
1287
  }
1263
1288
  // ESM relative imports do no directory lookups (neither package.json nor index files).
@@ -1281,7 +1306,7 @@ class ResolutionState {
1281
1306
  extensionless = candidate.slice(0, candidate.lastIndexOf('.'));
1282
1307
  const extension = candidate.slice(extensionless.length);
1283
1308
  if (this.traces !== undefined)
1284
- this.trace(1297 /* Diagnostics.File_name_0_has_a_1_extension_stripping_it */, candidate, extension);
1309
+ this.trace(1308 /* Diagnostics.File_name_0_has_a_1_extension_stripping_it */, candidate, extension);
1285
1310
  return this.tryAddingExtensions(extensionless, extensions, extension);
1286
1311
  }
1287
1312
  tryAddingExtensions(extensionless, extensions, originalExtension) {
@@ -1367,13 +1392,19 @@ class ResolutionState {
1367
1392
  tryFileLookup(fileName) {
1368
1393
  if (this.host.fileExists(fileName)) {
1369
1394
  if (this.traces !== undefined)
1370
- this.trace(1266 /* Diagnostics.File_0_exists_use_it_as_a_name_resolution_result */, fileName);
1395
+ this.trace(1277 /* Diagnostics.File_0_exists_use_it_as_a_name_resolution_result */, fileName);
1371
1396
  return true;
1372
1397
  }
1373
1398
  if (this.traces !== undefined)
1374
- this.trace(1265 /* Diagnostics.File_0_does_not_exist */, fileName);
1399
+ this.trace(1276 /* Diagnostics.File_0_does_not_exist */, fileName);
1375
1400
  return false;
1376
1401
  }
1402
+ loadPackageMainEntrypoint(info) {
1403
+ return this.loadNodeModuleFromDirectoryWorker(this.extensions, info.packageDirectory, info)?.path ?? '';
1404
+ }
1405
+ loadPackageExportTargetEntrypoint(candidate, target) {
1406
+ return this.loadFileNameFromPackageJsonField(this.extensions, candidate, target)?.path ?? '';
1407
+ }
1377
1408
  loadNodeModuleFromDirectory(extensions, candidate, considerPackageJson) {
1378
1409
  const packageInfo = considerPackageJson ? this.getPackageJsonInfo(candidate) : undefined;
1379
1410
  return this.loadNodeModuleFromDirectoryWorker(extensions, candidate, packageInfo);
@@ -1392,7 +1423,7 @@ class ResolutionState {
1392
1423
  if (versionPaths !== undefined && (packageFile === '' || containsPath(candidate, packageFile, false))) {
1393
1424
  const moduleName = getRelativePathFromDirectory(candidate, packageFile !== '' ? packageFile : indexPath, false);
1394
1425
  if (this.traces !== undefined) {
1395
- this.trace(1361 /* Diagnostics.X_package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2 */, versionPaths.version, typeScriptVersion, moduleName);
1426
+ this.trace(1372 /* Diagnostics.X_package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2 */, versionPaths.version, typeScriptVersion, moduleName);
1396
1427
  }
1397
1428
  const result = this.tryLoadModuleUsingPaths(extensions, moduleName, candidate, versionPaths.paths, parsePatterns(versionPaths.paths), { kind: 'directory', packageFile, packageInfo });
1398
1429
  if (result !== undefined)
@@ -1475,11 +1506,11 @@ class ResolutionState {
1475
1506
  if (existing !== undefined) {
1476
1507
  if (existing.contents !== undefined) {
1477
1508
  if (this.traces !== undefined)
1478
- this.trace(1391 /* Diagnostics.File_0_exists_according_to_earlier_cached_lookups */, packageJsonPath);
1509
+ this.trace(1402 /* Diagnostics.File_0_exists_according_to_earlier_cached_lookups */, packageJsonPath);
1479
1510
  return withPackageDirectory(existing, packageDirectory);
1480
1511
  }
1481
1512
  if (existing.directoryExists && this.traces !== undefined) {
1482
- this.trace(1392 /* Diagnostics.File_0_does_not_exist_according_to_earlier_cached_lookups */, packageJsonPath);
1513
+ this.trace(1403 /* Diagnostics.File_0_does_not_exist_according_to_earlier_cached_lookups */, packageJsonPath);
1483
1514
  }
1484
1515
  return undefined;
1485
1516
  }
@@ -1487,12 +1518,12 @@ class ResolutionState {
1487
1518
  if (directoryExists && this.host.fileExists(packageJsonPath)) {
1488
1519
  const contents = parsePackageJson(this.host.readFile(packageJsonPath) ?? '');
1489
1520
  if (this.traces !== undefined)
1490
- this.trace(1268 /* Diagnostics.Found_package_json_at_0 */, packageJsonPath);
1521
+ this.trace(1279 /* Diagnostics.Found_package_json_at_0 */, packageJsonPath);
1491
1522
  const stored = cache.set(packageJsonPath, { packageDirectory, directoryExists: true, contents });
1492
1523
  return withPackageDirectory(stored, packageDirectory);
1493
1524
  }
1494
1525
  if (directoryExists && this.traces !== undefined)
1495
- this.trace(1265 /* Diagnostics.File_0_does_not_exist */, packageJsonPath);
1526
+ this.trace(1276 /* Diagnostics.File_0_does_not_exist */, packageJsonPath);
1496
1527
  cache.set(packageJsonPath, { packageDirectory, directoryExists, contents: undefined });
1497
1528
  return undefined;
1498
1529
  }
@@ -1520,7 +1551,7 @@ class ResolutionState {
1520
1551
  if (peers === undefined || peers.size === 0)
1521
1552
  return '';
1522
1553
  if (this.traces !== undefined)
1523
- this.trace(1430 /* Diagnostics.X_package_json_has_a_peerDependencies_field */);
1554
+ this.trace(1441 /* Diagnostics.X_package_json_has_a_peerDependencies_field */);
1524
1555
  const packageDirectory = this.realPath(packageInfo.packageDirectory);
1525
1556
  const index = packageDirectory.lastIndexOf('/node_modules');
1526
1557
  if (index === -1)
@@ -1535,10 +1566,10 @@ class ResolutionState {
1535
1566
  const version = peerContents.version.value ?? '';
1536
1567
  result += '+' + name + '@' + version;
1537
1568
  if (this.traces !== undefined)
1538
- this.trace(1431 /* Diagnostics.Found_peerDependency_0_with_1_version */, name, version);
1569
+ this.trace(1442 /* Diagnostics.Found_peerDependency_0_with_1_version */, name, version);
1539
1570
  }
1540
1571
  else if (this.traces !== undefined) {
1541
- this.trace(1432 /* Diagnostics.Failed_to_find_peerDependency_0 */, name);
1572
+ this.trace(1443 /* Diagnostics.Failed_to_find_peerDependency_0 */, name);
1542
1573
  }
1543
1574
  }
1544
1575
  return result;
@@ -1546,7 +1577,7 @@ class ResolutionState {
1546
1577
  realPath(path) {
1547
1578
  const real = normalizePath(this.host.realpath(path));
1548
1579
  if (this.traces !== undefined)
1549
- this.trace(1295 /* Diagnostics.Resolving_real_path_for_0_result_1 */, path, real);
1580
+ this.trace(1306 /* Diagnostics.Resolving_real_path_for_0_result_1 */, path, real);
1550
1581
  return real;
1551
1582
  }
1552
1583
  validatePackageJsonField(fieldName, field, expectedType) {
@@ -1554,11 +1585,11 @@ class ResolutionState {
1554
1585
  if (field.value !== undefined)
1555
1586
  return true;
1556
1587
  if (this.traces !== undefined) {
1557
- this.trace(1273 /* Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2 */, fieldName, expectedType, field.actualType);
1588
+ this.trace(1284 /* Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2 */, fieldName, expectedType, field.actualType);
1558
1589
  }
1559
1590
  }
1560
1591
  if (this.traces !== undefined)
1561
- this.trace(1269 /* Diagnostics.X_package_json_does_not_have_a_0_field */, fieldName);
1592
+ this.trace(1280 /* Diagnostics.X_package_json_does_not_have_a_0_field */, fieldName);
1562
1593
  return false;
1563
1594
  }
1564
1595
  /** The normalized path a string field points at, or `''`. */
@@ -1568,12 +1599,12 @@ class ResolutionState {
1568
1599
  const value = field.value ?? '';
1569
1600
  if (value === '') {
1570
1601
  if (this.traces !== undefined)
1571
- this.trace(1373 /* Diagnostics.X_package_json_had_a_falsy_0_field */, fieldName);
1602
+ this.trace(1384 /* Diagnostics.X_package_json_had_a_falsy_0_field */, fieldName);
1572
1603
  return '';
1573
1604
  }
1574
1605
  const path = normalizePath(combinePaths(directory, value));
1575
1606
  if (this.traces !== undefined)
1576
- this.trace(1270 /* Diagnostics.X_package_json_has_0_field_1_that_references_2 */, fieldName, value, path);
1607
+ this.trace(1281 /* Diagnostics.X_package_json_has_0_field_1_that_references_2 */, fieldName, value, path);
1577
1608
  return path;
1578
1609
  }
1579
1610
  conditionMatches(condition) {