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
@@ -10,7 +10,6 @@
10
10
  // - grammar: checker-grammar.ts (checks the parser leaves to the checker)
11
11
  // - type nodes: `checkTypeNode` below
12
12
  import { checkPendingExternalEmitHelpers } from './checker-emit-helpers.js';
13
- import { produceDeferredCollisionChecks } from './checker-generated-code.js';
14
13
  import { resolveUntypedCall } from './checker-calls.js';
15
14
  import { NodeVisitor, getComment, getElements, getExpression, getName, getParameters, getText, getNodeId, getStatements, getType, getTypeParameters, getHeritageClauses, getFlowNode, } from './ast.js';
16
15
  import { getSourceFileOfNode, isEnumConst, isExternalOrCommonJSModule, isPotentiallyExecutableNode, } from './binder-utilities.js';
@@ -23,23 +22,22 @@ import { nodeIsMissing } from './ast-utilities.js';
23
22
  import { getAttachedJSDoc } from './parser.js';
24
23
  import { shouldPreserveConstEnums } from './options.js';
25
24
  import { isReachableFlowNode } from './checker-narrowing.js';
26
- import { getTupleElementFlags, getTypeFromIndexedAccessTypeNode, getTypeFromTypeNode } from './checker-type-nodes.js';
25
+ import { getTupleElementFlags, getTypeFromIndexedAccessTypeNode, getTypeFromTypeNode, isAssertionExpression, } from './checker-type-nodes.js';
27
26
  import { isArrayLikeType } from './checker-members.js';
28
27
  import { checkBlock, checkDoStatement, checkExpressionStatement, checkForInStatement, checkForOfStatement, checkForStatement, checkIfStatement, checkLabeledStatement, checkReturnStatement, checkSwitchStatement, checkThrowStatement, checkTryStatement, checkWhileStatement, } from './checker-statements.js';
29
28
  import { checkEnumDeclaration, checkEnumMember, checkExternalModuleExports, checkFunctionDeclaration, checkModuleDeclaration, checkTypeAliasDeclaration, checkTypeArgumentConstraintsOfReference, checkTypeParameter, checkTypeParameterDeferred, checkTypeParameters, checkVariableStatement, checkVariableLikeDeclaration, checkUnusedRenamedBindingElements, isInstantiatedModule, } from './checker-declarations.js';
30
- import { checkExportAssignment, checkExportDeclaration, checkImportDeclaration, checkImportEqualsDeclaration, resolveJSDocMemberName, } from './checker-modules.js';
29
+ import { checkExportAssignment, checkExportDeclaration, checkImportAttributes, checkImportDeclaration, checkImportEqualsDeclaration, resolveJSDocMemberName, } from './checker-modules.js';
31
30
  import { checkAccessorDeclaration, checkClassDeclaration, checkClassLikeDeferred, checkInterfaceDeclaration, } from './checker-classes.js';
32
31
  import { checkJsxElementDeferred } from './checker-jsx.js';
33
- import { checkAssertionDeferred, checkComputedPropertyName, checkExpression, checkIndexedAccessIndexType, } from './checker-expressions.js';
32
+ import { checkAssertionDeferred, checkComputedPropertyName, checkExpression, checkIndexedAccessIndexType, isConstTypeReference, } from './checker-expressions.js';
34
33
  import { checkFunctionLikeBody } from './checker-functions.js';
35
- import { produceDeferredIterationErrors } from './checker-iteration.js';
36
34
  import { checkFunctionOrMethodSymbols } from './checker-overloads.js';
37
35
  import { checkInferTypeParameterDeclarations, checkTypeLiteralMembers } from './checker-heritage.js';
38
36
  import { checkGrammarSourceFile } from './checker-grammar.js';
39
37
  import { getTypeOfSymbol, reportImplicitAny } from './checker-symbol-types.js';
40
38
  import { getSymbolOfDeclaration } from './checker-symbols.js';
41
39
  import { checkUnusedIdentifiers } from './checker-unused.js';
42
- import { checkDeprecatedTypeReference } from './checker-deprecation.js';
40
+ import { checkContextualDeprecations, checkDeprecatedTypeReference } from './checker-deprecation.js';
43
41
  /**
44
42
  * Checks `file` once; diagnostics accumulate in the checker. `checkUnused` also reports unused
45
43
  * identifiers, which need the whole file checked first.
@@ -57,7 +55,6 @@ export function checkSourceFile(c, file, checkUnused = false) {
57
55
  }
58
56
  function checkSourceFileWorker(c, file) {
59
57
  c.fileBeingChecked = file;
60
- c.saveDeferredDiagnostics = true;
61
58
  for (const statement of getStatements(file).nodes)
62
59
  checkSourceElement(c, statement);
63
60
  checkDeferredNodes(c, file);
@@ -73,9 +70,7 @@ function checkSourceFileWorker(c, file) {
73
70
  checkDeferredNodes(c, file);
74
71
  checkPendingExternalEmitHelpers(c, file);
75
72
  c.fileBeingChecked = undefined;
76
- c.saveDeferredDiagnostics = false;
77
- produceDeferredIterationErrors(c);
78
- produceDeferredCollisionChecks(c);
73
+ produceDeferredDiagnostics(c);
79
74
  // The file's deferred nodes are all checked; later ones are not queued (checkNodeDeferred).
80
75
  const links = c.nodeLinks(file);
81
76
  links.typeChecked = true;
@@ -95,7 +90,6 @@ function checkSourceFileWorker(c, file) {
95
90
  export function checkSourceFileRange(c, file, start, end) {
96
91
  const statements = getStatements(file).nodes;
97
92
  c.fileBeingChecked = file;
98
- c.saveDeferredDiagnostics = true;
99
93
  for (let i = start; i < end; i++)
100
94
  checkSourceElement(c, statements[i]);
101
95
  checkDeferredNodes(c, file);
@@ -109,13 +103,24 @@ export function checkSourceFileRange(c, file, start, end) {
109
103
  checkPendingExternalEmitHelpers(c, file);
110
104
  }
111
105
  c.fileBeingChecked = undefined;
112
- c.saveDeferredDiagnostics = false;
113
- produceDeferredIterationErrors(c);
114
- produceDeferredCollisionChecks(c);
106
+ produceDeferredDiagnostics(c);
115
107
  // Deferred nodes of a later range are queued again (checkNodeDeferred).
116
108
  c.nodeLinks(file).deferredNodes = undefined;
117
109
  return c.diagnostics.forFile(file.fileName).length > 0;
118
110
  }
111
+ /**
112
+ * Reports the deferred diagnostics, in the order they were deferred. Diagnostics deferred while they
113
+ * are reported are dropped.
114
+ */
115
+ export function produceDeferredDiagnostics(c) {
116
+ const callbacks = c.deferredDiagnostics;
117
+ if (callbacks.length === 0)
118
+ return;
119
+ const count = callbacks.length;
120
+ for (let i = 0; i < count; i++)
121
+ callbacks[i]();
122
+ c.deferredDiagnostics = [];
123
+ }
119
124
  /** Checks a statement, declaration, class member or type node. */
120
125
  export function checkSourceElement(c, node) {
121
126
  if (node === undefined)
@@ -154,16 +159,16 @@ function checkSourceElementUnreachable(c, node) {
154
159
  }
155
160
  // A missing statement starts where it ends, before the trivia of the next token.
156
161
  const start = nodeIsMissing(node) ? node.pos : skipTrivia(file.text, node.pos);
157
- const diagnostic = new Diagnostic(file.diagnosticFile(), start, endNode.end, 1698 /* Diagnostics.Unreachable_code_detected */, []);
162
+ const diagnostic = new Diagnostic(file.diagnosticFile(), start, endNode.end, 1717 /* Diagnostics.Unreachable_code_detected */, []);
158
163
  c.addErrorOrSuggestion(c.compilerOptions.allowUnreachableCode === false, diagnostic);
159
164
  return true;
160
165
  }
161
166
  function isSourceElementUnreachable(c, node) {
162
167
  if ((node.flags & 134217728 /* NodeFlags.Unreachable */) !== 0) {
163
168
  // The binder knows the code is unreachable; const enums only count when preserved.
164
- if (node.kind === 267 /* SyntaxKind.EnumDeclaration */)
169
+ if (node.kind === 268 /* SyntaxKind.EnumDeclaration */)
165
170
  return !isEnumConst(node) || shouldPreserveConstEnums(c.compilerOptions);
166
- if (node.kind === 268 /* SyntaxKind.ModuleDeclaration */)
171
+ if (node.kind === 269 /* SyntaxKind.ModuleDeclaration */)
167
172
  return isInstantiatedModule(node, shouldPreserveConstEnums(c.compilerOptions));
168
173
  return true;
169
174
  }
@@ -186,98 +191,98 @@ function checkSourceElementWorker(c, node) {
186
191
  c.withinUnreachableCode = true;
187
192
  switch (node.kind) {
188
193
  // Statements
189
- case 242 /* SyntaxKind.Block */:
190
- case 269 /* SyntaxKind.ModuleBlock */:
194
+ case 243 /* SyntaxKind.Block */:
195
+ case 270 /* SyntaxKind.ModuleBlock */:
191
196
  checkBlock(c, node);
192
197
  return;
193
- case 243 /* SyntaxKind.EmptyStatement */:
194
- case 260 /* SyntaxKind.DebuggerStatement */:
195
- case 253 /* SyntaxKind.BreakStatement */:
196
- case 252 /* SyntaxKind.ContinueStatement */:
198
+ case 244 /* SyntaxKind.EmptyStatement */:
199
+ case 261 /* SyntaxKind.DebuggerStatement */:
200
+ case 254 /* SyntaxKind.BreakStatement */:
201
+ case 253 /* SyntaxKind.ContinueStatement */:
197
202
  return;
198
- case 244 /* SyntaxKind.VariableStatement */:
203
+ case 245 /* SyntaxKind.VariableStatement */:
199
204
  checkVariableStatement(c, node);
200
205
  return;
201
- case 245 /* SyntaxKind.ExpressionStatement */:
206
+ case 246 /* SyntaxKind.ExpressionStatement */:
202
207
  checkExpressionStatement(c, node);
203
208
  return;
204
- case 246 /* SyntaxKind.IfStatement */:
209
+ case 247 /* SyntaxKind.IfStatement */:
205
210
  checkIfStatement(c, node);
206
211
  return;
207
- case 247 /* SyntaxKind.DoStatement */:
212
+ case 248 /* SyntaxKind.DoStatement */:
208
213
  checkDoStatement(c, node);
209
214
  return;
210
- case 248 /* SyntaxKind.WhileStatement */:
215
+ case 249 /* SyntaxKind.WhileStatement */:
211
216
  checkWhileStatement(c, node);
212
217
  return;
213
- case 249 /* SyntaxKind.ForStatement */:
218
+ case 250 /* SyntaxKind.ForStatement */:
214
219
  checkForStatement(c, node);
215
220
  return;
216
- case 250 /* SyntaxKind.ForInStatement */:
221
+ case 251 /* SyntaxKind.ForInStatement */:
217
222
  checkForInStatement(c, node);
218
223
  return;
219
- case 251 /* SyntaxKind.ForOfStatement */:
224
+ case 252 /* SyntaxKind.ForOfStatement */:
220
225
  checkForOfStatement(c, node);
221
226
  return;
222
- case 254 /* SyntaxKind.ReturnStatement */:
227
+ case 255 /* SyntaxKind.ReturnStatement */:
223
228
  checkReturnStatement(c, node);
224
229
  return;
225
- case 256 /* SyntaxKind.SwitchStatement */:
230
+ case 257 /* SyntaxKind.SwitchStatement */:
226
231
  checkSwitchStatement(c, node);
227
232
  return;
228
- case 257 /* SyntaxKind.LabeledStatement */:
233
+ case 258 /* SyntaxKind.LabeledStatement */:
229
234
  checkLabeledStatement(c, node);
230
235
  return;
231
- case 258 /* SyntaxKind.ThrowStatement */:
236
+ case 259 /* SyntaxKind.ThrowStatement */:
232
237
  checkThrowStatement(c, node);
233
238
  return;
234
- case 259 /* SyntaxKind.TryStatement */:
239
+ case 260 /* SyntaxKind.TryStatement */:
235
240
  checkTryStatement(c, node);
236
241
  return;
237
- case 255 /* SyntaxKind.WithStatement */:
242
+ case 256 /* SyntaxKind.WithStatement */:
238
243
  // The body isn't checked: every name in it has type `any`.
239
244
  checkExpression(c, getExpression(node));
240
245
  return;
241
246
  // Declarations
242
- case 263 /* SyntaxKind.FunctionDeclaration */:
247
+ case 264 /* SyntaxKind.FunctionDeclaration */:
243
248
  checkFunctionDeclaration(c, node);
244
249
  return;
245
- case 264 /* SyntaxKind.ClassDeclaration */:
250
+ case 265 /* SyntaxKind.ClassDeclaration */:
246
251
  checkClassDeclaration(c, node);
247
252
  return;
248
- case 265 /* SyntaxKind.InterfaceDeclaration */:
253
+ case 266 /* SyntaxKind.InterfaceDeclaration */:
249
254
  checkInterfaceDeclaration(c, node);
250
255
  return;
251
- case 266 /* SyntaxKind.TypeAliasDeclaration */:
252
- case 345 /* SyntaxKind.JSTypeAliasDeclaration */:
256
+ case 267 /* SyntaxKind.TypeAliasDeclaration */:
257
+ case 346 /* SyntaxKind.JSTypeAliasDeclaration */:
253
258
  checkTypeAliasDeclaration(c, node);
254
259
  return;
255
- case 267 /* SyntaxKind.EnumDeclaration */:
260
+ case 268 /* SyntaxKind.EnumDeclaration */:
256
261
  checkEnumDeclaration(c, node);
257
262
  return;
258
- case 306 /* SyntaxKind.EnumMember */:
263
+ case 307 /* SyntaxKind.EnumMember */:
259
264
  checkEnumMember(c, node);
260
265
  return;
261
- case 268 /* SyntaxKind.ModuleDeclaration */:
266
+ case 269 /* SyntaxKind.ModuleDeclaration */:
262
267
  checkModuleDeclaration(c, node);
263
268
  return;
264
- case 273 /* SyntaxKind.ImportDeclaration */:
265
- case 346 /* SyntaxKind.JSImportDeclaration */:
269
+ case 274 /* SyntaxKind.ImportDeclaration */:
270
+ case 347 /* SyntaxKind.JSImportDeclaration */:
266
271
  checkImportDeclaration(c, node);
267
272
  return;
268
- case 272 /* SyntaxKind.ImportEqualsDeclaration */:
273
+ case 273 /* SyntaxKind.ImportEqualsDeclaration */:
269
274
  checkImportEqualsDeclaration(c, node);
270
275
  return;
271
- case 279 /* SyntaxKind.ExportDeclaration */:
276
+ case 280 /* SyntaxKind.ExportDeclaration */:
272
277
  checkExportDeclaration(c, node);
273
278
  return;
274
- case 278 /* SyntaxKind.ExportAssignment */:
279
+ case 279 /* SyntaxKind.ExportAssignment */:
275
280
  checkExportAssignment(c, node);
276
281
  return;
277
- case 271 /* SyntaxKind.NamespaceExportDeclaration */:
278
- case 283 /* SyntaxKind.MissingDeclaration */:
282
+ case 272 /* SyntaxKind.NamespaceExportDeclaration */:
283
+ case 284 /* SyntaxKind.MissingDeclaration */:
279
284
  return;
280
- case 169 /* SyntaxKind.TypeParameter */:
285
+ case 170 /* SyntaxKind.TypeParameter */:
281
286
  checkTypeParameter(c, node);
282
287
  return;
283
288
  }
@@ -287,7 +292,7 @@ function checkSourceElementWorker(c, node) {
287
292
  /** Resolves the names of `{@link}` tags in a JSDoc comment and its tags, which references them. */
288
293
  function checkJSDocLinks(c, jsDoc) {
289
294
  checkJSDocCommentLinks(c, getComment(jsDoc));
290
- const tags = jsDoc.kind === 315 /* SyntaxKind.JSDoc */ ? jsDoc.tags : undefined;
295
+ const tags = jsDoc.kind === 316 /* SyntaxKind.JSDoc */ ? jsDoc.tags : undefined;
291
296
  if (tags !== undefined)
292
297
  for (const tag of tags.nodes)
293
298
  checkJSDocCommentLinks(c, getComment(tag));
@@ -296,9 +301,9 @@ function checkJSDocCommentLinks(c, comments) {
296
301
  if (comments === undefined)
297
302
  return;
298
303
  for (const comment of comments.nodes)
299
- if (comment.kind === 319 /* SyntaxKind.JSDocLink */ ||
300
- comment.kind === 320 /* SyntaxKind.JSDocLinkCode */ ||
301
- comment.kind === 321 /* SyntaxKind.JSDocLinkPlain */)
304
+ if (comment.kind === 320 /* SyntaxKind.JSDocLink */ ||
305
+ comment.kind === 321 /* SyntaxKind.JSDocLinkCode */ ||
306
+ comment.kind === 322 /* SyntaxKind.JSDocLinkPlain */)
302
307
  resolveJSDocMemberName(c, getName(comment));
303
308
  }
304
309
  // ---- Type nodes
@@ -311,12 +316,12 @@ export function checkTypeNodeIfPresent(c, node) {
311
316
  function checkSignatureMember(c, node) {
312
317
  if (getType(node) !== undefined || !c.noImplicitAny)
313
318
  return;
314
- if (node.kind === 174 /* SyntaxKind.MethodSignature */)
319
+ if (node.kind === 175 /* SyntaxKind.MethodSignature */)
315
320
  reportImplicitAny(c, node, c.anyType);
316
- else if (node.kind === 180 /* SyntaxKind.CallSignature */)
317
- c.error(node, 1692 /* Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type */);
321
+ else if (node.kind === 181 /* SyntaxKind.CallSignature */)
322
+ c.error(node, 1711 /* Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type */);
318
323
  else
319
- c.error(node, 1685 /* Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type */);
324
+ c.error(node, 1704 /* Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type */);
320
325
  }
321
326
  function checkTypeNode(c, node) {
322
327
  const saveCurrentNode = c.currentNode;
@@ -327,10 +332,10 @@ function checkTypeNode(c, node) {
327
332
  }
328
333
  function isTypeReferenceHeritageElement(node) {
329
334
  const clause = node.parent;
330
- if (clause === undefined || clause.kind !== 299 /* SyntaxKind.HeritageClause */)
335
+ if (clause === undefined || clause.kind !== 300 /* SyntaxKind.HeritageClause */)
331
336
  return false;
332
337
  const token = clause.token;
333
- if ((token === 118 /* SyntaxKind.ImplementsKeyword */) === (clause.parent.kind === 265 /* SyntaxKind.InterfaceDeclaration */))
338
+ if ((token === 118 /* SyntaxKind.ImplementsKeyword */) === (clause.parent.kind === 266 /* SyntaxKind.InterfaceDeclaration */))
334
339
  return false;
335
340
  // Only the first clause of each kind counts.
336
341
  for (const other of getHeritageClauses(clause.parent).nodes)
@@ -340,73 +345,78 @@ function isTypeReferenceHeritageElement(node) {
340
345
  }
341
346
  function checkTypeNodeWorker(c, node) {
342
347
  switch (node.kind) {
343
- case 183 /* SyntaxKind.TypePredicate */:
348
+ case 184 /* SyntaxKind.TypePredicate */:
344
349
  checkTypePredicate(c, node);
345
350
  return;
346
- case 174 /* SyntaxKind.MethodSignature */:
347
- case 180 /* SyntaxKind.CallSignature */:
348
- case 181 /* SyntaxKind.ConstructSignature */: {
351
+ case 175 /* SyntaxKind.MethodSignature */:
352
+ case 181 /* SyntaxKind.CallSignature */:
353
+ case 182 /* SyntaxKind.ConstructSignature */: {
349
354
  checkTypeParameters(c, getTypeParameters(node));
350
355
  checkSignatureMember(c, node);
351
356
  const name = getName(node);
352
- if (name !== undefined && name.kind === 168 /* SyntaxKind.ComputedPropertyName */)
357
+ if (name !== undefined && name.kind === 169 /* SyntaxKind.ComputedPropertyName */)
353
358
  checkComputedPropertyName(c, name);
354
359
  break;
355
360
  }
356
- case 185 /* SyntaxKind.FunctionType */:
357
- case 186 /* SyntaxKind.ConstructorType */:
361
+ case 186 /* SyntaxKind.FunctionType */:
362
+ case 187 /* SyntaxKind.ConstructorType */:
358
363
  checkTypeParameters(c, getTypeParameters(node));
359
364
  break;
360
- case 184 /* SyntaxKind.TypeReference */:
361
- case 206 /* SyntaxKind.ImportType */: {
365
+ case 185 /* SyntaxKind.TypeReference */:
366
+ case 207 /* SyntaxKind.ImportType */: {
367
+ // `const` in `x as const` is not checked as a type: its type is the type of `x`.
368
+ if (isConstTypeReference(node) && isAssertionExpression(node.parent))
369
+ break;
362
370
  const type = getTypeFromTypeNode(c, node);
363
371
  checkTypeArgumentConstraintsOfReference(c, node, type);
364
372
  checkDeprecatedTypeReference(c, node, type);
373
+ if (node.kind === 207 /* SyntaxKind.ImportType */)
374
+ checkImportAttributes(c, node);
365
375
  break;
366
376
  }
367
- case 200 /* SyntaxKind.IndexedAccessType */:
377
+ case 201 /* SyntaxKind.IndexedAccessType */:
368
378
  // The indexed access type itself, not the substitution type of a conditional type's true branch.
369
379
  checkIndexedAccessIndexType(c, getTypeFromIndexedAccessTypeNode(c, node), node);
370
380
  break;
371
- case 190 /* SyntaxKind.TupleType */:
381
+ case 191 /* SyntaxKind.TupleType */:
372
382
  checkTupleRestElements(c, node);
373
383
  getTypeFromTypeNode(c, node);
374
- case 234 /* SyntaxKind.ExpressionWithTypeArguments */:
384
+ case 235 /* SyntaxKind.ExpressionWithTypeArguments */:
375
385
  // Implemented types and interface base types are type references; class base types are
376
386
  // checked with the base constructor's type parameters.
377
387
  if (isTypeReferenceHeritageElement(node))
378
388
  checkTypeArgumentConstraintsOfReference(c, node, getTypeFromTypeNode(c, node));
379
389
  break;
380
- case 187 /* SyntaxKind.TypeQuery */:
381
- case 199 /* SyntaxKind.TypeOperator */:
382
- case 202 /* SyntaxKind.LiteralType */:
383
- case 198 /* SyntaxKind.ThisType */:
390
+ case 188 /* SyntaxKind.TypeQuery */:
391
+ case 200 /* SyntaxKind.TypeOperator */:
392
+ case 203 /* SyntaxKind.LiteralType */:
393
+ case 199 /* SyntaxKind.ThisType */:
384
394
  getTypeFromTypeNode(c, node);
385
395
  break;
386
396
  }
387
397
  // Type arguments of an import type are only resolved with its type.
388
- if (node.kind === 206 /* SyntaxKind.ImportType */) {
398
+ if (node.kind === 207 /* SyntaxKind.ImportType */) {
389
399
  checkTypeNode(c, node.argument);
390
400
  return;
391
401
  }
392
402
  // Type arguments of a type query are checked with its type.
393
- if (node.kind === 187 /* SyntaxKind.TypeQuery */)
403
+ if (node.kind === 188 /* SyntaxKind.TypeQuery */)
394
404
  return;
395
- if (node.kind === 201 /* SyntaxKind.MappedType */) {
405
+ if (node.kind === 202 /* SyntaxKind.MappedType */) {
396
406
  checkMappedType(c, node);
397
407
  return;
398
408
  }
399
- if (node.kind === 204 /* SyntaxKind.TemplateLiteralType */) {
409
+ if (node.kind === 205 /* SyntaxKind.TemplateLiteralType */) {
400
410
  checkTemplateLiteralType(c, node);
401
411
  return;
402
412
  }
403
413
  node.forEachChild(c.typeNodeVisitor);
404
414
  // Unions and intersections are resolved after their constituents.
405
- if (node.kind === 193 /* SyntaxKind.UnionType */ || node.kind === 194 /* SyntaxKind.IntersectionType */)
415
+ if (node.kind === 194 /* SyntaxKind.UnionType */ || node.kind === 195 /* SyntaxKind.IntersectionType */)
406
416
  getTypeFromTypeNode(c, node);
407
- if (node.kind === 174 /* SyntaxKind.MethodSignature */)
417
+ if (node.kind === 175 /* SyntaxKind.MethodSignature */)
408
418
  checkFunctionOrMethodSymbols(c, node);
409
- else if (node.kind === 188 /* SyntaxKind.TypeLiteral */)
419
+ else if (node.kind === 189 /* SyntaxKind.TypeLiteral */)
410
420
  checkTypeLiteralMembers(c, node);
411
421
  }
412
422
  /** Checks that each span of a template literal type can be written in a template, then its type. */
@@ -433,6 +443,8 @@ function checkMappedType(c, node) {
433
443
  checkTypeAssignableTo(c, getConstraintTypeFromMappedType(c, t), c.stringNumberSymbolType, node.typeParameter.constraint, undefined);
434
444
  }
435
445
  function checkTypePredicate(c, node) {
446
+ // The predicate's type is checked also in a position a predicate can't have.
447
+ checkTypeNodeIfPresent(c, node.type);
436
448
  const parent = getTypePredicateParent(node);
437
449
  if (parent === undefined) {
438
450
  c.error(node, 178 /* Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods */);
@@ -442,7 +454,6 @@ function checkTypePredicate(c, node) {
442
454
  const typePredicate = getTypePredicateOfSignature(c, signature);
443
455
  if (typePredicate === undefined)
444
456
  return;
445
- checkTypeNodeIfPresent(c, node.type);
446
457
  if (typePredicate.kind === 0 /* TypePredicateKind.This */ || typePredicate.kind === 2 /* TypePredicateKind.AssertsThis */)
447
458
  return;
448
459
  const parameterName = node.parameterName;
@@ -452,13 +463,13 @@ function checkTypePredicate(c, node) {
452
463
  else if (typePredicate.type !== undefined) {
453
464
  const diagnostics = [];
454
465
  if (!checkTypeRelatedTo(c, typePredicate.type, getTypeOfSymbol(c, signature.parameters[typePredicate.parameterIndex]), c.assignableRelation, node.type, undefined, diagnostics))
455
- c.addDiagnostic(chainDiagnostic(diagnostics[0], 811 /* Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type */));
466
+ c.addDiagnostic(chainDiagnostic(diagnostics[0], 818 /* Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type */));
456
467
  }
457
468
  return;
458
469
  }
459
470
  for (const param of getParameters(parent).nodes) {
460
471
  const name = getName(param);
461
- if ((name.kind === 207 /* SyntaxKind.ObjectBindingPattern */ || name.kind === 208 /* SyntaxKind.ArrayBindingPattern */) &&
472
+ if ((name.kind === 208 /* SyntaxKind.ObjectBindingPattern */ || name.kind === 209 /* SyntaxKind.ArrayBindingPattern */) &&
462
473
  checkIfTypePredicateVariableIsDeclaredInBindingPattern(c, name, parameterName, typePredicate.parameterName))
463
474
  return;
464
475
  }
@@ -468,13 +479,13 @@ function checkTypePredicate(c, node) {
468
479
  function getTypePredicateParent(node) {
469
480
  const parent = node.parent;
470
481
  switch (parent.kind) {
471
- case 220 /* SyntaxKind.ArrowFunction */:
472
- case 180 /* SyntaxKind.CallSignature */:
473
- case 263 /* SyntaxKind.FunctionDeclaration */:
474
- case 219 /* SyntaxKind.FunctionExpression */:
475
- case 185 /* SyntaxKind.FunctionType */:
476
- case 175 /* SyntaxKind.MethodDeclaration */:
477
- case 174 /* SyntaxKind.MethodSignature */:
482
+ case 221 /* SyntaxKind.ArrowFunction */:
483
+ case 181 /* SyntaxKind.CallSignature */:
484
+ case 264 /* SyntaxKind.FunctionDeclaration */:
485
+ case 220 /* SyntaxKind.FunctionExpression */:
486
+ case 186 /* SyntaxKind.FunctionType */:
487
+ case 176 /* SyntaxKind.MethodDeclaration */:
488
+ case 175 /* SyntaxKind.MethodSignature */:
478
489
  if (getType(parent) === node)
479
490
  return parent;
480
491
  }
@@ -489,7 +500,7 @@ function checkIfTypePredicateVariableIsDeclaredInBindingPattern(c, pattern, pred
489
500
  c.error(predicateVariableNode, 180 /* Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern */, predicateVariableName);
490
501
  return true;
491
502
  }
492
- if ((name.kind === 208 /* SyntaxKind.ArrayBindingPattern */ || name.kind === 207 /* SyntaxKind.ObjectBindingPattern */) &&
503
+ if ((name.kind === 209 /* SyntaxKind.ArrayBindingPattern */ || name.kind === 208 /* SyntaxKind.ObjectBindingPattern */) &&
493
504
  checkIfTypePredicateVariableIsDeclaredInBindingPattern(c, name, predicateVariableNode, predicateVariableName))
494
505
  return true;
495
506
  }
@@ -498,7 +509,7 @@ function checkIfTypePredicateVariableIsDeclaredInBindingPattern(c, pattern, pred
498
509
  /** Checks an accessor of a type literal or interface. */
499
510
  function checkTypeMemberAccessor(c, node) {
500
511
  const name = getName(node);
501
- if (name !== undefined && name.kind === 168 /* SyntaxKind.ComputedPropertyName */)
512
+ if (name !== undefined && name.kind === 169 /* SyntaxKind.ComputedPropertyName */)
502
513
  checkComputedPropertyName(c, name);
503
514
  const symbol = getSymbolOfDeclaration(c, node);
504
515
  if (symbol !== undefined)
@@ -512,7 +523,7 @@ function checkTupleRestElements(c, node) {
512
523
  if ((getTupleElementFlags(c, e) & 8 /* ElementFlags.Variadic */) === 0)
513
524
  continue;
514
525
  if (!isArrayLikeType(c, getTypeFromTypeNode(c, getType(e)))) {
515
- c.error(e, 725 /* Diagnostics.A_rest_element_type_must_be_an_array_type */);
526
+ c.error(e, 732 /* Diagnostics.A_rest_element_type_must_be_an_array_type */);
516
527
  return;
517
528
  }
518
529
  }
@@ -529,42 +540,42 @@ export class TypeNodeVisitor extends NodeVisitor {
529
540
  checkJSDocLinksOfNode(this.c, node);
530
541
  switch (node.kind) {
531
542
  case 79 /* SyntaxKind.Identifier */:
532
- case 167 /* SyntaxKind.QualifiedName */:
543
+ case 168 /* SyntaxKind.QualifiedName */:
533
544
  case 10 /* SyntaxKind.StringLiteral */:
534
545
  case 8 /* SyntaxKind.NumericLiteral */:
535
546
  return false;
536
- case 170 /* SyntaxKind.Parameter */:
547
+ case 171 /* SyntaxKind.Parameter */:
537
548
  checkVariableLikeDeclaration(this.c, node);
538
549
  return false;
539
- case 174 /* SyntaxKind.MethodSignature */:
540
- case 180 /* SyntaxKind.CallSignature */:
541
- case 181 /* SyntaxKind.ConstructSignature */:
550
+ case 175 /* SyntaxKind.MethodSignature */:
551
+ case 181 /* SyntaxKind.CallSignature */:
552
+ case 182 /* SyntaxKind.ConstructSignature */:
542
553
  checkTypeNode(this.c, node);
543
554
  return false;
544
- case 172 /* SyntaxKind.PropertySignature */:
555
+ case 173 /* SyntaxKind.PropertySignature */:
545
556
  checkVariableLikeDeclaration(this.c, node);
546
557
  return false;
547
- case 178 /* SyntaxKind.GetAccessor */:
548
- case 179 /* SyntaxKind.SetAccessor */:
558
+ case 179 /* SyntaxKind.GetAccessor */:
559
+ case 180 /* SyntaxKind.SetAccessor */:
549
560
  checkTypeMemberAccessor(this.c, node);
550
561
  return false;
551
- case 182 /* SyntaxKind.IndexSignature */:
562
+ case 183 /* SyntaxKind.IndexSignature */:
552
563
  node.forEachChild(this);
553
564
  return false;
554
- case 169 /* SyntaxKind.TypeParameter */:
565
+ case 170 /* SyntaxKind.TypeParameter */:
555
566
  // Lists of signatures are checked as a whole; `infer` and mapped type parameters alone.
556
- if (node.parent.kind === 196 /* SyntaxKind.InferType */ || node.parent.kind === 201 /* SyntaxKind.MappedType */)
567
+ if (node.parent.kind === 197 /* SyntaxKind.InferType */ || node.parent.kind === 202 /* SyntaxKind.MappedType */)
557
568
  checkTypeParameter(this.c, node);
558
- if (node.parent.kind === 196 /* SyntaxKind.InferType */) {
569
+ if (node.parent.kind === 197 /* SyntaxKind.InferType */) {
559
570
  const symbol = getSymbolOfDeclaration(this.c, node);
560
571
  if (symbol !== undefined)
561
572
  checkInferTypeParameterDeclarations(this.c, symbol);
562
573
  }
563
574
  return false;
564
575
  }
565
- if (node.kind >= 183 /* SyntaxKind.FirstTypeNode */ && node.kind <= 206 /* SyntaxKind.LastTypeNode */)
576
+ if (node.kind >= 184 /* SyntaxKind.FirstTypeNode */ && node.kind <= 207 /* SyntaxKind.LastTypeNode */)
566
577
  checkTypeNode(this.c, node);
567
- else if (node.kind === 234 /* SyntaxKind.ExpressionWithTypeArguments */)
578
+ else if (node.kind === 235 /* SyntaxKind.ExpressionWithTypeArguments */)
568
579
  checkTypeNode(this.c, node);
569
580
  return false;
570
581
  }
@@ -603,7 +614,7 @@ function checkDeferredNodes(c, file) {
603
614
  }
604
615
  /** Resolves the type of an object literal accessor, which reports accessors implicitly typed `any`. */
605
616
  function checkObjectLiteralAccessorType(c, node) {
606
- if (node.parent.kind !== 211 /* SyntaxKind.ObjectLiteralExpression */)
617
+ if (node.parent.kind !== 212 /* SyntaxKind.ObjectLiteralExpression */)
607
618
  return;
608
619
  const symbol = getSymbolOfDeclaration(c, node);
609
620
  if (symbol !== undefined)
@@ -614,39 +625,52 @@ function checkDeferredNode(c, node) {
614
625
  c.currentNode = node;
615
626
  c.instantiationCount = 0;
616
627
  switch (node.kind) {
617
- case 214 /* SyntaxKind.CallExpression */:
618
- case 215 /* SyntaxKind.NewExpression */:
619
- case 216 /* SyntaxKind.TaggedTemplateExpression */:
628
+ case 215 /* SyntaxKind.CallExpression */:
629
+ case 216 /* SyntaxKind.NewExpression */:
630
+ case 217 /* SyntaxKind.TaggedTemplateExpression */:
620
631
  // Deferred when overload resolution fails, so that the arguments are checked once.
621
632
  resolveUntypedCall(c, node);
622
633
  break;
623
- case 219 /* SyntaxKind.FunctionExpression */:
624
- case 220 /* SyntaxKind.ArrowFunction */:
625
- case 175 /* SyntaxKind.MethodDeclaration */:
634
+ case 220 /* SyntaxKind.FunctionExpression */:
635
+ case 221 /* SyntaxKind.ArrowFunction */:
636
+ case 176 /* SyntaxKind.MethodDeclaration */:
626
637
  checkFunctionLikeBody(c, node);
627
638
  break;
628
- case 178 /* SyntaxKind.GetAccessor */:
629
- case 179 /* SyntaxKind.SetAccessor */:
639
+ case 179 /* SyntaxKind.GetAccessor */:
640
+ case 180 /* SyntaxKind.SetAccessor */:
630
641
  checkObjectLiteralAccessorType(c, node);
631
642
  checkFunctionLikeBody(c, node);
632
- if (node.parent.kind === 211 /* SyntaxKind.ObjectLiteralExpression */)
643
+ if (node.parent.kind === 212 /* SyntaxKind.ObjectLiteralExpression */)
633
644
  checkAccessorDeclaration(c, node);
634
645
  break;
635
- case 232 /* SyntaxKind.ClassExpression */:
646
+ case 233 /* SyntaxKind.ClassExpression */:
636
647
  checkClassLikeDeferred(c, node);
637
648
  break;
638
- case 235 /* SyntaxKind.AsExpression */:
639
- case 217 /* SyntaxKind.TypeAssertionExpression */:
649
+ case 212 /* SyntaxKind.ObjectLiteralExpression */: {
650
+ // Reported only as suggestions, which are computed when they are asked for (`getSuggestionDiagnostics`).
651
+ const file = getSourceFileOfNode(node);
652
+ const pending = c.objectLiteralsForDeprecations.get(file);
653
+ if (pending === undefined)
654
+ c.objectLiteralsForDeprecations.set(file, [node]);
655
+ else
656
+ pending.push(node);
657
+ break;
658
+ }
659
+ case 294 /* SyntaxKind.JsxAttributes */:
660
+ checkContextualDeprecations(c, node);
661
+ break;
662
+ case 236 /* SyntaxKind.AsExpression */:
663
+ case 218 /* SyntaxKind.TypeAssertionExpression */:
640
664
  checkAssertionDeferred(c, node);
641
665
  break;
642
- case 169 /* SyntaxKind.TypeParameter */:
666
+ case 170 /* SyntaxKind.TypeParameter */:
643
667
  checkTypeParameterDeferred(c, node);
644
668
  break;
645
- case 285 /* SyntaxKind.JsxElement */:
646
- case 286 /* SyntaxKind.JsxSelfClosingElement */:
669
+ case 286 /* SyntaxKind.JsxElement */:
670
+ case 287 /* SyntaxKind.JsxSelfClosingElement */:
647
671
  checkJsxElementDeferred(c, node);
648
672
  break;
649
- case 223 /* SyntaxKind.VoidExpression */:
673
+ case 224 /* SyntaxKind.VoidExpression */:
650
674
  checkExpression(c, getExpression(node));
651
675
  break;
652
676
  }