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
@@ -39,16 +39,6 @@ export declare class IterationTypes {
39
39
  hasTypes(): boolean;
40
40
  getType(kind: IterationTypeKind): Type | undefined;
41
41
  }
42
- /** A not-iterable error, reported once the file is checked so printing its type can't recurse. */
43
- export declare class DeferredIterationError {
44
- readonly errorNode: Node;
45
- readonly type: Type;
46
- readonly allowAsyncIterables: boolean;
47
- readonly related: Diagnostic[];
48
- constructor(errorNode: Node, type: Type, allowAsyncIterables: boolean, related: Diagnostic[]);
49
- }
50
- /** Reports the not-iterable errors deferred while checking a file. */
51
- export declare function produceDeferredIterationErrors(c: Checker): void;
52
42
  export declare function getGlobalIteratorType(c: Checker, isAsync: boolean): Type;
53
43
  export declare function getGlobalIterableType(c: Checker, isAsync: boolean): Type;
54
44
  export declare function getGlobalIterableIteratorType(c: Checker, isAsync: boolean): Type;
@@ -3,7 +3,7 @@
3
3
  // promised types.
4
4
  import { getExpression } from './ast.js';
5
5
  import { createDiagnosticForNode } from './checker.js';
6
- import { cachedTypeKey, } from './checker-types.js';
6
+ import { cachedTypeKey, getMappedType, } from './checker-types.js';
7
7
  import { createTypeFromGenericGlobalType, createTypeReference, filterType, getIntersectionType, getTypeArguments, getUnionType, getUnionTypeEx, isEmptyObjectType, mapType, someType, typesOf, } from './checker-type-factory.js';
8
8
  import { getBaseConstraintOfType, getBaseConstraintOrType, getIndexTypeOfType, getPropertyOfType, getReducedType, getSignaturesOfType, getTypeOfPropertyOfType, isArrayLikeType, } from './checker-members.js';
9
9
  import { getTypeOfSymbol } from './checker-symbol-types.js';
@@ -45,30 +45,13 @@ function noIterationTypes() {
45
45
  function anyIterationTypes(c) {
46
46
  return new IterationTypes(c.anyType, c.anyType, c.anyType);
47
47
  }
48
- /** A not-iterable error, reported once the file is checked so printing its type can't recurse. */
49
- export class DeferredIterationError {
50
- errorNode;
51
- type;
52
- allowAsyncIterables;
53
- related;
54
- constructor(errorNode, type, allowAsyncIterables, related) {
55
- this.errorNode = errorNode;
56
- this.type = type;
57
- this.allowAsyncIterables = allowAsyncIterables;
58
- this.related = related;
59
- }
60
- }
61
- /** Reports the not-iterable errors deferred while checking a file. */
62
- export function produceDeferredIterationErrors(c) {
63
- const errors = c.deferredIterationErrors;
64
- if (errors.length === 0)
65
- return;
66
- c.deferredIterationErrors = [];
67
- for (const e of errors) {
68
- const diagnostic = reportTypeNotIterableError(c, e.errorNode, e.type, e.allowAsyncIterables);
69
- for (const d of e.related)
48
+ /** Defers a not-iterable error, so printing its type can't resolve types that are being resolved. */
49
+ function deferTypeNotIterableError(c, errorNode, t, allowAsyncIterables, related) {
50
+ c.deferDiagnostic(errorNode, () => {
51
+ const diagnostic = reportTypeNotIterableError(c, errorNode, t, allowAsyncIterables);
52
+ for (const d of related)
70
53
  diagnostic.addRelatedInfo(d);
71
- }
54
+ });
72
55
  }
73
56
  // ---- Global types
74
57
  export function getGlobalIteratorType(c, isAsync) {
@@ -160,16 +143,16 @@ export function getIteratedTypeOrElementType(c, use, inputType, sentType, errorN
160
143
  let diagnostic;
161
144
  if ((use & 8 /* IterationUse.ForOfFlag */) !== 0)
162
145
  diagnostic =
163
- 895 /* Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_for_of_will_always_send_0 */;
146
+ 902 /* Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_for_of_will_always_send_0 */;
164
147
  else if ((use & 32 /* IterationUse.SpreadFlag */) !== 0)
165
148
  diagnostic =
166
- 896 /* Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_spread_will_always_send_0 */;
149
+ 903 /* Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_spread_will_always_send_0 */;
167
150
  else if ((use & 64 /* IterationUse.DestructuringFlag */) !== 0)
168
151
  diagnostic =
169
- 897 /* Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_destructuring_will_always_send_0 */;
152
+ 904 /* Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_destructuring_will_always_send_0 */;
170
153
  else if ((use & 16 /* IterationUse.YieldStarFlag */) !== 0)
171
154
  diagnostic =
172
- 898 /* Diagnostics.Cannot_delegate_iteration_to_value_because_the_next_method_of_its_iterator_expects_type_1_but_the_containing_generator_will_always_send_0 */;
155
+ 905 /* Diagnostics.Cannot_delegate_iteration_to_value_because_the_next_method_of_its_iterator_expects_type_1_but_the_containing_generator_will_always_send_0 */;
173
156
  if (diagnostic !== undefined)
174
157
  checkTypeRelatedTo(c, sentType, iterationTypes.nextType, c.assignableRelation, errorNode, diagnostic, undefined);
175
158
  }
@@ -235,12 +218,12 @@ class IterationDiagnosticDetails {
235
218
  }
236
219
  }
237
220
  function getIterationDiagnosticDetails(c, use, inputType, allowsStrings) {
238
- const downlevel = 934 /* Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher */;
221
+ const downlevel = 941 /* Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher */;
239
222
  if (getIterationTypeOfIterable(c, use, 0 /* IterationTypeKind.Yield */, inputType, undefined) !== undefined)
240
223
  return new IterationDiagnosticDetails(downlevel, false);
241
224
  if (inputType.symbol !== undefined && isES2015OrLaterIterable(inputType.symbol.name))
242
225
  return new IterationDiagnosticDetails(downlevel, true);
243
- return new IterationDiagnosticDetails(allowsStrings ? 655 /* Diagnostics.Type_0_is_not_an_array_type_or_a_string_type */ : 627 /* Diagnostics.Type_0_is_not_an_array_type */, true);
226
+ return new IterationDiagnosticDetails(allowsStrings ? 662 /* Diagnostics.Type_0_is_not_an_array_type_or_a_string_type */ : 634 /* Diagnostics.Type_0_is_not_an_array_type */, true);
244
227
  }
245
228
  function isES2015OrLaterIterable(name) {
246
229
  switch (name) {
@@ -260,13 +243,13 @@ function isES2015OrLaterIterable(name) {
260
243
  }
261
244
  function reportTypeNotIterableError(c, errorNode, t, allowAsyncIterables) {
262
245
  const message = allowAsyncIterables
263
- ? 664 /* Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator */
264
- : 648 /* Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator */;
246
+ ? 671 /* Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator */
247
+ : 655 /* Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator */;
265
248
  const parent = errorNode.parent;
266
249
  const suggestAwait = getAwaitedTypeOfPromise(c, t) !== undefined ||
267
250
  (!allowAsyncIterables &&
268
251
  parent !== undefined &&
269
- parent.kind === 251 /* SyntaxKind.ForOfStatement */ &&
252
+ parent.kind === 252 /* SyntaxKind.ForOfStatement */ &&
270
253
  getExpression(parent) === errorNode &&
271
254
  getGlobalIterableType(c, true) !== c.emptyGenericType &&
272
255
  isTypeAssignableTo(c, t, createTypeFromGenericGlobalType(c, getGlobalIterableType(c, true), [c.anyType, c.anyType, c.anyType])));
@@ -312,8 +295,8 @@ function getIterationTypesOfIterableWorker(c, t, use, errorNode) {
312
295
  for (const constituent of typesOf(t)) {
313
296
  const iterationTypes = getIterationTypesOfIterableWorker(c, constituent, use, undefined);
314
297
  if (!iterationTypes.hasTypes()) {
315
- if (errorNode !== undefined && c.saveDeferredDiagnostics)
316
- c.deferredIterationErrors.push(new DeferredIterationError(errorNode, t, allowAsync, []));
298
+ if (errorNode !== undefined)
299
+ deferTypeNotIterableError(c, errorNode, t, allowAsync, []);
317
300
  return noIterationTypes();
318
301
  }
319
302
  all.push(iterationTypes);
@@ -345,8 +328,8 @@ function getIterationTypesOfIterableWorker(c, t, use, errorNode) {
345
328
  return allowAsync ? getAsyncFromSyncIterationTypes(c, iterationTypes, errorNode) : iterationTypes;
346
329
  }
347
330
  }
348
- if (errorNode !== undefined && c.saveDeferredDiagnostics)
349
- c.deferredIterationErrors.push(new DeferredIterationError(errorNode, t, allowAsync, diagnostics));
331
+ if (errorNode !== undefined)
332
+ deferTypeNotIterableError(c, errorNode, t, allowAsync, diagnostics);
350
333
  return noIterationTypes();
351
334
  }
352
335
  /** Reads the iteration types of references to the global iterable types from their type arguments. */
@@ -459,11 +442,11 @@ function getIterationTypesOfMethod(c, t, isAsync, methodName, errorNode, diagnos
459
442
  if (errorNode !== undefined) {
460
443
  const message = methodName === 'next'
461
444
  ? isAsync
462
- ? 679 /* Diagnostics.An_async_iterator_must_have_a_next_method */
463
- : 649 /* Diagnostics.An_iterator_must_have_a_next_method */
445
+ ? 686 /* Diagnostics.An_async_iterator_must_have_a_next_method */
446
+ : 656 /* Diagnostics.An_iterator_must_have_a_next_method */
464
447
  : isAsync
465
- ? 900 /* Diagnostics.The_0_property_of_an_async_iterator_must_be_a_method */
466
- : 899 /* Diagnostics.The_0_property_of_an_iterator_must_be_a_method */;
448
+ ? 907 /* Diagnostics.The_0_property_of_an_async_iterator_must_be_a_method */
449
+ : 906 /* Diagnostics.The_0_property_of_an_iterator_must_be_a_method */;
467
450
  reportDiagnostic(c, createDiagnosticForNode(errorNode, message, [methodName]), diagnosticOutput);
468
451
  }
469
452
  return noIterationTypes();
@@ -483,7 +466,7 @@ function getIterationTypesOfMethod(c, t, isAsync, methodName, errorNode, diagnos
483
466
  const typeParameters = (isGeneratorMethod ? globalGeneratorType : globalIteratorType).typeParameters();
484
467
  const mapper = methodType.mapper;
485
468
  if (mapper !== undefined)
486
- return new IterationTypes(mapper.map(typeParameters[0]), mapper.map(typeParameters[1]), methodName === 'next' ? mapper.map(typeParameters[2]) : undefined);
469
+ return new IterationTypes(getMappedType(typeParameters[0], mapper), getMappedType(typeParameters[1], mapper), methodName === 'next' ? getMappedType(typeParameters[2], mapper) : undefined);
487
470
  }
488
471
  }
489
472
  // The first parameter and return type of each signature.
@@ -513,8 +496,8 @@ function getIterationTypesOfMethod(c, t, isAsync, methodName, errorNode, diagnos
513
496
  if (!iterationTypes.hasTypes()) {
514
497
  if (errorNode !== undefined)
515
498
  reportDiagnostic(c, createDiagnosticForNode(errorNode, isAsync
516
- ? 702 /* Diagnostics.The_type_returned_by_the_0_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property */
517
- : 650 /* Diagnostics.The_type_returned_by_the_0_method_of_an_iterator_must_have_a_value_property */, [methodName]), diagnosticOutput);
499
+ ? 709 /* Diagnostics.The_type_returned_by_the_0_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property */
500
+ : 657 /* Diagnostics.The_type_returned_by_the_0_method_of_an_iterator_must_have_a_value_property */, [methodName]), diagnosticOutput);
518
501
  yieldType = c.anyType;
519
502
  returnTypes.push(c.anyType);
520
503
  }
@@ -676,7 +659,7 @@ export function getAwaitedTypeNoAliasEx(c, t, errorNode, message) {
676
659
  if (errorNode !== undefined && message !== undefined) {
677
660
  let chain;
678
661
  if (promised.thisTypeForError !== undefined)
679
- chain = createDiagnosticForNode(errorNode, 817 /* Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1 */, [typeToString(c, t), typeToString(c, promised.thisTypeForError)]);
662
+ chain = createDiagnosticForNode(errorNode, 824 /* Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1 */, [typeToString(c, t), typeToString(c, promised.thisTypeForError)]);
680
663
  const diagnostic = createDiagnosticForNode(errorNode, message, []);
681
664
  if (chain !== undefined) {
682
665
  diagnostic.addMessageChain(chain);
@@ -799,7 +782,7 @@ function getPromisedTypeOfPromiseWorker(c, t, errorNode) {
799
782
  }
800
783
  if (candidates.length === 0) {
801
784
  if (errorNode !== undefined)
802
- c.error(errorNode, 817 /* Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1 */, typeToString(c, t), typeToString(c, thisTypeForError));
785
+ c.error(errorNode, 824 /* Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1 */, typeToString(c, t), typeToString(c, thisTypeForError));
803
786
  return new PromisedType(undefined, thisTypeForError);
804
787
  }
805
788
  const onfulfilledParameterType = getTypeWithFacts(c, getUnionType(c, getTypesOfFirstParameterOfSignatures(c, candidates)), 2097152 /* TypeFacts.NEUndefinedOrNull */);
@@ -844,14 +827,14 @@ export function createPromiseLikeType(c, promisedType) {
844
827
  export function createPromiseReturnType(c, func, promisedType) {
845
828
  const promiseType = createPromiseType(c, promisedType);
846
829
  if (promiseType === c.unknownType) {
847
- c.error(func, func.kind === 214 /* SyntaxKind.CallExpression */
848
- ? 843 /* Diagnostics.A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option */
849
- : 829 /* Diagnostics.An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option */);
830
+ c.error(func, func.kind === 215 /* SyntaxKind.CallExpression */
831
+ ? 850 /* Diagnostics.A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option */
832
+ : 836 /* Diagnostics.An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option */);
850
833
  return c.errorType;
851
834
  }
852
835
  if (getGlobalValueSymbol(c, 'Promise', true) === undefined)
853
- c.error(func, func.kind === 214 /* SyntaxKind.CallExpression */
854
- ? 844 /* Diagnostics.A_dynamic_import_call_in_ES5_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option */
855
- : 837 /* Diagnostics.An_async_function_or_method_in_ES5_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option */);
836
+ c.error(func, func.kind === 215 /* SyntaxKind.CallExpression */
837
+ ? 851 /* Diagnostics.A_dynamic_import_call_in_ES5_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option */
838
+ : 844 /* Diagnostics.An_async_function_or_method_in_ES5_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option */);
856
839
  return promiseType;
857
840
  }
@@ -100,7 +100,7 @@ function getAssignmentDeclarationInitializerType(c, node) {
100
100
  }
101
101
  return t;
102
102
  }
103
- if (node.kind === 214 /* SyntaxKind.CallExpression */)
103
+ if (node.kind === 215 /* SyntaxKind.CallExpression */)
104
104
  return getTypeFromPropertyDescriptor(c, getArguments(node).nodes[2]);
105
105
  return undefined;
106
106
  }
@@ -116,7 +116,7 @@ function hasParentWithTypeAnnotation(c, symbol) {
116
116
  if (parent === undefined || parent.valueDeclaration === undefined)
117
117
  return false;
118
118
  const kind = parent.valueDeclaration.kind;
119
- if (kind !== 219 /* SyntaxKind.FunctionExpression */ && kind !== 220 /* SyntaxKind.ArrowFunction */)
119
+ if (kind !== 220 /* SyntaxKind.FunctionExpression */ && kind !== 221 /* SyntaxKind.ArrowFunction */)
120
120
  return false;
121
121
  const annotated = getSymbolOfDeclaration(c, parent.valueDeclaration.parent);
122
122
  return (annotated !== undefined &&
@@ -178,7 +178,7 @@ function getThisAssignmentKind(c, symbol) {
178
178
  }
179
179
  const left = declaration.left;
180
180
  if (getAssignmentDeclarationKind(declaration) === 3 /* JSDeclarationKind.ThisProperty */ &&
181
- (left.kind !== 213 /* SyntaxKind.ElementAccessExpression */ || isStringOrNumericLiteralLike(getArgumentExpression(left)))) {
181
+ (left.kind !== 214 /* SyntaxKind.ElementAccessExpression */ || isStringOrNumericLiteralLike(getArgumentExpression(left)))) {
182
182
  if (declaration.type !== undefined)
183
183
  typeAnnotation = declaration.type;
184
184
  }
@@ -213,7 +213,7 @@ export function isConstructorDeclaredThisProperty(c, symbol) {
213
213
  function getDeclaringConstructor(symbol) {
214
214
  for (const declaration of getDeclarations(symbol)) {
215
215
  const container = getThisContainer(declaration, false, false);
216
- if (container.kind === 177 /* SyntaxKind.Constructor */)
216
+ if (container.kind === 178 /* SyntaxKind.Constructor */)
217
217
  return container;
218
218
  }
219
219
  return undefined;
@@ -243,7 +243,7 @@ export function getFlowTypeOfAutoTypedProperty(c, reference, prop) {
243
243
  /** The leftmost expression of a property access, element access or call chain. */
244
244
  function getLeftmostAccessExpression(node) {
245
245
  let current = node;
246
- while (isAccessExpression(current) || current.kind === 214 /* SyntaxKind.CallExpression */)
246
+ while (isAccessExpression(current) || current.kind === 215 /* SyntaxKind.CallExpression */)
247
247
  current = getExpression(current);
248
248
  return current;
249
249
  }
@@ -267,7 +267,7 @@ export function getContextualTypeForAssignmentExpression(c, binary) {
267
267
  break;
268
268
  // `F.id = expr` takes a contextual type only from an annotated variable F.
269
269
  const declaration = symbol.valueDeclaration;
270
- if (declaration === undefined || declaration.kind !== 261 /* SyntaxKind.VariableDeclaration */)
270
+ if (declaration === undefined || declaration.kind !== 262 /* SyntaxKind.VariableDeclaration */)
271
271
  return undefined;
272
272
  const typeNode = getType(declaration);
273
273
  if (typeNode === undefined)
@@ -279,8 +279,8 @@ export function getContextualTypeForAssignmentExpression(c, binary) {
279
279
  return getTypeOfPropertyOfContextualType(c, getTypeFromTypeNode(c, typeNode), getPropertyNameFromType(nameType));
280
280
  return getTypeOfExpression(c, left);
281
281
  }
282
- case 212 /* SyntaxKind.PropertyAccessExpression */:
283
- case 213 /* SyntaxKind.ElementAccessExpression */:
282
+ case 213 /* SyntaxKind.PropertyAccessExpression */:
283
+ case 214 /* SyntaxKind.ElementAccessExpression */:
284
284
  if (binary.symbol !== undefined)
285
285
  return undefined;
286
286
  break;
@@ -304,7 +304,7 @@ export function getContextualTypeForAssignmentExpression(c, binary) {
304
304
  const d = symbol?.valueDeclaration;
305
305
  // `this.x = expr` where x is a property with no type annotation or initializer.
306
306
  if (d !== undefined &&
307
- (d.kind === 173 /* SyntaxKind.PropertyDeclaration */ || d.kind === 172 /* SyntaxKind.PropertySignature */) &&
307
+ (d.kind === 174 /* SyntaxKind.PropertyDeclaration */ || d.kind === 173 /* SyntaxKind.PropertySignature */) &&
308
308
  getType(d) === undefined &&
309
309
  getInitializer(d) === undefined)
310
310
  return undefined;
@@ -332,9 +332,9 @@ export function isCommonJSRequire(c, node) {
332
332
  return false;
333
333
  let kind = 0 /* SyntaxKind.Unknown */;
334
334
  if ((resolved.flags & 16 /* SymbolFlags.Function */) !== 0)
335
- kind = 263 /* SyntaxKind.FunctionDeclaration */;
335
+ kind = 264 /* SyntaxKind.FunctionDeclaration */;
336
336
  else if ((resolved.flags & 3 /* SymbolFlags.Variable */) !== 0)
337
- kind = 261 /* SyntaxKind.VariableDeclaration */;
337
+ kind = 262 /* SyntaxKind.VariableDeclaration */;
338
338
  if (kind === 0 /* SyntaxKind.Unknown */)
339
339
  return false;
340
340
  const declaration = getDeclarationOfKind(resolved, kind);
@@ -342,7 +342,7 @@ export function isCommonJSRequire(c, node) {
342
342
  }
343
343
  /** The type of the module a `require("m")` call names. */
344
344
  export function resolveExternalModuleTypeByLiteral(c, name) {
345
- const moduleSymbol = resolveExternalModuleName(c, name, name, false);
345
+ const moduleSymbol = resolveExternalModuleName(c, name, name, false, undefined);
346
346
  if (moduleSymbol !== undefined) {
347
347
  const resolved = resolveExternalModuleSymbol(c, moduleSymbol, false);
348
348
  if (resolved !== undefined)
@@ -352,7 +352,7 @@ export function resolveExternalModuleTypeByLiteral(c, name) {
352
352
  }
353
353
  /** Whether a JavaScript declaration declares an alias: a `require` or an exported entity name. */
354
354
  export function isJSAliasDeclaration(node) {
355
- if (node.kind !== 227 /* SyntaxKind.BinaryExpression */)
355
+ if (node.kind !== 228 /* SyntaxKind.BinaryExpression */)
356
356
  return isVariableDeclarationInitializedToRequire(node);
357
357
  const kind = getAssignmentDeclarationKind(node);
358
358
  return ((kind === 1 /* JSDeclarationKind.ModuleExports */ || kind === 2 /* JSDeclarationKind.ExportsProperty */) &&
@@ -361,7 +361,7 @@ export function isJSAliasDeclaration(node) {
361
361
  /** `this` in `obj.x = function () {}` is `obj`, except for CommonJS `exports.x = function () {}`. */
362
362
  export function getThisTypeOfAssignedFunction(c, func) {
363
363
  let parent = func.parent;
364
- while (parent.kind === 218 /* SyntaxKind.ParenthesizedExpression */)
364
+ while (parent.kind === 219 /* SyntaxKind.ParenthesizedExpression */)
365
365
  parent = parent.parent;
366
366
  // Compound assignments like `??=` count too.
367
367
  if (!(parent instanceof BinaryExpression) ||
@@ -11,6 +11,8 @@ export declare function getSignatureOfFullSignatureType(c: Checker, node: Node):
11
11
  export declare function getParameterTypeOfFullSignature(c: Checker, fn: Node, parameter: Node): Type | undefined;
12
12
  /** The return type of a function typed by a JSDoc `@type` tag. */
13
13
  export declare function getReturnTypeOfFullSignature(c: Checker, fn: Node): Type | undefined;
14
+ /** Checks the type of a JSDoc `@type` on a function as a type node. */
15
+ export declare function checkJSDocFullSignatureType(c: Checker, fn: Node): void;
14
16
  /** A JSDoc `@type` on a function needs a call signature taking at least its parameters. */
15
17
  export declare function checkJSDocFullSignature(c: Checker, fn: Node): void;
16
18
  /**
@@ -18,13 +20,9 @@ export declare function checkJSDocFullSignature(c: Checker, fn: Node): void;
18
20
  * without a parent `@param {object}`.
19
21
  */
20
22
  export declare function checkUnmatchedJSDocParameters(c: Checker, node: Node): void;
21
- /** An `@augments` or `@extends` tag naming another class than the `extends` clause. */
22
- export declare class AugmentsMismatch {
23
- readonly name: Node;
24
- readonly tagName: string;
25
- readonly className: string;
26
- readonly extendsName: string;
27
- constructor(name: Node, tagName: string, className: string, extendsName: string);
28
- }
29
- /** The `@augments` or `@extends` tag of a class whose class name differs from its `extends` clause. */
30
- export declare function findMismatchedAugmentsTag(classLike: Node, extendsType: ExpressionWithTypeArguments): AugmentsMismatch | undefined;
23
+ /**
24
+ * Reports an `@augments` or `@extends` tag of a JavaScript class whose class doesn't match the
25
+ * `extends` clause: for an entity name, a different type; for another expression, a type the base
26
+ * type isn't assignable to.
27
+ */
28
+ export declare function checkJSDocAugmentsTagMatchesExtends(c: Checker, node: Node, baseTypeNode: ExpressionWithTypeArguments, baseType: Type): void;
@@ -1,7 +1,8 @@
1
1
  // JSDoc semantics: the intended types of JSDoc type references like `String`, `function` and
2
2
  // `Object<K, V>`, functions typed by a JSDoc `@type` tag, and `@param` tags without parameters.
3
3
  import { ArrowFunction, FunctionDeclaration, FunctionExpression, MethodDeclaration, NodeVisitor, getBody, getDotDotDotToken, getExpression, getInitializer, getName, getParameters, getText, getType, } from './ast.js';
4
- import { getSourceFileOfNode, isTypeNodeKind } from './binder-utilities.js';
4
+ import { getSourceFileOfNode, getSourceTextOfNode, isEntityNameExpression, isTypeNodeKind, } from './binder-utilities.js';
5
+ import { isTypeAssignableTo, isTypeIdenticalTo } from './relations.js';
5
6
  import { getAttachedJSDoc, getJSDoc } from './parser.js';
6
7
  import { isInJSFile } from './ast-utilities.js';
7
8
  import { getGlobalTypeAliasSymbol } from './checker-symbols.js';
@@ -12,9 +13,10 @@ import { getRestTypeAtPosition, getReturnTypeOfSignature, getSingleCallSignature
12
13
  import { getContextualCallSignature } from './checker-contextual.js';
13
14
  import { entityNameToString, getResolvedSymbol } from './checker-expressions.js';
14
15
  import { isArrayType } from './checker-type-factory.js';
16
+ import { checkSourceElement } from './checker-source-file.js';
15
17
  /** The type a JSDoc type reference to a JavaScript-style name means, if it is one. */
16
18
  export function getIntendedTypeFromJSDocTypeReference(c, node) {
17
- if ((node.flags & 4194304 /* NodeFlags.JSDoc */) === 0 || node.kind !== 184 /* SyntaxKind.TypeReference */)
19
+ if ((node.flags & 4194304 /* NodeFlags.JSDoc */) === 0 || node.kind !== 185 /* SyntaxKind.TypeReference */)
18
20
  return undefined;
19
21
  const reference = node;
20
22
  const typeName = reference.typeName;
@@ -108,13 +110,19 @@ export function getReturnTypeOfFullSignature(c, fn) {
108
110
  const signature = getSignatureOfFullSignatureType(c, fn);
109
111
  return signature !== undefined ? getReturnTypeOfSignature(c, signature) : undefined;
110
112
  }
113
+ /** Checks the type of a JSDoc `@type` on a function as a type node. */
114
+ export function checkJSDocFullSignatureType(c, fn) {
115
+ const typeNode = getFullSignatureTypeNode(fn);
116
+ if (typeNode !== undefined)
117
+ checkSourceElement(c, typeNode);
118
+ }
111
119
  /** A JSDoc `@type` on a function needs a call signature taking at least its parameters. */
112
120
  export function checkJSDocFullSignature(c, fn) {
113
121
  const typeNode = getFullSignatureTypeNode(fn);
114
122
  if (typeNode === undefined)
115
123
  return;
116
124
  if (getContextualCallSignature(c, getTypeFromTypeNode(c, typeNode), fn) === undefined)
117
- c.error(typeNode, 1759 /* Diagnostics.A_JSDoc_type_tag_on_a_function_must_have_a_signature_with_the_correct_number_of_arguments */);
125
+ c.error(typeNode, 1779 /* Diagnostics.A_JSDoc_type_tag_on_a_function_must_have_a_signature_with_the_correct_number_of_arguments */);
118
126
  }
119
127
  // ---- `@param` tags
120
128
  /** The tags of the last JSDoc comment of `node` or of the declaration or statement it heads. */
@@ -137,16 +145,16 @@ function getNextJSDocCommentLocation(node) {
137
145
  if (parent === undefined)
138
146
  return undefined;
139
147
  switch (parent.kind) {
140
- case 303 /* SyntaxKind.PropertyAssignment */:
141
- case 278 /* SyntaxKind.ExportAssignment */:
142
- case 173 /* SyntaxKind.PropertyDeclaration */:
143
- case 261 /* SyntaxKind.VariableDeclaration */:
144
- case 239 /* SyntaxKind.SatisfiesExpression */:
145
- case 254 /* SyntaxKind.ReturnStatement */:
146
- case 244 /* SyntaxKind.VariableStatement */:
147
- case 245 /* SyntaxKind.ExpressionStatement */:
148
+ case 304 /* SyntaxKind.PropertyAssignment */:
149
+ case 279 /* SyntaxKind.ExportAssignment */:
150
+ case 174 /* SyntaxKind.PropertyDeclaration */:
151
+ case 262 /* SyntaxKind.VariableDeclaration */:
152
+ case 240 /* SyntaxKind.SatisfiesExpression */:
153
+ case 255 /* SyntaxKind.ReturnStatement */:
154
+ case 245 /* SyntaxKind.VariableStatement */:
155
+ case 246 /* SyntaxKind.ExpressionStatement */:
148
156
  return parent;
149
- case 262 /* SyntaxKind.VariableDeclarationList */:
157
+ case 263 /* SyntaxKind.VariableDeclarationList */:
150
158
  return parent.declarations.nodes[0] === node ? parent : undefined;
151
159
  }
152
160
  return undefined;
@@ -164,7 +172,7 @@ export function checkUnmatchedJSDocParameters(c, node) {
164
172
  return;
165
173
  const jsdocParameters = [];
166
174
  for (const tag of getAllJSDocTags(node)) {
167
- if (tag.kind !== 333 /* SyntaxKind.JSDocParameterTag */)
175
+ if (tag.kind !== 334 /* SyntaxKind.JSDocParameterTag */)
168
176
  continue;
169
177
  const name = tag.name;
170
178
  if (name.kind === 79 /* SyntaxKind.Identifier */ && getText(name).length === 0)
@@ -180,7 +188,7 @@ export function checkUnmatchedJSDocParameters(c, node) {
180
188
  const name = getName(params[i]);
181
189
  if (name.kind === 79 /* SyntaxKind.Identifier */)
182
190
  parameters.add(getText(name));
183
- if (name.kind === 207 /* SyntaxKind.ObjectBindingPattern */ || name.kind === 208 /* SyntaxKind.ArrayBindingPattern */)
191
+ if (name.kind === 208 /* SyntaxKind.ObjectBindingPattern */ || name.kind === 209 /* SyntaxKind.ArrayBindingPattern */)
184
192
  excludedParameters.add(i);
185
193
  }
186
194
  if (containsArgumentsReference(c, node)) {
@@ -196,7 +204,7 @@ export function checkUnmatchedJSDocParameters(c, node) {
196
204
  const typeNode = typeExpression !== undefined ? getType(typeExpression) : undefined;
197
205
  if (typeNode === undefined || isArrayType(c, getTypeFromTypeNode(c, typeNode)))
198
206
  return;
199
- c.error(last.name, 1758 /* Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type */, getText(last.name));
207
+ c.error(last.name, 1778 /* Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type */, getText(last.name));
200
208
  return;
201
209
  }
202
210
  if (!isJs)
@@ -206,10 +214,10 @@ export function checkUnmatchedJSDocParameters(c, node) {
206
214
  const name = tag.name;
207
215
  if (excludedParameters.has(index) || (name.kind === 79 /* SyntaxKind.Identifier */ && parameters.has(getText(name))))
208
216
  continue;
209
- if (name.kind === 167 /* SyntaxKind.QualifiedName */)
210
- c.error(name, 1761 /* Diagnostics.Qualified_name_0_is_not_allowed_without_a_leading_param_object_1 */, entityNameToString(name), entityNameToString(name.left));
217
+ if (name.kind === 168 /* SyntaxKind.QualifiedName */)
218
+ c.error(name, 1781 /* Diagnostics.Qualified_name_0_is_not_allowed_without_a_leading_param_object_1 */, entityNameToString(name), entityNameToString(name.left));
211
219
  else if (!tag.isNameFirst)
212
- c.error(name, 1753 /* Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name */, getText(name));
220
+ c.error(name, 1773 /* Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name */, getText(name));
213
221
  }
214
222
  }
215
223
  /** Finds a reference to `arguments` outside nested functions and types. */
@@ -223,19 +231,19 @@ class ArgumentsReferenceFinder extends NodeVisitor {
223
231
  switch (node.kind) {
224
232
  case 79 /* SyntaxKind.Identifier */:
225
233
  return getText(node) === 'arguments' && getResolvedSymbol(this.c, node) === this.c.argumentsSymbol;
226
- case 173 /* SyntaxKind.PropertyDeclaration */:
227
- case 175 /* SyntaxKind.MethodDeclaration */:
228
- case 178 /* SyntaxKind.GetAccessor */:
229
- case 179 /* SyntaxKind.SetAccessor */: {
234
+ case 174 /* SyntaxKind.PropertyDeclaration */:
235
+ case 176 /* SyntaxKind.MethodDeclaration */:
236
+ case 179 /* SyntaxKind.GetAccessor */:
237
+ case 180 /* SyntaxKind.SetAccessor */: {
230
238
  const name = getName(node);
231
- if (name !== undefined && name.kind === 168 /* SyntaxKind.ComputedPropertyName */)
239
+ if (name !== undefined && name.kind === 169 /* SyntaxKind.ComputedPropertyName */)
232
240
  return this.visitNode(name);
233
241
  break;
234
242
  }
235
- case 212 /* SyntaxKind.PropertyAccessExpression */:
236
- case 213 /* SyntaxKind.ElementAccessExpression */:
243
+ case 213 /* SyntaxKind.PropertyAccessExpression */:
244
+ case 214 /* SyntaxKind.ElementAccessExpression */:
237
245
  return this.visitNode(getExpression(node));
238
- case 303 /* SyntaxKind.PropertyAssignment */:
246
+ case 304 /* SyntaxKind.PropertyAssignment */:
239
247
  return this.visitNode(getInitializer(node));
240
248
  }
241
249
  if (startsNewLexicalEnvironment(node) || isTypeNodeKind(node.kind))
@@ -245,15 +253,15 @@ class ArgumentsReferenceFinder extends NodeVisitor {
245
253
  }
246
254
  function startsNewLexicalEnvironment(node) {
247
255
  switch (node.kind) {
248
- case 177 /* SyntaxKind.Constructor */:
249
- case 219 /* SyntaxKind.FunctionExpression */:
250
- case 263 /* SyntaxKind.FunctionDeclaration */:
251
- case 220 /* SyntaxKind.ArrowFunction */:
252
- case 175 /* SyntaxKind.MethodDeclaration */:
253
- case 178 /* SyntaxKind.GetAccessor */:
254
- case 179 /* SyntaxKind.SetAccessor */:
255
- case 268 /* SyntaxKind.ModuleDeclaration */:
256
- case 307 /* SyntaxKind.SourceFile */:
256
+ case 178 /* SyntaxKind.Constructor */:
257
+ case 220 /* SyntaxKind.FunctionExpression */:
258
+ case 264 /* SyntaxKind.FunctionDeclaration */:
259
+ case 221 /* SyntaxKind.ArrowFunction */:
260
+ case 176 /* SyntaxKind.MethodDeclaration */:
261
+ case 179 /* SyntaxKind.GetAccessor */:
262
+ case 180 /* SyntaxKind.SetAccessor */:
263
+ case 269 /* SyntaxKind.ModuleDeclaration */:
264
+ case 308 /* SyntaxKind.SourceFile */:
257
265
  return true;
258
266
  }
259
267
  return false;
@@ -280,41 +288,42 @@ function containsArgumentsReference(c, node) {
280
288
  function getIdentifierFromEntityNameExpression(node) {
281
289
  if (node.kind === 79 /* SyntaxKind.Identifier */)
282
290
  return node;
283
- if (node.kind === 212 /* SyntaxKind.PropertyAccessExpression */)
291
+ if (node.kind === 213 /* SyntaxKind.PropertyAccessExpression */)
284
292
  return getName(node);
285
293
  return undefined;
286
294
  }
287
- /** An `@augments` or `@extends` tag naming another class than the `extends` clause. */
288
- export class AugmentsMismatch {
289
- name;
290
- tagName;
291
- className;
292
- extendsName;
293
- constructor(name, tagName, className, extendsName) {
294
- this.name = name;
295
- this.tagName = tagName;
296
- this.className = className;
297
- this.extendsName = extendsName;
298
- }
299
- }
300
- /** The `@augments` or `@extends` tag of a class whose class name differs from its `extends` clause. */
301
- export function findMismatchedAugmentsTag(classLike, extendsType) {
302
- const jsDoc = getAttachedJSDoc(classLike);
295
+ /**
296
+ * Reports an `@augments` or `@extends` tag of a JavaScript class whose class doesn't match the
297
+ * `extends` clause: for an entity name, a different type; for another expression, a type the base
298
+ * type isn't assignable to.
299
+ */
300
+ export function checkJSDocAugmentsTagMatchesExtends(c, node, baseTypeNode, baseType) {
301
+ if (!isInJSFile(node))
302
+ return;
303
+ const jsDoc = getAttachedJSDoc(node);
303
304
  if (jsDoc === undefined)
304
- return undefined;
305
+ return;
305
306
  for (const j of jsDoc) {
306
307
  const tags = j.tags;
307
308
  if (tags === undefined)
308
309
  continue;
309
310
  for (const tag of tags.nodes) {
310
- if (tag.kind !== 323 /* SyntaxKind.JSDocAugmentsTag */)
311
+ if (tag.kind !== 324 /* SyntaxKind.JSDocAugmentsTag */)
311
312
  continue;
312
313
  const augments = tag;
313
- const targetName = getIdentifierFromEntityNameExpression(extendsType.expression);
314
+ const sourceType = getTypeFromTypeNode(c, augments.className);
314
315
  const sourceName = getIdentifierFromEntityNameExpression(augments.className.expression);
315
- if (targetName !== undefined && sourceName !== undefined && getText(targetName) !== getText(sourceName))
316
- return new AugmentsMismatch(sourceName, getText(augments.tagName), getText(sourceName), getText(targetName));
316
+ if (isEntityNameExpression(baseTypeNode.expression, false)) {
317
+ if (isTypeIdenticalTo(c, sourceType, baseType))
318
+ continue;
319
+ const targetName = getIdentifierFromEntityNameExpression(baseTypeNode.expression);
320
+ if (targetName !== undefined && sourceName !== undefined)
321
+ c.error(sourceName, 1772 /* Diagnostics.JSDoc_0_1_does_not_match_the_extends_2_clause */, getText(augments.tagName), getText(sourceName), getText(targetName));
322
+ }
323
+ else if (sourceName !== undefined && !isTypeAssignableTo(c, baseType, sourceType)) {
324
+ const expression = baseTypeNode.expression;
325
+ c.error(sourceName, 1772 /* Diagnostics.JSDoc_0_1_does_not_match_the_extends_2_clause */, getText(augments.tagName), getText(sourceName), getSourceTextOfNode(getSourceFileOfNode(expression), expression));
326
+ }
317
327
  }
318
328
  }
319
- return undefined;
320
329
  }