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
@@ -1,7 +1,7 @@
1
1
  import { sideOf } from './side-state.js';
2
- import { CompactSymbolLinkTable, IntLinkTable, LinkTable, PagedIdSet, SparseLinkTable } from './link-tables.js';
2
+ import { CompactIntLinkTable, CompactLinkTable, IntLinkTable, LinkTable, PagedIdSet, SparseLinkTable, } from './link-tables.js';
3
3
  import { getErrorRangeForNode, getSourceFileOfNode } from './binder-utilities.js';
4
- import { Diagnostic, compareDiagnostics } from './diagnostics.js';
4
+ import { Diagnostic, compareDiagnostics, equalDiagnostics, } from './diagnostics.js';
5
5
  import { ModuleKind, ScriptTarget, getEmitScriptTarget, getIsolatedModules, getStrictOptionValue, shouldPreserveConstEnums, } from './options.js';
6
6
  import { Symbol, getSymbolId } from './symbol.js';
7
7
  import { IndexInfo, IntrinsicType, LiteralType, NodeLinks, Signature, SymbolLinks, TypeParameter, TypePredicate, emptyTypes, TypeListCache, TypeListTable, } from './checker-types.js';
@@ -10,12 +10,14 @@ import { getFalseTypeFromConditionalType, getTrueTypeFromConditionalType } from
10
10
  import { createArrayType, createTypeFromGenericGlobalType, getBigIntLiteralType, getNumberLiteralType, getStringLiteralType, getTemplateLiteralType, getUnionType, newAnonymousType, newObjectType, } from './checker-type-factory.js';
11
11
  import { CheckerNameResolver, borrowLibGlobals, findLibGlobals, returnLibGlobals, setGlobal, SuggestionNameResolver, getGlobalStrictFunctionType, getGlobalType, initializeGlobals, mergeAmbientModulesAndAugmentations, } from './checker-symbols.js';
12
12
  import { PermissiveMapper, ReportingMapper, RestrictiveMapper, UniqueLiteralMapper } from './instantiation.js';
13
- import { Relation, RelationKey } from './relations.js';
14
- import { TypeNodeVisitor, checkSourceFile } from './checker-source-file.js';
13
+ import { Relation, RelationKey, } from './relations.js';
14
+ import { TypeNodeVisitor, checkSourceFile, produceDeferredDiagnostics } from './checker-source-file.js';
15
+ import { checkObjectLiteralDeprecations } from './checker-deprecation.js';
15
16
  import { InferenceCaches } from './checker-inference.js';
16
17
  import { AssignmentMarker } from './checker-narrowing.js';
17
18
  import { JsxState } from './checker-jsx.js';
18
19
  import { SourceFileMetadata, getEmitModuleFormatOfFile } from './program-utilities.js';
20
+ import { shareThreads, startThreadSharing } from './shared-results.js';
19
21
  /** What the checker needs from a program. */
20
22
  export class CheckerHost {
21
23
  /** How a module name in `file` resolved in `mode`, if the program resolved it. */
@@ -78,22 +80,40 @@ export class CheckerHost {
78
80
  return undefined;
79
81
  }
80
82
  }
81
- /** Per-file and global diagnostics, sorted on read like tsgo's DiagnosticsCollection. */
83
+ /**
84
+ * Per-file and global diagnostics, sorted on read like tsgo's DiagnosticsCollection, which keeps one of
85
+ * each set of equal diagnostics.
86
+ */
82
87
  class DiagnosticCollection {
83
88
  byFile = new Map();
84
89
  sortedFiles = new Set();
85
90
  global = [];
86
91
  globalSorted = true;
87
- /** The diagnostics added since `startLog`, while recording. */
92
+ /** The diagnostics at each file, position, end and code, to find an equal one when adding. */
93
+ byLocation = new Map();
94
+ /** The diagnostics reported since `startLog`, while recording, also those equal to one already added. */
88
95
  log = undefined;
96
+ /** Adds `diagnostic` unless an equal one was added; returns the one the collection holds. */
89
97
  add(diagnostic) {
90
98
  if (this.log !== undefined)
91
99
  this.log.push(diagnostic);
100
+ if (this.added !== undefined)
101
+ this.added.push(diagnostic);
92
102
  const file = diagnostic.file;
103
+ const key = `${file === undefined ? '' : file.fileName}\0${diagnostic.pos}\0${diagnostic.end}\0${diagnostic.code}`;
104
+ const existing = this.byLocation.get(key);
105
+ if (existing === undefined)
106
+ this.byLocation.set(key, [diagnostic]);
107
+ else {
108
+ for (const d of existing)
109
+ if (equalDiagnostics(d, diagnostic))
110
+ return d;
111
+ existing.push(diagnostic);
112
+ }
93
113
  if (file === undefined) {
94
114
  this.global.push(diagnostic);
95
115
  this.globalSorted = false;
96
- return;
116
+ return diagnostic;
97
117
  }
98
118
  let list = this.byFile.get(file.fileName);
99
119
  if (list === undefined) {
@@ -102,6 +122,7 @@ class DiagnosticCollection {
102
122
  }
103
123
  list.push(diagnostic);
104
124
  this.sortedFiles.delete(file.fileName);
125
+ return diagnostic;
105
126
  }
106
127
  forFile(fileName) {
107
128
  const list = this.byFile.get(fileName);
@@ -137,6 +158,50 @@ class DiagnosticCollection {
137
158
  }
138
159
  return this.global.slice();
139
160
  }
161
+ /** The global diagnostics `withoutNewGlobals` removed. */
162
+ removedGlobals = 0;
163
+ /** Where results are shared between checker threads (shared-results.ts): every diagnostic added, in order. */
164
+ added = undefined;
165
+ /** Runs `run`, then removes the global diagnostics it added. */
166
+ withoutNewGlobals(run) {
167
+ const outer = this.log;
168
+ const added = [];
169
+ this.log = added;
170
+ try {
171
+ return run();
172
+ }
173
+ finally {
174
+ this.log = outer;
175
+ if (outer !== undefined)
176
+ for (const d of added)
177
+ outer.push(d);
178
+ const globals = new Set();
179
+ for (const d of added)
180
+ if (d.file === undefined)
181
+ globals.add(d);
182
+ if (globals.size > 0) {
183
+ let kept = 0;
184
+ for (const d of this.global) {
185
+ if (!globals.has(d))
186
+ this.global[kept++] = d;
187
+ else
188
+ this.forget(d);
189
+ }
190
+ this.removedGlobals += this.global.length - kept;
191
+ this.global.length = kept;
192
+ }
193
+ }
194
+ }
195
+ /** Removes the global diagnostic `diagnostic` from the location index. */
196
+ forget(diagnostic) {
197
+ const key = `\0${diagnostic.pos}\0${diagnostic.end}\0${diagnostic.code}`;
198
+ const existing = this.byLocation.get(key);
199
+ if (existing === undefined)
200
+ return;
201
+ const at = existing.indexOf(diagnostic);
202
+ if (at >= 0)
203
+ existing.splice(at, 1);
204
+ }
140
205
  /** Records the diagnostics added from now on. */
141
206
  startLog() {
142
207
  this.log = [];
@@ -220,10 +285,20 @@ export class Checker {
220
285
  memberPositionsInLists = new Map();
221
286
  /** The property names of the last instantiation of each such list whose table is built on demand. */
222
287
  memberNamesOfLists = new Map();
288
+ /** The property order of the instantiations of each such list (`NamedMemberOrder`); null where it has none. */
289
+ namedMemberOrdersOfLists = new Map();
223
290
  /** Long lists of inherited properties, by name. */
224
291
  propertiesByName = new Map();
225
292
  /** Number of `typeToString` calls in progress. */
226
293
  serializationLevel = 0;
294
+ /**
295
+ * `typeToString` results by type, enclosing declaration, flags and the type parameter of the variance check in
296
+ * progress: the prints that created no types, which a later print with the same inputs repeats exactly
297
+ * (`typeToString`).
298
+ */
299
+ typeStrings = new Map();
300
+ /** `symbolToString` results by symbol, then by enclosing declaration and flags, kept as `typeStrings` are. */
301
+ symbolStrings = new Map();
227
302
  /** Whether `globalObjectType` is set; global type lookups before it can't suggest `typeof`. */
228
303
  hasGlobalObjectType = false;
229
304
  /** The node being checked, for errors with no better location. */
@@ -257,6 +332,9 @@ export class Checker {
257
332
  * so far; null where a list repeats a name.
258
333
  */
259
334
  propertyListIndexes = new Map();
335
+ // Types, targets and mappers of symbols keep a slot per id: they are dense enough, and read on hot
336
+ // paths. The other symbol columns, which most symbols leave empty, keep only their values
337
+ // (CompactLinkTable).
260
338
  /** The type of a value symbol. */
261
339
  symbolTypes = new LinkTable();
262
340
  /** For instantiated and synthetic symbols, the symbol they come from. */
@@ -264,24 +342,24 @@ export class Checker {
264
342
  /** The mapper of an instantiated symbol or a mapped type property. */
265
343
  symbolMappers = new LinkTable();
266
344
  /** The literal type of a property name. */
267
- symbolNameTypes = new LinkTable();
345
+ symbolNameTypes = new CompactLinkTable();
268
346
  /** The mapped type of a mapped type property, or the union/intersection of a synthetic property. */
269
- symbolContainingTypes = new LinkTable();
347
+ symbolContainingTypes = new CompactLinkTable();
270
348
  /** The key type of a mapped type property. */
271
- symbolKeyTypes = new LinkTable();
349
+ symbolKeyTypes = new CompactLinkTable();
272
350
  /** The property a mapped, spread or synthetic property comes from. */
273
- symbolSyntheticOrigins = new LinkTable();
351
+ symbolSyntheticOrigins = new CompactLinkTable();
274
352
  /** The left and right properties a spread property combines. */
275
- symbolLeftSpreads = new LinkTable();
276
- symbolRightSpreads = new LinkTable();
353
+ symbolLeftSpreads = new CompactLinkTable();
354
+ symbolRightSpreads = new CompactLinkTable();
277
355
  /** Bits of SymbolFlags for the meanings in which a symbol was referenced. */
278
- symbolReferenceKinds = new IntLinkTable();
356
+ symbolReferenceKinds = new CompactIntLinkTable();
279
357
  /** The resolved symbol of an identifier, entity name or call. */
280
- resolvedSymbols = new CompactSymbolLinkTable();
358
+ resolvedSymbols = new CompactLinkTable();
281
359
  /** The resolved type of a type node or expression. */
282
- resolvedTypes = new SparseLinkTable();
360
+ resolvedTypes = new CompactLinkTable();
283
361
  /** The resolved signature of a call-like node or a signature declaration. */
284
- resolvedSignatures = new SparseLinkTable();
362
+ resolvedSignatures = new CompactLinkTable();
285
363
  /** Merged symbols, indexed by the id of the symbol merged into them. */
286
364
  mergedSymbols;
287
365
  /**
@@ -451,14 +529,20 @@ export class Checker {
451
529
  globalSymbolCache = new Map();
452
530
  // Resolution stacks for cycle detection (see pushTypeResolution).
453
531
  resolutionStart = 0;
454
- inVarianceComputation = false;
532
+ /** The generic types whose variances are being computed, outermost first. */
533
+ varianceStack = [];
455
534
  // Instantiation
456
535
  instantiationDepth = 0;
536
+ /** The types being instantiated, outermost first: the first `instantiationDepth` entries are current. */
537
+ instantiationStack = [];
538
+ /** The calls being resolved, outermost first: the first `callResolutionDepth` entries are current. */
539
+ callResolutionStack = [];
540
+ callResolutionDepth = 0;
457
541
  instantiationCount = 0;
458
542
  /** Instantiations over the checker's lifetime (statistics). */
459
543
  totalInstantiations = 0;
460
- /** Mappers of the instantiations in progress: the first `activeMapperDepth` entries are live. */
461
- activeMappers = [];
544
+ /** Ids of the mappers of the instantiations in progress: the first `activeMapperDepth` entries are live. */
545
+ activeMapperIds = new Int32Array(16);
462
546
  activeMapperDepth = 0;
463
547
  /** Per active mapper: its instantiations by type id, created on the first nested write. */
464
548
  activeMapperCaches = [];
@@ -473,20 +557,32 @@ export class Checker {
473
557
  /** Empty lists for type arguments that are compared with cached instantiations before any is kept. */
474
558
  freeTypeLists = [];
475
559
  /**
476
- * 1 by type id for the anonymous and mapped types whose declaration has no outer type parameters
560
+ * The ids of the anonymous and mapped types whose declaration has no outer type parameters
477
561
  * to instantiate (`getObjectTypeInstantiation`).
478
562
  */
479
- withoutOuterTypeParameters = new IntLinkTable();
563
+ withoutOuterTypeParameters = new PagedIdSet();
480
564
  conditionalConstraintDepth = 0;
481
565
  suggestionResolver;
482
566
  awaitedTypeStack = [];
483
567
  /** Iteration types by type id and iteration use. */
484
568
  iterationTypesCache = new Map();
485
- /** Whether diagnostics can be deferred to the end of the file being checked. */
486
- saveDeferredDiagnostics = false;
487
- deferredIterationErrors = [];
488
- /** Collision checks waiting for the end of the file (checker-generated-code.ts). */
489
- deferredCollisionChecks = [];
569
+ /**
570
+ * Diagnostics reported after the checks of the file being checked, or before the next global
571
+ * diagnostics are read, in the order they were deferred. Reporting them earlier could resolve types
572
+ * that are being resolved.
573
+ */
574
+ deferredDiagnostics = [];
575
+ /** Defers the diagnostic `report` reports at `node` (`deferredDiagnostics`). */
576
+ deferDiagnostic(node, report) {
577
+ this.deferredDiagnostics.push(report);
578
+ if (this.deferredDiagnosticFiles !== undefined)
579
+ this.deferredDiagnosticFiles.push(getSourceFileOfNode(node).fileName);
580
+ }
581
+ /**
582
+ * The checked object literals of each file whose members may set deprecated properties of their contextual
583
+ * types, reported when the file's suggestion diagnostics are asked for (`checkObjectLiteralDeprecations`).
584
+ */
585
+ objectLiteralsForDeprecations = new Map();
490
586
  /** Binding patterns whose implied type is being computed as a contextual type. */
491
587
  contextualBindingPatterns = [];
492
588
  /** The binding pattern or assignment pattern that implied each type. */
@@ -543,6 +639,8 @@ export class Checker {
543
639
  flowNodePostSuper = new Map();
544
640
  lastFlowNode = undefined;
545
641
  lastFlowNodeReachable = false;
642
+ /** Symbols whose explicit type is being found, for flow analysis of self-referential `for...of`. */
643
+ resolvingExplicitTypeOfSymbol = new Set();
546
644
  assignmentMarker;
547
645
  primitiveTypeAliasSuggestions = new Map();
548
646
  /** Renamed binding elements in parameters of bodiless signatures, checked for use with their file. */
@@ -566,6 +664,9 @@ export class Checker {
566
664
  ambientModuleSymbols = [];
567
665
  patternAmbientModules = [];
568
666
  patternAmbientModuleAugmentations = new Map();
667
+ /** The pattern module each entry of `patternAmbientModuleAugmentations` augments. */
668
+ patternAmbientModuleAugmentationTargets = new Map();
669
+ moduleImportAttributesTypes = new Map();
569
670
  inferenceCaches = new InferenceCaches();
570
671
  /** The type resolution stack: the first `resolutionDepth` entries are live, later slots are reused. */
571
672
  resolutionTargets = [];
@@ -574,6 +675,28 @@ export class Checker {
574
675
  resolutionDepth = 0;
575
676
  /** The number of resolution cycles found (`pushTypeResolution`). */
576
677
  resolutionCycleCount = 0;
678
+ /**
679
+ * While an `inferTypesFromUnstarted` walk runs: the unions and intersections whose properties
680
+ * `hasUnmatchedProperty` searched before they were resolved. Such a search creates fewer types
681
+ * than one of the resolved properties.
682
+ */
683
+ unresolvedPropertySearches = undefined;
684
+ // The fields of shared results come last, so the fields before keep their places.
685
+ /** TSC_TS_SHARE: the checker thread's sharing with the other checker threads. */
686
+ threadSharing = undefined;
687
+ /**
688
+ * Where results are shared (shared-results.ts): for each conditional type made as a member of the distribution of a
689
+ * conditional type instantiation, that instantiation and the constituent it is for.
690
+ */
691
+ distributedConditionals = undefined;
692
+ /** The same members by `distributedKey`. */
693
+ distributedByKey = undefined;
694
+ /** The conditional types conditional type instantiations resolved to, with the instantiation's root and key. */
695
+ conditionalResults = undefined;
696
+ /** The access flags of the key `getIndexedAccessTypeEx` keeps each indexed access type by. */
697
+ indexedAccessKeyFlags = undefined;
698
+ /** Where results are shared between checker threads (shared-results.ts): the file of each diagnostic deferred. */
699
+ deferredDiagnosticFiles = undefined;
577
700
  constructor(host) {
578
701
  this.host = host;
579
702
  const options = host.getCompilerOptions();
@@ -763,6 +886,14 @@ export class Checker {
763
886
  mergeAmbientModulesAndAugmentations(this);
764
887
  this.modulesMerged = true;
765
888
  this.mergeDiagnostics.push(this.diagnostics.takeLog(), this.suggestionDiagnostics.takeLog());
889
+ if (shareThreads)
890
+ startThreadSharing(this);
891
+ if (this.threadSharing !== undefined) {
892
+ this.distributedConditionals = new Map();
893
+ this.distributedByKey = new Map();
894
+ this.conditionalResults = new Map();
895
+ this.indexedAccessKeyFlags = new Map();
896
+ }
766
897
  }
767
898
  // ---- Public API
768
899
  /** Checks `file` if needed and returns its semantic diagnostics, sorted. */
@@ -774,12 +905,25 @@ export class Checker {
774
905
  /** Checks `file`, including unused identifiers, and returns its suggestion diagnostics. */
775
906
  getSuggestionDiagnostics(file) {
776
907
  checkSourceFile(this, file, true);
908
+ checkObjectLiteralDeprecations(this, file);
777
909
  return this.suggestionDiagnostics.forFile(file.fileName);
778
910
  }
779
911
  /** Diagnostics without a file, such as missing global types. */
780
912
  getGlobalDiagnostics() {
913
+ produceDeferredDiagnostics(this);
781
914
  return this.diagnostics.globals();
782
915
  }
916
+ /**
917
+ * Runs `run` (such as emitting declarations), then forgets the global diagnostics it reported:
918
+ * the program collects global diagnostics before it emits.
919
+ */
920
+ withoutGlobalDiagnostics(run) {
921
+ return this.diagnostics.withoutNewGlobals(run);
922
+ }
923
+ /** The global diagnostics `withoutGlobalDiagnostics` forgot so far. */
924
+ forgottenGlobalDiagnostics() {
925
+ return this.diagnostics.removedGlobals;
926
+ }
783
927
  // ---- Links
784
928
  /** The rarely used links of `symbol`, created on first use. */
785
929
  symbolLinks(symbol) {
@@ -847,15 +991,15 @@ export class Checker {
847
991
  // ---- Diagnostics
848
992
  /** Reports `message` at `node`, or as a global diagnostic without a node. */
849
993
  error(node, message, ...args) {
850
- const diagnostic = createDiagnosticForNode(node, message, args);
851
- this.addDiagnostic(diagnostic);
852
- return diagnostic;
994
+ return this.addDiagnostic(createDiagnosticForNode(node, message, args));
853
995
  }
996
+ /** Reports `diagnostic`; returns the equal diagnostic already reported, if any, else `diagnostic`. */
854
997
  addDiagnostic(diagnostic) {
855
998
  this.reports++;
856
999
  // Discard diagnostics created while at the maximum number of nested typeToString calls.
857
1000
  if (this.serializationLevel < maxSerializationLevel)
858
- this.diagnostics.add(diagnostic);
1001
+ return this.diagnostics.add(diagnostic);
1002
+ return diagnostic;
859
1003
  }
860
1004
  addSuggestion(diagnostic) {
861
1005
  this.reports++;
@@ -901,6 +1045,7 @@ export function disposeChecker(c) {
901
1045
  c.sharedSymbolCopies.clear();
902
1046
  c.memberPositionsInLists.clear();
903
1047
  c.memberNamesOfLists.clear();
1048
+ c.namedMemberOrdersOfLists.clear();
904
1049
  c.propertiesByName.clear();
905
1050
  c.symbolAccessibilityCaches = undefined;
906
1051
  c.unresolvedSymbols.clear();
@@ -926,8 +1071,8 @@ export function disposeChecker(c) {
926
1071
  c.cachedTypesById.clear();
927
1072
  c.cachedTypesByPair.clear();
928
1073
  c.iterationTypesCache.clear();
929
- c.deferredIterationErrors = [];
930
- c.deferredCollisionChecks = [];
1074
+ c.deferredDiagnostics = [];
1075
+ c.objectLiteralsForDeprecations.clear();
931
1076
  c.errorTypes.clear();
932
1077
  c.globalTypeCache.clear();
933
1078
  c.globalSymbolCache.clear();
@@ -938,8 +1083,11 @@ export function disposeChecker(c) {
938
1083
  c.flowNodePostSuper.clear();
939
1084
  c.primitiveTypeAliasSuggestions.clear();
940
1085
  c.patternAmbientModuleAugmentations.clear();
1086
+ c.patternAmbientModuleAugmentationTargets.clear();
1087
+ c.moduleImportAttributesTypes.clear();
941
1088
  c.sharedFlowTypes.length = 0;
942
1089
  c.relationComparers = [];
1090
+ c.inferenceCaches.unstartedInferences.clear();
943
1091
  }
944
1092
  /** A diagnostic at `node`'s error range, or a global one without a node. */
945
1093
  export function createDiagnosticForNode(node, message, args) {
@@ -1,6 +1,6 @@
1
1
  import { type Diagnostic } from './diagnostics.js';
2
2
  import { type OptionDeclaration } from './option-declarations.js';
3
- import { type BuildOptions, type CompilerOptions, type OptionValue, type WatchOptions } from './options.js';
3
+ import { type BuildOptions, type CompilerOptions, type OptionValue } from './options.js';
4
4
  /** Reads response files. */
5
5
  export declare abstract class CommandLineHost {
6
6
  readonly currentDirectory: string;
@@ -10,7 +10,6 @@ export declare abstract class CommandLineHost {
10
10
  }
11
11
  export interface ParsedCommandLine {
12
12
  readonly options: CompilerOptions;
13
- readonly watchOptions: WatchOptions;
14
13
  readonly fileNames: readonly string[];
15
14
  readonly errors: readonly Diagnostic[];
16
15
  /** Options as written, keyed by declaration name in first-seen order. Paths are not made absolute. */
@@ -20,7 +19,6 @@ export interface ParsedBuildCommandLine {
20
19
  readonly buildOptions: BuildOptions;
21
20
  /** Only options shared with `tsc`, and `build`. */
22
21
  readonly compilerOptions: CompilerOptions;
23
- readonly watchOptions: WatchOptions;
24
22
  /** Project paths as given; `["."]` if none. */
25
23
  readonly projects: readonly string[];
26
24
  readonly errors: readonly Diagnostic[];
@@ -4,9 +4,10 @@
4
4
  import { isUnicodeWhiteSpace, isWhiteSpaceLike } from './character-codes.js';
5
5
  import { createCompilerDiagnostic } from './diagnostics.js';
6
6
  import { isValidLocale } from './locale.js';
7
- import { buildOption, buildOptionsByName, compilerOptionsByName, watchOptionsByName, } from './option-declarations.js';
8
- import { setBuildOption, setCompilerOption, setWatchOption, } from './options.js';
9
- import { getNormalizedAbsolutePath } from './path.js';
7
+ import { buildOption, buildOptionsByName, compilerOptionsByName, } from './option-declarations.js';
8
+ import { setBuildOption, setCompilerOption, } from './options.js';
9
+ import { getNormalizedAbsolutePath, isNetworkPathValue } from './path.js';
10
+ import { getSpellingSuggestion } from './spelling.js';
10
11
  /** Reads response files. */
11
12
  export class CommandLineHost {
12
13
  currentDirectory;
@@ -16,43 +17,37 @@ export class CommandLineHost {
16
17
  }
17
18
  const compilerMode = {
18
19
  options: compilerOptionsByName,
19
- unknownOption: 1121 /* Diagnostics.Unknown_compiler_option_0 */,
20
- missingArgument: 1222 /* Diagnostics.Compiler_option_0_expects_an_argument */,
20
+ unknownOption: 1128 /* Diagnostics.Unknown_compiler_option_0 */,
21
+ unknownOptionDidYouMean: 1130 /* Diagnostics.Unknown_compiler_option_0_Did_you_mean_1 */,
22
+ missingArgument: 1233 /* Diagnostics.Compiler_option_0_expects_an_argument */,
21
23
  otherModeOptions: buildOptionsByName,
22
- wrongMode: 1167 /* Diagnostics.Compiler_option_0_may_only_be_used_with_build */,
24
+ wrongMode: 1174 /* Diagnostics.Compiler_option_0_may_only_be_used_with_build */,
23
25
  };
24
26
  const buildMode = {
25
27
  options: buildOptionsByName,
26
- unknownOption: 1147 /* Diagnostics.Unknown_build_option_0 */,
27
- missingArgument: 1148 /* Diagnostics.Build_option_0_requires_a_value_of_type_1 */,
28
+ unknownOption: 1154 /* Diagnostics.Unknown_build_option_0 */,
29
+ unknownOptionDidYouMean: 1159 /* Diagnostics.Unknown_build_option_0_Did_you_mean_1 */,
30
+ missingArgument: 1155 /* Diagnostics.Build_option_0_requires_a_value_of_type_1 */,
28
31
  otherModeOptions: compilerOptionsByName,
29
- wrongMode: 1168 /* Diagnostics.Compiler_option_0_may_not_be_used_with_build */,
30
- };
31
- const watchMode = {
32
- options: watchOptionsByName,
33
- unknownOption: 1153 /* Diagnostics.Unknown_watch_option_0 */,
34
- missingArgument: 1155 /* Diagnostics.Watch_option_0_requires_a_value_of_type_1 */,
32
+ wrongMode: 1175 /* Diagnostics.Compiler_option_0_may_not_be_used_with_build */,
35
33
  };
36
34
  export function parseCommandLine(args, host) {
37
35
  const parser = new CommandLineParser(compilerMode, host);
38
36
  parser.parseArguments(args);
39
37
  const cwd = host.currentDirectory;
40
38
  const options = {};
41
- const watchOptions = {};
42
39
  for (const [name, value] of parser.raw) {
43
40
  if (parser.droppedLists.has(name))
44
41
  continue;
45
42
  setCompilerOption(options, name, toAbsolutePaths(name, value, cwd));
46
- setWatchOption(watchOptions, name, value);
47
43
  }
48
- return { options, watchOptions, fileNames: parser.fileNames, errors: parser.errors, raw: parser.raw };
44
+ return { options, fileNames: parser.fileNames, errors: parser.errors, raw: parser.raw };
49
45
  }
50
46
  export function parseBuildCommandLine(args, host) {
51
47
  const parser = new CommandLineParser(buildMode, host);
52
48
  parser.parseArguments(args);
53
49
  const buildOptions = {};
54
50
  const compilerOptions = {};
55
- const watchOptions = {};
56
51
  for (const [name, value] of parser.raw) {
57
52
  if (parser.droppedLists.has(name))
58
53
  continue;
@@ -61,23 +56,21 @@ export function parseBuildCommandLine(args, host) {
61
56
  setCompilerOption(compilerOptions, name, value);
62
57
  }
63
58
  setBuildOption(buildOptions, name, value);
64
- setWatchOption(watchOptions, name, value);
65
59
  }
66
60
  const errors = parser.errors;
67
61
  const { clean, force, verbose, dry } = buildOptions;
68
62
  const watch = compilerOptions.watch;
69
63
  if (clean === true && force === true)
70
- errors.push(createCompilerDiagnostic(1465 /* Diagnostics.Options_0_and_1_cannot_be_combined */, 'clean', 'force'));
64
+ errors.push(createCompilerDiagnostic(1476 /* Diagnostics.Options_0_and_1_cannot_be_combined */, 'clean', 'force'));
71
65
  if (clean === true && verbose === true)
72
- errors.push(createCompilerDiagnostic(1465 /* Diagnostics.Options_0_and_1_cannot_be_combined */, 'clean', 'verbose'));
66
+ errors.push(createCompilerDiagnostic(1476 /* Diagnostics.Options_0_and_1_cannot_be_combined */, 'clean', 'verbose'));
73
67
  if (clean === true && watch === true)
74
- errors.push(createCompilerDiagnostic(1465 /* Diagnostics.Options_0_and_1_cannot_be_combined */, 'clean', 'watch'));
68
+ errors.push(createCompilerDiagnostic(1476 /* Diagnostics.Options_0_and_1_cannot_be_combined */, 'clean', 'watch'));
75
69
  if (watch === true && dry === true)
76
- errors.push(createCompilerDiagnostic(1465 /* Diagnostics.Options_0_and_1_cannot_be_combined */, 'watch', 'dry'));
70
+ errors.push(createCompilerDiagnostic(1476 /* Diagnostics.Options_0_and_1_cannot_be_combined */, 'watch', 'dry'));
77
71
  return {
78
72
  buildOptions,
79
73
  compilerOptions,
80
- watchOptions,
81
74
  projects: parser.fileNames.length > 0 ? parser.fileNames : ['.'],
82
75
  errors,
83
76
  raw: parser.raw,
@@ -109,6 +102,8 @@ class CommandLineParser {
109
102
  * though `raw` (and so `--init`) has `[]`.
110
103
  */
111
104
  droppedLists = new Set();
105
+ /** Response files being read, so one that includes itself is skipped. */
106
+ responseFiles = new Set();
112
107
  constructor(mode, host) {
113
108
  this.mode = mode;
114
109
  this.host = host;
@@ -126,16 +121,10 @@ class CommandLineParser {
126
121
  else if (arg.startsWith('-')) {
127
122
  const name = arg.startsWith('--') ? arg.slice(2) : arg.slice(1);
128
123
  const option = this.mode.options.find(name, true);
129
- if (option !== undefined) {
124
+ if (option !== undefined)
130
125
  i = this.parseOptionValue(args, i, option, this.mode);
131
- }
132
- else {
133
- const watchOption = watchOptionsByName.find(name, true);
134
- if (watchOption !== undefined)
135
- i = this.parseOptionValue(args, i, watchOption, watchMode);
136
- else
137
- this.errors.push(this.unknownOptionError(name, arg));
138
- }
126
+ else
127
+ this.errors.push(this.unknownOptionError(name, arg));
139
128
  }
140
129
  else {
141
130
  this.fileNames.push(arg);
@@ -145,17 +134,27 @@ class CommandLineParser {
145
134
  unknownOptionError(name, arg) {
146
135
  const other = this.mode.otherModeOptions?.get(name);
147
136
  if (other !== undefined && this.mode.wrongMode !== undefined) {
148
- const message = other.name === 'build' ? 1464 /* Diagnostics.Option_build_must_be_the_first_command_line_argument */ : this.mode.wrongMode;
137
+ const message = other.name === 'build' ? 1475 /* Diagnostics.Option_build_must_be_the_first_command_line_argument */ : this.mode.wrongMode;
149
138
  return createCompilerDiagnostic(message, name);
150
139
  }
140
+ const suggestion = getSpellingSuggestion(name, this.mode.options.names());
141
+ if (suggestion !== '')
142
+ return createCompilerDiagnostic(this.mode.unknownOptionDidYouMean, arg, suggestion);
151
143
  return createCompilerDiagnostic(this.mode.unknownOption, arg);
152
144
  }
153
145
  /** Splits a response file into arguments at whitespace; `"` quotes an argument. */
154
146
  parseResponseFile(fileName) {
155
147
  const path = getNormalizedAbsolutePath(fileName, this.host.currentDirectory);
148
+ if (this.responseFiles.has(path))
149
+ return;
150
+ this.responseFiles.add(path);
151
+ this.readResponseFile(fileName, path);
152
+ this.responseFiles.delete(path);
153
+ }
154
+ readResponseFile(fileName, path) {
156
155
  const text = this.host.readFile(path);
157
156
  if (text === undefined) {
158
- this.errors.push(createCompilerDiagnostic(1158 /* Diagnostics.Cannot_read_file_0 */, path));
157
+ this.errors.push(createCompilerDiagnostic(1165 /* Diagnostics.Cannot_read_file_0 */, path));
159
158
  return;
160
159
  }
161
160
  const args = [];
@@ -175,11 +174,11 @@ class CommandLineParser {
175
174
  pos++;
176
175
  }
177
176
  else {
178
- this.errors.push(createCompilerDiagnostic(1223 /* Diagnostics.Unterminated_quoted_string_in_response_file_0 */, path));
177
+ // The file name as written.
178
+ this.errors.push(createCompilerDiagnostic(1234 /* Diagnostics.Unterminated_quoted_string_in_response_file_0 */, fileName));
179
179
  }
180
180
  }
181
181
  else {
182
- // tsgo panics when the file ends in an argument; tsc accepts it.
183
182
  while (pos < text.length && text.charCodeAt(pos) > 32)
184
183
  pos++;
185
184
  args.push(text.slice(start, pos));
@@ -202,10 +201,10 @@ class CommandLineParser {
202
201
  this.raw.set(name, false);
203
202
  return i + 1;
204
203
  }
205
- this.errors.push(createCompilerDiagnostic(1382 /* Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line */, name));
204
+ this.errors.push(createCompilerDiagnostic(1393 /* Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line */, name));
206
205
  return value === 'true' ? i + 1 : i;
207
206
  }
208
- this.errors.push(createCompilerDiagnostic(1237 /* Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_null_on_command_line */, name));
207
+ this.errors.push(createCompilerDiagnostic(1248 /* Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_null_on_command_line */, name));
209
208
  return value !== '' && !value.startsWith('-') ? i + 1 : i;
210
209
  }
211
210
  if (next === undefined) {
@@ -234,7 +233,7 @@ class CommandLineParser {
234
233
  this.raw.set(name, value);
235
234
  }
236
235
  else {
237
- this.errors.push(createCompilerDiagnostic(1116 /* Diagnostics.Option_0_requires_value_to_be_greater_than_1 */, name, String(option.minValue ?? 0)));
236
+ this.errors.push(createCompilerDiagnostic(1123 /* Diagnostics.Option_0_requires_value_to_be_greater_than_1 */, name, String(option.minValue ?? 0)));
238
237
  }
239
238
  return i + 1;
240
239
  }
@@ -243,7 +242,11 @@ class CommandLineParser {
243
242
  this.raw.set(name, next !== 'false');
244
243
  return next === 'true' || next === 'false' ? i + 1 : i;
245
244
  case 'string':
246
- if (this.validateString(option, next))
245
+ if (!this.validateString(option, next))
246
+ return i + 1;
247
+ if (option.isFilePath === true && isNetworkPathValue(next, this.host.currentDirectory))
248
+ this.errors.push(createCompilerDiagnostic(1195 /* Diagnostics.Network_path_0_is_not_supported */, next));
249
+ else
247
250
  this.raw.set(name, next);
248
251
  return i + 1;
249
252
  case 'list': {
@@ -306,7 +309,7 @@ class CommandLineParser {
306
309
  }
307
310
  }
308
311
  else if (option.extraValidation === 'locale' && !isValidLocale(value)) {
309
- this.errors.push(createCompilerDiagnostic(1225 /* Diagnostics.Locale_must_be_an_IETF_BCP_47_language_tag_Examples_Colon_0_1 */, 'en', 'ja-jp'));
312
+ this.errors.push(createCompilerDiagnostic(1236 /* Diagnostics.Locale_must_be_an_IETF_BCP_47_language_tag_Examples_Colon_0_1 */, 'en', 'ja-jp'));
310
313
  return false;
311
314
  }
312
315
  return true;
@@ -320,7 +323,7 @@ function valueTypeName(option) {
320
323
  return option.kind;
321
324
  }
322
325
  function invalidEnumValueError(option) {
323
- return createCompilerDiagnostic(1224 /* Diagnostics.Argument_for_0_option_must_be_Colon_1 */, '--' + option.name, enumNamesList(option));
326
+ return createCompilerDiagnostic(1235 /* Diagnostics.Argument_for_0_option_must_be_Colon_1 */, '--' + option.name, enumNamesList(option));
324
327
  }
325
328
  /** `'a', 'b', 'c'`: the option's value names without deprecated ones. */
326
329
  export function enumNamesList(option) {
@@ -340,7 +343,7 @@ function specError(spec) {
340
343
  return undefined;
341
344
  const lastDotDot = spec.endsWith('/..') ? spec.length : spec.lastIndexOf('/../');
342
345
  return lastDotDot > wildcard
343
- ? 1140 /* Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0 */
346
+ ? 1147 /* Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0 */
344
347
  : undefined;
345
348
  }
346
349
  /** Parses a decimal 64-bit integer with an optional sign, like Go's `strconv.Atoi`. */