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
@@ -7,16 +7,17 @@ import { getThisContainer, isEntityNameExpression, isStatic, skipParentheses, is
7
7
  import { shouldCheckErasableSyntax } from './checker-declarations.js';
8
8
  import { skipTrivia } from './scanner.js';
9
9
  import { Diagnostic } from './diagnostics.js';
10
+ import { createDiagnosticForNode } from './checker.js';
10
11
  import { checkSuperExpression, checkThisBeforeSuper, checkThisInStaticClassFieldInitializerInDecoratedClass, } from './checker-super.js';
11
12
  import { cachedTypeKey, } from './checker-types.js';
12
13
  import { createTupleTypeEx, getBigIntLiteralType, getFreshTypeOfLiteralType, getNumberLiteralType, getRegularTypeOfLiteralType, getStringLiteralType, getUnionTypeEx, getWidenedLiteralType, getWidenedUniqueESSymbolType, isErrorType, isTupleType, someType, typesOf, getBaseTypeOfLiteralType, cloneTypeReference, createArrayTypeEx, everyType, getTemplateLiteralType, isMutableArrayOrTuple, } from './checker-type-factory.js';
13
14
  import { TupleElementInfo } from './checker-types.js';
14
15
  import { getBaseConstraintOfType, getPropertyOfType, getIndexInfoOfType, getIndexInfosOfType, getIndexTypeOfType, getTypeOfPropertyOfType, isArrayLikeType, getBaseConstraintOrType, isApplicableIndexType, getDeclarationModifierFlagsFromSymbol, getApparentType, mapToBaseConstraintOrType, } from './checker-members.js';
15
- import { getExportSymbolOfValueSymbolIfExported, getMergedSymbol, getSymbolOfDeclaration, resolveEntityName, resolveName, getFirstIdentifier, getCannotFindNameDiagnosticForName, getDeclarationOfAliasSymbol, popTypeResolution, pushTypeResolution, reportCircularityError, } from './checker-symbols.js';
16
+ import { getExportSymbolOfValueSymbolIfExported, getMergedSymbol, getSymbolOfDeclaration, resolveEntityName, resolveName, getFirstIdentifier, cannotFindNameAtLocation, getDeclarationOfAliasSymbol, popTypeResolution, pushTypeResolution, reportCircularityError, } from './checker-symbols.js';
16
17
  import { getTypeOfSymbol, getWidenedType, isReadonlySymbol, getOptionalType, removeMissingType, addOptionality, } from './checker-symbol-types.js';
17
18
  import { getDeclaredTypeOfClassOrInterface } from './checker-declared-types.js';
18
19
  import { getTypeFromTypeNode } from './checker-type-nodes.js';
19
- import { isGenericObjectType, getIndexedAccessTypeOrUndefinedEx, getHomomorphicTypeVariable, isGenericIndexType, isGenericMappedType, isGenericType, getMappedTypeNameTypeKind, getIndexForMappedType, getIndexTypeEx, getMappedTypeModifiers, getPropertyNameFromIndex, isNoInferType, } from './checker-type-operators.js';
20
+ import { isGenericObjectType, getIndexedAccessTypeOrUndefinedEx, getHomomorphicTypeVariable, isGenericIndexType, isGenericMappedType, isGenericType, getIndexTypeEx, getMappedTypeModifiers, getPropertyNameFromIndex, isNoInferType, } from './checker-type-operators.js';
20
21
  import { getTypeFacts, getNonNullableType, getTypeWithFacts, hasTypeFacts } from './checker-flow.js';
21
22
  import { checkTypeComparableTo, isTypeAssignableTo, isTypeComparableTo } from './relations.js';
22
23
  import { isTypeAssignableToKindEx as isTypeAssignableToKind } from './checker-type-operators.js';
@@ -33,7 +34,8 @@ import { isInPropertyInitializerOrClassStaticBlock } from './checker-declaration
33
34
  import { checkObjectLiteral } from './checker-object-literals.js';
34
35
  import { evaluate } from './checker-evaluator.js';
35
36
  import { checkPrivateIdentifierExpression, checkPropertyAccessExpressionOrQualifiedName, isMethodAccessForCall, } from './checker-property-access.js';
36
- import { checkBinaryExpression, checkConditionalExpression, checkDeleteExpression, checkPostfixUnaryExpression, checkPrefixUnaryExpression, isTypeAssertion, } from './checker-operators.js';
37
+ import { checkBinaryExpression, checkConditionalExpression, checkDeleteExpression, checkPostfixUnaryExpression, checkPrefixUnaryExpression, grammarErrorOnNode, isTypeAssertion, } from './checker-operators.js';
38
+ import { fileExtensionIsOneOf } from './path.js';
37
39
  import { checkJsx } from './checker-jsx.js';
38
40
  import { getRegularTypeOfObjectLiteral } from './checker-literals.js';
39
41
  import { getReturnTypeOfSignature, getSignatureFromDeclaration, getSingleSignature, getThisTypeOfSignature, } from './checker-signatures.js';
@@ -69,14 +71,14 @@ export function checkExpressionEx(c, node, checkMode) {
69
71
  */
70
72
  function checkConstEnumAccess(c, node, t) {
71
73
  const parent = node.parent;
72
- const ok = ((parent.kind === 212 /* SyntaxKind.PropertyAccessExpression */ || parent.kind === 213 /* SyntaxKind.ElementAccessExpression */) &&
74
+ const ok = ((parent.kind === 213 /* SyntaxKind.PropertyAccessExpression */ || parent.kind === 214 /* SyntaxKind.ElementAccessExpression */) &&
73
75
  getExpression(parent) === node) ||
74
- ((node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 167 /* SyntaxKind.QualifiedName */) &&
76
+ ((node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 168 /* SyntaxKind.QualifiedName */) &&
75
77
  isInRightSideOfImportOrExportAssignment(node)) ||
76
- (parent.kind === 187 /* SyntaxKind.TypeQuery */ && parent.exprName === node) ||
77
- parent.kind === 282 /* SyntaxKind.ExportSpecifier */;
78
+ (parent.kind === 188 /* SyntaxKind.TypeQuery */ && parent.exprName === node) ||
79
+ parent.kind === 283 /* SyntaxKind.ExportSpecifier */;
78
80
  if (!ok)
79
- c.error(node, 639 /* Diagnostics.X_const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment_or_type_query */);
81
+ c.error(node, 646 /* Diagnostics.X_const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment_or_type_query */);
80
82
  // Under verbatimModuleSyntax, only uses that don't resolve to an import are checked here; imports of
81
83
  // ambient const enums are checked with the alias.
82
84
  if (c.compilerOptions.isolatedModules === true ||
@@ -85,17 +87,17 @@ function checkConstEnumAccess(c, node, t) {
85
87
  resolveName(c, node, getText(getFirstIdentifier(node)), 2097152 /* SymbolFlags.Alias */, undefined, false, true) === undefined)) {
86
88
  const constEnumDeclaration = t.symbol.valueDeclaration;
87
89
  if ((constEnumDeclaration.flags & 8388608 /* NodeFlags.Ambient */) !== 0 && !isValidTypeOnlyAliasUseSite(node))
88
- c.error(node, 880 /* Diagnostics.Cannot_access_ambient_const_enums_when_0_is_enabled */, getIsolatedModulesLikeFlagName(c));
90
+ c.error(node, 887 /* Diagnostics.Cannot_access_ambient_const_enums_when_0_is_enabled */, getIsolatedModulesLikeFlagName(c));
89
91
  }
90
92
  }
91
93
  function isInRightSideOfImportOrExportAssignment(name) {
92
94
  let node = name;
93
- while (node.parent.kind === 167 /* SyntaxKind.QualifiedName */)
95
+ while (node.parent.kind === 168 /* SyntaxKind.QualifiedName */)
94
96
  node = node.parent;
95
97
  const parent = node.parent;
96
- return ((parent.kind === 272 /* SyntaxKind.ImportEqualsDeclaration */ &&
98
+ return ((parent.kind === 273 /* SyntaxKind.ImportEqualsDeclaration */ &&
97
99
  parent.moduleReference === node) ||
98
- (parent.kind === 278 /* SyntaxKind.ExportAssignment */ && getExpression(parent) === node));
100
+ (parent.kind === 279 /* SyntaxKind.ExportAssignment */ && getExpression(parent) === node));
99
101
  }
100
102
  /** The type of `node`, computed once. */
101
103
  export function checkExpressionCached(c, node) {
@@ -162,11 +164,11 @@ export function checkDeclarationInitializer(c, declaration, checkMode = 0 /* Che
162
164
  function getQuickTypeOfExpression(c, node) {
163
165
  const expr = skipParentheses(node);
164
166
  switch (expr.kind) {
165
- case 224 /* SyntaxKind.AwaitExpression */: {
167
+ case 225 /* SyntaxKind.AwaitExpression */: {
166
168
  const t = getQuickTypeOfExpression(c, getExpression(expr));
167
169
  return t !== undefined ? getAwaitedType(c, t) : undefined;
168
170
  }
169
- case 214 /* SyntaxKind.CallExpression */: {
171
+ case 215 /* SyntaxKind.CallExpression */: {
170
172
  const call = expr;
171
173
  if (call.expression.kind === 107 /* SyntaxKind.SuperKeyword */ ||
172
174
  isRequireCall(call, true) ||
@@ -183,10 +185,10 @@ function getQuickTypeOfExpression(c, node) {
183
185
  }
184
186
  return getReturnTypeOfSingleNonGenericSignature(c, checkNonNullExpression(c, call.expression), 0 /* SignatureKind.Call */);
185
187
  }
186
- case 215 /* SyntaxKind.NewExpression */:
188
+ case 216 /* SyntaxKind.NewExpression */:
187
189
  return getReturnTypeOfSingleNonGenericSignature(c, checkNonNullExpression(c, getExpression(expr)), 1 /* SignatureKind.Construct */);
188
- case 235 /* SyntaxKind.AsExpression */:
189
- case 217 /* SyntaxKind.TypeAssertionExpression */: {
190
+ case 236 /* SyntaxKind.AsExpression */:
191
+ case 218 /* SyntaxKind.TypeAssertionExpression */: {
190
192
  const typeNode = getType(expr);
191
193
  return isConstTypeReference(typeNode) ? undefined : getTypeFromTypeNode(c, typeNode);
192
194
  }
@@ -202,18 +204,20 @@ function getReturnTypeOfSingleNonGenericSignature(c, funcType, kind) {
202
204
  : undefined;
203
205
  }
204
206
  export function checkComputedPropertyName(c, node) {
205
- const nodeId = node.expression.id;
207
+ const nodeId = node.id;
206
208
  if (c.resolvedTypes.get(nodeId) === undefined) {
209
+ // A reference to the name while its expression is checked sees a circular type.
210
+ c.resolvedTypes.set(nodeId, c.circularConstraintType);
207
211
  const expression = node.expression;
208
212
  const container = node.parent.parent;
209
213
  // `[x in y]` in a type member is a mapped type written in the wrong place, reported by the parser.
210
- if ((container.kind === 188 /* SyntaxKind.TypeLiteral */ ||
214
+ if ((container.kind === 189 /* SyntaxKind.TypeLiteral */ ||
211
215
  isClassLike(container) ||
212
- container.kind === 265 /* SyntaxKind.InterfaceDeclaration */) &&
213
- expression.kind === 227 /* SyntaxKind.BinaryExpression */ &&
216
+ container.kind === 266 /* SyntaxKind.InterfaceDeclaration */) &&
217
+ expression.kind === 228 /* SyntaxKind.BinaryExpression */ &&
214
218
  expression.operatorToken.kind === 102 /* SyntaxKind.InKeyword */ &&
215
- node.parent.kind !== 178 /* SyntaxKind.GetAccessor */ &&
216
- node.parent.kind !== 179 /* SyntaxKind.SetAccessor */) {
219
+ node.parent.kind !== 179 /* SyntaxKind.GetAccessor */ &&
220
+ node.parent.kind !== 180 /* SyntaxKind.SetAccessor */) {
217
221
  c.resolvedTypes.set(nodeId, c.errorType);
218
222
  return c.resolvedTypes.get(nodeId);
219
223
  }
@@ -223,14 +227,14 @@ export function checkComputedPropertyName(c, node) {
223
227
  if ((t.flags & 12 /* TypeFlags.Nullable */) !== 0 ||
224
228
  (!isTypeAssignableToKind(c, t, 12583968 /* TypeFlags.StringLike */ | 67648 /* TypeFlags.NumberLike */ | 16896 /* TypeFlags.ESSymbolLike */, false) &&
225
229
  !isTypeAssignableTo(c, t, c.stringNumberSymbolType)))
226
- c.error(node, 630 /* Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any */);
230
+ c.error(node, 637 /* Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any */);
227
231
  }
228
232
  return c.resolvedTypes.get(nodeId);
229
233
  }
230
234
  /** A parameter's declared type without `undefined` when its initializer can't be `undefined`. */
231
235
  function removeOptionalityFromDeclaredType(c, declaredType, declaration) {
232
236
  const removeUndefined = c.strictNullChecks &&
233
- declaration.kind === 170 /* SyntaxKind.Parameter */ &&
237
+ declaration.kind === 171 /* SyntaxKind.Parameter */ &&
234
238
  getInitializer(declaration) !== undefined &&
235
239
  hasTypeFacts(c, declaredType, 16777216 /* TypeFacts.IsUndefined */) &&
236
240
  !parameterInitializerContainsUndefined(c, declaration);
@@ -257,19 +261,19 @@ function parameterInitializerContainsUndefined(c, declaration) {
257
261
  /** Whether `node` is the operand of a spread in an object destructuring assignment, as in `({ ...x } = obj)`. */
258
262
  function isSpreadDestructuringAssignmentTarget(node) {
259
263
  const parent = node.parent;
260
- if (parent.kind !== 305 /* SyntaxKind.SpreadAssignment */ || parent.parent === undefined)
264
+ if (parent.kind !== 306 /* SyntaxKind.SpreadAssignment */ || parent.parent === undefined)
261
265
  return false;
262
266
  const pattern = parent.parent;
263
267
  const grandparent = pattern.parent;
264
- return ((grandparent.kind === 227 /* SyntaxKind.BinaryExpression */ && grandparent.left === pattern) ||
265
- (grandparent.kind === 251 /* SyntaxKind.ForOfStatement */ && grandparent.initializer === pattern));
268
+ return ((grandparent.kind === 228 /* SyntaxKind.BinaryExpression */ && grandparent.left === pattern) ||
269
+ (grandparent.kind === 252 /* SyntaxKind.ForOfStatement */ && grandparent.initializer === pattern));
266
270
  }
267
271
  /** Whether `node` is in a binding element of the same declaration as the binding element `declaration`. */
268
272
  function isSameScopedBindingElement(node, declaration) {
269
- if (declaration.kind !== 209 /* SyntaxKind.BindingElement */)
273
+ if (declaration.kind !== 210 /* SyntaxKind.BindingElement */)
270
274
  return false;
271
275
  let bindingElement = node.parent;
272
- while (bindingElement !== undefined && bindingElement.kind !== 209 /* SyntaxKind.BindingElement */)
276
+ while (bindingElement !== undefined && bindingElement.kind !== 210 /* SyntaxKind.BindingElement */)
273
277
  bindingElement = bindingElement.parent;
274
278
  return bindingElement !== undefined && getRootDeclaration(bindingElement) === getRootDeclaration(declaration);
275
279
  }
@@ -278,16 +282,16 @@ export function isThisInTypeQuery(node) {
278
282
  if (node.kind !== 79 /* SyntaxKind.Identifier */ || getText(node) !== 'this')
279
283
  return false;
280
284
  let current = node;
281
- while (current.parent.kind === 167 /* SyntaxKind.QualifiedName */ && current.parent.left === current)
285
+ while (current.parent.kind === 168 /* SyntaxKind.QualifiedName */ && current.parent.left === current)
282
286
  current = current.parent;
283
- return current.parent.kind === 187 /* SyntaxKind.TypeQuery */;
287
+ return current.parent.kind === 188 /* SyntaxKind.TypeQuery */;
284
288
  }
285
289
  /** The type of the expression in a `typeof` type query. */
286
290
  export function checkTypeQueryExpression(c, node) {
287
291
  const exprName = node.exprName;
288
292
  if (exprName.kind === 79 /* SyntaxKind.Identifier */)
289
293
  return checkIdentifier(c, exprName);
290
- if (exprName.kind === 167 /* SyntaxKind.QualifiedName */)
294
+ if (exprName.kind === 168 /* SyntaxKind.QualifiedName */)
291
295
  return checkQualifiedName(c, exprName);
292
296
  if (exprName.kind === 109 /* SyntaxKind.ThisKeyword */)
293
297
  return checkThisExpression(c, exprName);
@@ -299,9 +303,9 @@ export function getResolvedSymbol(c, node) {
299
303
  if (cached !== undefined)
300
304
  return cached;
301
305
  let symbol = c.unknownSymbol;
302
- if (getText(node) !== '') {
303
- const text = getText(node);
304
- const found = resolveName(c, node, text, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */, getCannotFindNameDiagnosticForName(c, node), !isWriteOnlyAccess(node), false);
306
+ const text = getText(node);
307
+ if (text !== '') {
308
+ const found = resolveName(c, node, text, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */, cannotFindNameAtLocation, !isWriteOnlyAccess(node), false);
305
309
  if (found !== undefined)
306
310
  symbol = found;
307
311
  }
@@ -332,40 +336,40 @@ function checkExpressionWorker(c, node, checkMode) {
332
336
  return getFreshTypeOfLiteralType(c, getNumberLiteralType(c, Number(getText(node))));
333
337
  case 9 /* SyntaxKind.BigIntLiteral */:
334
338
  return getFreshTypeOfLiteralType(c, getBigIntLiteralType(c, parseBigIntText(getText(node))));
335
- case 229 /* SyntaxKind.TemplateExpression */:
339
+ case 230 /* SyntaxKind.TemplateExpression */:
336
340
  return checkTemplateExpression(c, node);
337
341
  case 13 /* SyntaxKind.RegularExpressionLiteral */:
338
342
  return c.globalRegExpType;
339
- case 210 /* SyntaxKind.ArrayLiteralExpression */:
343
+ case 211 /* SyntaxKind.ArrayLiteralExpression */:
340
344
  return checkArrayLiteral(c, node, checkMode);
341
- case 211 /* SyntaxKind.ObjectLiteralExpression */:
345
+ case 212 /* SyntaxKind.ObjectLiteralExpression */:
342
346
  return checkObjectLiteral(c, node, checkMode);
343
- case 212 /* SyntaxKind.PropertyAccessExpression */:
347
+ case 213 /* SyntaxKind.PropertyAccessExpression */:
344
348
  return checkPropertyAccessExpression(c, node, false, checkMode);
345
- case 167 /* SyntaxKind.QualifiedName */:
349
+ case 168 /* SyntaxKind.QualifiedName */:
346
350
  return checkQualifiedName(c, node);
347
- case 213 /* SyntaxKind.ElementAccessExpression */:
351
+ case 214 /* SyntaxKind.ElementAccessExpression */:
348
352
  return checkElementAccessExpression(c, node, checkMode);
349
- case 214 /* SyntaxKind.CallExpression */:
353
+ case 215 /* SyntaxKind.CallExpression */:
350
354
  return checkCallExpression(c, node, checkMode);
351
- case 215 /* SyntaxKind.NewExpression */:
355
+ case 216 /* SyntaxKind.NewExpression */:
352
356
  return checkNewExpression(c, node, checkMode);
353
- case 216 /* SyntaxKind.TaggedTemplateExpression */:
357
+ case 217 /* SyntaxKind.TaggedTemplateExpression */:
354
358
  return checkTaggedTemplateExpression(c, node, checkMode);
355
- case 218 /* SyntaxKind.ParenthesizedExpression */:
359
+ case 219 /* SyntaxKind.ParenthesizedExpression */:
356
360
  return checkExpressionEx(c, getExpression(node), checkMode);
357
- case 232 /* SyntaxKind.ClassExpression */:
361
+ case 233 /* SyntaxKind.ClassExpression */:
358
362
  return checkClassExpression(c, node);
359
- case 219 /* SyntaxKind.FunctionExpression */:
360
- case 220 /* SyntaxKind.ArrowFunction */:
363
+ case 220 /* SyntaxKind.FunctionExpression */:
364
+ case 221 /* SyntaxKind.ArrowFunction */:
361
365
  return checkFunctionExpressionOrObjectLiteralMethod(c, node, checkMode);
362
- case 222 /* SyntaxKind.TypeOfExpression */:
366
+ case 223 /* SyntaxKind.TypeOfExpression */:
363
367
  checkExpression(c, getExpression(node));
364
368
  return c.typeofType;
365
- case 217 /* SyntaxKind.TypeAssertionExpression */:
366
- case 235 /* SyntaxKind.AsExpression */:
369
+ case 218 /* SyntaxKind.TypeAssertionExpression */:
370
+ case 236 /* SyntaxKind.AsExpression */:
367
371
  return checkAssertion(c, node, checkMode);
368
- case 236 /* SyntaxKind.NonNullExpression */: {
372
+ case 237 /* SyntaxKind.NonNullExpression */: {
369
373
  const leftType = checkExpressionEx(c, getExpression(node), checkMode);
370
374
  if ((node.flags & 32 /* NodeFlags.OptionalChain */) === 0)
371
375
  return getNonNullableType(c, leftType);
@@ -373,41 +377,41 @@ function checkExpressionWorker(c, node, checkMode) {
373
377
  const nonOptionalType = getOptionalExpressionType(c, leftType, getExpression(node));
374
378
  return propagateOptionalTypeMarker(c, getNonNullableType(c, nonOptionalType), node, nonOptionalType !== leftType);
375
379
  }
376
- case 234 /* SyntaxKind.ExpressionWithTypeArguments */:
380
+ case 235 /* SyntaxKind.ExpressionWithTypeArguments */:
377
381
  return checkExpressionWithTypeArguments(c, node);
378
- case 239 /* SyntaxKind.SatisfiesExpression */:
382
+ case 240 /* SyntaxKind.SatisfiesExpression */:
379
383
  return checkSatisfiesExpression(c, node, checkMode);
380
- case 237 /* SyntaxKind.MetaProperty */:
384
+ case 238 /* SyntaxKind.MetaProperty */:
381
385
  return checkMetaProperty(c, node);
382
- case 221 /* SyntaxKind.DeleteExpression */:
386
+ case 222 /* SyntaxKind.DeleteExpression */:
383
387
  return checkDeleteExpression(c, node);
384
- case 223 /* SyntaxKind.VoidExpression */:
388
+ case 224 /* SyntaxKind.VoidExpression */:
385
389
  // The operand is checked deferred.
386
390
  checkNodeDeferred(c, node);
387
391
  return c.undefinedWideningType;
388
- case 224 /* SyntaxKind.AwaitExpression */:
392
+ case 225 /* SyntaxKind.AwaitExpression */:
389
393
  return checkAwaitExpression(c, node);
390
- case 225 /* SyntaxKind.PrefixUnaryExpression */:
394
+ case 226 /* SyntaxKind.PrefixUnaryExpression */:
391
395
  return checkPrefixUnaryExpression(c, node);
392
- case 226 /* SyntaxKind.PostfixUnaryExpression */:
396
+ case 227 /* SyntaxKind.PostfixUnaryExpression */:
393
397
  return checkPostfixUnaryExpression(c, node);
394
- case 227 /* SyntaxKind.BinaryExpression */:
398
+ case 228 /* SyntaxKind.BinaryExpression */:
395
399
  return checkBinaryExpression(c, node, checkMode);
396
- case 228 /* SyntaxKind.ConditionalExpression */:
400
+ case 229 /* SyntaxKind.ConditionalExpression */:
397
401
  return checkConditionalExpression(c, node, checkMode);
398
- case 231 /* SyntaxKind.SpreadElement */:
402
+ case 232 /* SyntaxKind.SpreadElement */:
399
403
  return checkSpreadExpression(c, node, checkMode);
400
- case 233 /* SyntaxKind.OmittedExpression */:
404
+ case 234 /* SyntaxKind.OmittedExpression */:
401
405
  return c.undefinedWideningType;
402
- case 230 /* SyntaxKind.YieldExpression */:
406
+ case 231 /* SyntaxKind.YieldExpression */:
403
407
  return checkYieldExpression(c, node);
404
- case 238 /* SyntaxKind.SyntheticExpression */:
408
+ case 239 /* SyntaxKind.SyntheticExpression */:
405
409
  return c.anyType;
406
- case 295 /* SyntaxKind.JsxExpression */:
407
- case 285 /* SyntaxKind.JsxElement */:
408
- case 286 /* SyntaxKind.JsxSelfClosingElement */:
409
- case 289 /* SyntaxKind.JsxFragment */:
410
- case 293 /* SyntaxKind.JsxAttributes */:
410
+ case 296 /* SyntaxKind.JsxExpression */:
411
+ case 286 /* SyntaxKind.JsxElement */:
412
+ case 287 /* SyntaxKind.JsxSelfClosingElement */:
413
+ case 290 /* SyntaxKind.JsxFragment */:
414
+ case 294 /* SyntaxKind.JsxAttributes */:
411
415
  return checkJsx(c, node, checkMode);
412
416
  }
413
417
  return c.errorType;
@@ -434,7 +438,7 @@ export function checkIdentifier(c, node, checkMode = 0 /* CheckMode.Normal */) {
434
438
  return c.errorType;
435
439
  if (symbol === c.argumentsSymbol) {
436
440
  if (isInPropertyInitializerOrClassStaticBlock(node, true)) {
437
- c.error(node, 946 /* Diagnostics.X_arguments_cannot_be_referenced_in_property_initializers_or_class_static_initialization_blocks */);
441
+ c.error(node, 953 /* Diagnostics.X_arguments_cannot_be_referenced_in_property_initializers_or_class_static_initialization_blocks */);
438
442
  return c.errorType;
439
443
  }
440
444
  return getTypeOfSymbol(c, symbol);
@@ -446,7 +450,7 @@ export function checkIdentifier(c, node, checkMode = 0 /* CheckMode.Normal */) {
446
450
  const immediateDeclaration = declaration;
447
451
  // In `const [a, b = a + 1] = [2]`, `a` is `any` while computing the contextual type of `[2]`.
448
452
  if (declaration !== undefined &&
449
- declaration.kind === 209 /* SyntaxKind.BindingElement */ &&
453
+ declaration.kind === 210 /* SyntaxKind.BindingElement */ &&
450
454
  c.contextualBindingPatterns.includes(declaration.parent) &&
451
455
  isDescendantOf(node, declaration.parent))
452
456
  return c.nonInferrableAnyType;
@@ -454,22 +458,22 @@ export function checkIdentifier(c, node, checkMode = 0 /* CheckMode.Normal */) {
454
458
  const assignmentKind = getAssignmentTargetKind(node);
455
459
  if (assignmentKind !== 0 /* AssignmentKind.None */) {
456
460
  if ((localOrExportSymbol.flags & 3 /* SymbolFlags.Variable */) === 0) {
457
- let message = 696 /* Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable */;
461
+ let message = 703 /* Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable */;
458
462
  if ((localOrExportSymbol.flags & 384 /* SymbolFlags.Enum */) !== 0)
459
- message = 771 /* Diagnostics.Cannot_assign_to_0_because_it_is_an_enum */;
463
+ message = 778 /* Diagnostics.Cannot_assign_to_0_because_it_is_an_enum */;
460
464
  else if ((localOrExportSymbol.flags & 32 /* SymbolFlags.Class */) !== 0)
461
- message = 772 /* Diagnostics.Cannot_assign_to_0_because_it_is_a_class */;
465
+ message = 779 /* Diagnostics.Cannot_assign_to_0_because_it_is_a_class */;
462
466
  else if ((localOrExportSymbol.flags & 1536 /* SymbolFlags.Module */) !== 0)
463
- message = 774 /* Diagnostics.Cannot_assign_to_0_because_it_is_a_namespace */;
467
+ message = 781 /* Diagnostics.Cannot_assign_to_0_because_it_is_a_namespace */;
464
468
  else if ((localOrExportSymbol.flags & 16 /* SymbolFlags.Function */) !== 0)
465
- message = 773 /* Diagnostics.Cannot_assign_to_0_because_it_is_a_function */;
469
+ message = 780 /* Diagnostics.Cannot_assign_to_0_because_it_is_a_function */;
466
470
  else if ((localOrExportSymbol.flags & 2097152 /* SymbolFlags.Alias */) !== 0)
467
- message = 775 /* Diagnostics.Cannot_assign_to_0_because_it_is_an_import */;
471
+ message = 782 /* Diagnostics.Cannot_assign_to_0_because_it_is_an_import */;
468
472
  c.error(node, message, symbolToString(c, symbol));
469
473
  return c.errorType;
470
474
  }
471
475
  if (isReadonlySymbol(c, localOrExportSymbol)) {
472
- c.error(node, 736 /* Diagnostics.Cannot_assign_to_0_because_it_is_a_constant */, symbolToString(c, symbol));
476
+ c.error(node, 743 /* Diagnostics.Cannot_assign_to_0_because_it_is_a_constant */, symbolToString(c, symbol));
473
477
  return c.errorType;
474
478
  }
475
479
  }
@@ -485,14 +489,14 @@ export function checkIdentifier(c, node, checkMode = 0 /* CheckMode.Normal */) {
485
489
  return t;
486
490
  if (declaration === undefined)
487
491
  return t;
488
- const isParameter = getRootDeclaration(declaration).kind === 170 /* SyntaxKind.Parameter */;
492
+ const isParameter = getRootDeclaration(declaration).kind === 171 /* SyntaxKind.Parameter */;
489
493
  // The CommonJS `module` symbol is declared by its source file.
490
494
  const declarationContainer = declaration.parent !== undefined ? getControlFlowContainer(declaration) : undefined;
491
495
  let flowContainer = getControlFlowContainer(node);
492
496
  const isOuterVariable = flowContainer !== declarationContainer;
493
497
  const isModuleExports = (symbol.flags & 134217728 /* SymbolFlags.ModuleExports */) !== 0;
494
498
  const typeIsAutomatic = t === c.autoType || t === c.autoArrayType;
495
- const isAutomaticTypeInNonNull = typeIsAutomatic && node.parent.kind === 236 /* SyntaxKind.NonNullExpression */;
499
+ const isAutomaticTypeInNonNull = typeIsAutomatic && node.parent.kind === 237 /* SyntaxKind.NonNullExpression */;
496
500
  // Closures see narrowings of constants, and of variables past their last assignment.
497
501
  while (flowContainer !== declarationContainer &&
498
502
  (isFunctionExpressionOrArrowFunction(flowContainer) ||
@@ -501,9 +505,9 @@ export function checkIdentifier(c, node, checkMode = 0 /* CheckMode.Normal */) {
501
505
  (isParameterOrMutableLocalVariable(c, localOrExportSymbol) && isPastLastAssignment(c, localOrExportSymbol, node))))
502
506
  flowContainer = getControlFlowContainer(flowContainer);
503
507
  const isNeverInitialized = immediateDeclaration !== undefined &&
504
- immediateDeclaration.kind === 261 /* SyntaxKind.VariableDeclaration */ &&
505
- immediateDeclaration.parent.parent.kind !== 250 /* SyntaxKind.ForInStatement */ &&
506
- immediateDeclaration.parent.parent.kind !== 251 /* SyntaxKind.ForOfStatement */ &&
508
+ immediateDeclaration.kind === 262 /* SyntaxKind.VariableDeclaration */ &&
509
+ immediateDeclaration.parent.parent.kind !== 251 /* SyntaxKind.ForInStatement */ &&
510
+ immediateDeclaration.parent.parent.kind !== 252 /* SyntaxKind.ForOfStatement */ &&
507
511
  getInitializer(immediateDeclaration) === undefined &&
508
512
  immediateDeclaration.exclamationToken === undefined &&
509
513
  isMutableLocalVariableDeclaration(immediateDeclaration) &&
@@ -520,9 +524,9 @@ export function checkIdentifier(c, node, checkMode = 0 /* CheckMode.Normal */) {
520
524
  (t.flags & (3 /* TypeFlags.AnyOrUnknown */ | 16 /* TypeFlags.Void */)) !== 0 ||
521
525
  isPartOfTypeQuery(node) ||
522
526
  isInAmbientOrTypeNode(node) ||
523
- node.parent.kind === 282 /* SyntaxKind.ExportSpecifier */)) ||
524
- node.parent.kind === 236 /* SyntaxKind.NonNullExpression */ ||
525
- (declaration.kind === 261 /* SyntaxKind.VariableDeclaration */ &&
527
+ node.parent.kind === 283 /* SyntaxKind.ExportSpecifier */)) ||
528
+ node.parent.kind === 237 /* SyntaxKind.NonNullExpression */ ||
529
+ (declaration.kind === 262 /* SyntaxKind.VariableDeclaration */ &&
526
530
  declaration.exclamationToken !== undefined) ||
527
531
  (declaration.flags & 8388608 /* NodeFlags.Ambient */) !== 0;
528
532
  let initialType;
@@ -542,14 +546,14 @@ export function checkIdentifier(c, node, checkMode = 0 /* CheckMode.Normal */) {
542
546
  if (!isEvolvingArrayOperationTarget(c, node) && typeIsAutomatic) {
543
547
  if (flowType === c.autoType || flowType === c.autoArrayType) {
544
548
  if (c.noImplicitAny) {
545
- c.error(getNameOfDeclaration(declaration), 1705 /* Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined */, symbolToString(c, symbol), typeToString(c, flowType));
546
- c.error(node, 1678 /* Diagnostics.Variable_0_implicitly_has_an_1_type */, symbolToString(c, symbol), typeToString(c, flowType));
549
+ c.error(getNameOfDeclaration(declaration), 1724 /* Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined */, symbolToString(c, symbol), typeToString(c, flowType));
550
+ c.error(node, 1697 /* Diagnostics.Variable_0_implicitly_has_an_1_type */, symbolToString(c, symbol), typeToString(c, flowType));
547
551
  }
548
552
  return convertAutoToAny(c, flowType);
549
553
  }
550
554
  }
551
555
  else if (!assumeInitialized && !containsUndefinedType(t) && containsUndefinedType(flowType)) {
552
- c.error(node, 621 /* Diagnostics.Variable_0_is_used_before_being_assigned */, symbolToString(c, symbol));
556
+ c.error(node, 628 /* Diagnostics.Variable_0_is_used_before_being_assigned */, symbolToString(c, symbol));
553
557
  return t;
554
558
  }
555
559
  return assignmentKind !== 0 /* AssignmentKind.None */ ? getBaseTypeOfLiteralType(c, flowType) : flowType;
@@ -578,11 +582,11 @@ export function someTypeIsGenericWithUnionConstraint(c, t) {
578
582
  function isConstraintPosition(c, t, node) {
579
583
  const parent = node.parent;
580
584
  // `obj[x]` keeps `T[K]` when both are generic and obj's constraint isn't nullable.
581
- return (parent.kind === 212 /* SyntaxKind.PropertyAccessExpression */ ||
582
- parent.kind === 167 /* SyntaxKind.QualifiedName */ ||
583
- ((parent.kind === 214 /* SyntaxKind.CallExpression */ || parent.kind === 215 /* SyntaxKind.NewExpression */) &&
585
+ return (parent.kind === 213 /* SyntaxKind.PropertyAccessExpression */ ||
586
+ parent.kind === 168 /* SyntaxKind.QualifiedName */ ||
587
+ ((parent.kind === 215 /* SyntaxKind.CallExpression */ || parent.kind === 216 /* SyntaxKind.NewExpression */) &&
584
588
  getExpression(parent) === node) ||
585
- (parent.kind === 213 /* SyntaxKind.ElementAccessExpression */ &&
589
+ (parent.kind === 214 /* SyntaxKind.ElementAccessExpression */ &&
586
590
  getExpression(parent) === node &&
587
591
  !(someType(t, (u) => isGenericTypeWithoutNullableConstraint(c, u)) &&
588
592
  isGenericIndexType(c, getTypeOfExpression(c, parent.argumentExpression)))));
@@ -609,11 +613,11 @@ function isGenericTypeWithoutNullableConstraint(c, t) {
609
613
  function hasContextualTypeWithNoGenericTypes(c, node, checkMode) {
610
614
  // JSX tag names are excluded: their contextual type resolves the tag itself.
611
615
  if (node.kind !== 79 /* SyntaxKind.Identifier */ &&
612
- node.kind !== 212 /* SyntaxKind.PropertyAccessExpression */ &&
613
- node.kind !== 213 /* SyntaxKind.ElementAccessExpression */)
616
+ node.kind !== 213 /* SyntaxKind.PropertyAccessExpression */ &&
617
+ node.kind !== 214 /* SyntaxKind.ElementAccessExpression */)
614
618
  return false;
615
619
  const parent = node.parent;
616
- if ((parent.kind === 287 /* SyntaxKind.JsxOpeningElement */ || parent.kind === 286 /* SyntaxKind.JsxSelfClosingElement */) &&
620
+ if ((parent.kind === 288 /* SyntaxKind.JsxOpeningElement */ || parent.kind === 287 /* SyntaxKind.JsxSelfClosingElement */) &&
617
621
  getTagName(parent) === node)
618
622
  return false;
619
623
  // Rest elements skip binding pattern contextual types, so their type stays generic when possible.
@@ -635,9 +639,9 @@ export function isInAmbientOrTypeNode(node) {
635
639
  if ((node.flags & 8388608 /* NodeFlags.Ambient */) !== 0)
636
640
  return true;
637
641
  for (let current = node; current !== undefined; current = current.parent) {
638
- if (current.kind === 265 /* SyntaxKind.InterfaceDeclaration */ ||
639
- current.kind === 266 /* SyntaxKind.TypeAliasDeclaration */ ||
640
- current.kind === 188 /* SyntaxKind.TypeLiteral */)
642
+ if (current.kind === 266 /* SyntaxKind.InterfaceDeclaration */ ||
643
+ current.kind === 267 /* SyntaxKind.TypeAliasDeclaration */ ||
644
+ current.kind === 189 /* SyntaxKind.TypeLiteral */)
641
645
  return true;
642
646
  }
643
647
  return false;
@@ -647,15 +651,15 @@ export function checkThisExpression(c, node) {
647
651
  let container = getThisContainer(node, true, true);
648
652
  let capturedByArrowFunction = false;
649
653
  let thisInComputedPropertyName = false;
650
- if (container.kind === 177 /* SyntaxKind.Constructor */)
651
- checkThisBeforeSuper(c, node, container, 1812 /* Diagnostics.X_super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class */);
654
+ if (container.kind === 178 /* SyntaxKind.Constructor */)
655
+ checkThisBeforeSuper(c, node, container, 1832 /* Diagnostics.X_super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class */);
652
656
  for (;;) {
653
657
  // Skip arrow functions to the real owner of `this`.
654
- if (container.kind === 220 /* SyntaxKind.ArrowFunction */) {
658
+ if (container.kind === 221 /* SyntaxKind.ArrowFunction */) {
655
659
  container = getThisContainer(container, false, !thisInComputedPropertyName);
656
660
  capturedByArrowFunction = true;
657
661
  }
658
- if (container.kind === 168 /* SyntaxKind.ComputedPropertyName */) {
662
+ if (container.kind === 169 /* SyntaxKind.ComputedPropertyName */) {
659
663
  container = getThisContainer(container, !capturedByArrowFunction, false);
660
664
  thisInComputedPropertyName = true;
661
665
  continue;
@@ -664,23 +668,31 @@ export function checkThisExpression(c, node) {
664
668
  }
665
669
  checkThisInStaticClassFieldInitializerInDecoratedClass(c, node, container);
666
670
  if (thisInComputedPropertyName)
667
- c.error(node, 631 /* Diagnostics.X_this_cannot_be_referenced_in_a_computed_property_name */);
668
- else if (container.kind === 268 /* SyntaxKind.ModuleDeclaration */)
669
- c.error(node, 509 /* Diagnostics.X_this_cannot_be_referenced_in_a_module_or_namespace_body */);
670
- else if (container.kind === 267 /* SyntaxKind.EnumDeclaration */)
671
- c.error(node, 510 /* Diagnostics.X_this_cannot_be_referenced_in_current_location */);
671
+ c.error(node, 638 /* Diagnostics.X_this_cannot_be_referenced_in_a_computed_property_name */);
672
+ else if (container.kind === 269 /* SyntaxKind.ModuleDeclaration */)
673
+ c.error(node, 516 /* Diagnostics.X_this_cannot_be_referenced_in_a_module_or_namespace_body */);
674
+ else if (container.kind === 268 /* SyntaxKind.EnumDeclaration */)
675
+ c.error(node, 517 /* Diagnostics.X_this_cannot_be_referenced_in_current_location */);
672
676
  const t = tryGetThisTypeAt(c, node, container);
673
677
  if (c.noImplicitThis) {
674
678
  const globalThisType = getTypeOfSymbol(c, c.globalThisSymbol);
675
679
  if (t === globalThisType && capturedByArrowFunction)
676
- c.error(node, 1712 /* Diagnostics.The_containing_arrow_function_captures_the_global_value_of_this */);
677
- else if (t === undefined)
678
- c.error(node, 816 /* Diagnostics.X_this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation */);
680
+ c.error(node, 1731 /* Diagnostics.The_containing_arrow_function_captures_the_global_value_of_this */);
681
+ else if (t === undefined) {
682
+ // The related information goes on the reported diagnostic after it is added, as tsgo attaches it,
683
+ // so a later equal report compares unequal to it and is kept.
684
+ const diagnostic = c.error(node, 823 /* Diagnostics.X_this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation */);
685
+ if (container.kind !== 308 /* SyntaxKind.SourceFile */) {
686
+ const outsideThis = tryGetThisTypeAt(c, container, getThisContainer(container, false, false));
687
+ if (outsideThis !== undefined && outsideThis !== globalThisType)
688
+ diagnostic.addRelatedInfo(createDiagnosticForNode(container, 877 /* Diagnostics.An_outer_value_of_this_is_shadowed_by_this_container */, []));
689
+ }
690
+ }
679
691
  }
680
692
  return t ?? c.anyType;
681
693
  }
682
694
  function tryGetThisTypeAt(c, node, container) {
683
- if (isFunctionLike(container) && container.kind !== 177 /* SyntaxKind.Constructor */) {
695
+ if (isFunctionLike(container) && container.kind !== 178 /* SyntaxKind.Constructor */) {
684
696
  const thisType = getThisTypeOfSignature(c, getSignatureOfFullSignatureType(c, container) ?? getSignatureFromDeclaration(c, container)) ?? getContextualThisParameterType(c, container);
685
697
  if (thisType !== undefined)
686
698
  return getFlowTypeOfReference(c, node, thisType, thisType, undefined);
@@ -690,12 +702,12 @@ function tryGetThisTypeAt(c, node, container) {
690
702
  const classSymbol = getSymbolOfDeclaration(c, parent);
691
703
  if (classSymbol === undefined)
692
704
  return c.anyType;
693
- const t = isStatic(container) || container.kind === 176 /* SyntaxKind.ClassStaticBlockDeclaration */
705
+ const t = isStatic(container) || container.kind === 177 /* SyntaxKind.ClassStaticBlockDeclaration */
694
706
  ? getTypeOfSymbol(c, classSymbol)
695
707
  : getDeclaredTypeOfClassOrInterface(c, getMergedSymbol(c, classSymbol)).thisType;
696
708
  return t !== undefined ? getFlowTypeOfReference(c, node, t, t, undefined) : c.anyType;
697
709
  }
698
- if (container.kind === 307 /* SyntaxKind.SourceFile */) {
710
+ if (container.kind === 308 /* SyntaxKind.SourceFile */) {
699
711
  if (container.externalModuleIndicator !== undefined)
700
712
  return c.undefinedType;
701
713
  return getTypeOfSymbol(c, c.globalThisSymbol);
@@ -704,7 +716,7 @@ function tryGetThisTypeAt(c, node, container) {
704
716
  }
705
717
  /** The `this` type of a function expression or method from its context, such as its object literal. */
706
718
  export function getContextualThisParameterType(c, func) {
707
- if (func.kind === 220 /* SyntaxKind.ArrowFunction */)
719
+ if (func.kind === 221 /* SyntaxKind.ArrowFunction */)
708
720
  return undefined;
709
721
  if (isContextSensitiveFunctionOrObjectLiteralMethod(c, func)) {
710
722
  const signature = getContextualSignatureForFunctionLikeDeclaration(c, func);
@@ -720,12 +732,12 @@ export function getContextualThisParameterType(c, func) {
720
732
  }
721
733
  function getContainingObjectLiteral(func) {
722
734
  const parent = func.parent;
723
- if ((func.kind === 175 /* SyntaxKind.MethodDeclaration */ ||
724
- func.kind === 178 /* SyntaxKind.GetAccessor */ ||
725
- func.kind === 179 /* SyntaxKind.SetAccessor */) &&
726
- parent.kind === 211 /* SyntaxKind.ObjectLiteralExpression */)
735
+ if ((func.kind === 176 /* SyntaxKind.MethodDeclaration */ ||
736
+ func.kind === 179 /* SyntaxKind.GetAccessor */ ||
737
+ func.kind === 180 /* SyntaxKind.SetAccessor */) &&
738
+ parent.kind === 212 /* SyntaxKind.ObjectLiteralExpression */)
727
739
  return parent;
728
- if (func.kind === 219 /* SyntaxKind.FunctionExpression */ && parent.kind === 303 /* SyntaxKind.PropertyAssignment */)
740
+ if (func.kind === 220 /* SyntaxKind.FunctionExpression */ && parent.kind === 304 /* SyntaxKind.PropertyAssignment */)
729
741
  return parent.parent;
730
742
  return undefined;
731
743
  }
@@ -738,11 +750,11 @@ function checkTemplateExpression(c, node) {
738
750
  const t = checkExpression(c, expression);
739
751
  if (maybeTypeOfKind(t, 16896 /* TypeFlags.ESSymbolLike */) ||
740
752
  maybeTypeOfKind(getBaseConstraintOrType(c, t), 16896 /* TypeFlags.ESSymbolLike */))
741
- c.error(expression, 863 /* Diagnostics.Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String */);
753
+ c.error(expression, 870 /* Diagnostics.Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String */);
742
754
  texts.push(getText(span.literal));
743
755
  types.push(isTypeAssignableTo(c, t, c.templateConstraintType) ? t : c.stringType);
744
756
  }
745
- if (node.parent.kind !== 216 /* SyntaxKind.TaggedTemplateExpression */) {
757
+ if (node.parent.kind !== 217 /* SyntaxKind.TaggedTemplateExpression */) {
746
758
  const evaluated = evaluate(c, node, node);
747
759
  if (evaluated.kind === 2 /* EvaluatedKind.String */)
748
760
  return getFreshTypeOfLiteralType(c, getStringLiteralType(c, evaluated.stringValue));
@@ -755,8 +767,8 @@ function checkTemplateExpression(c, node) {
755
767
  }
756
768
  function isTemplateLiteralContext(node) {
757
769
  const parent = node.parent;
758
- return ((parent.kind === 218 /* SyntaxKind.ParenthesizedExpression */ && isTemplateLiteralContext(parent)) ||
759
- (parent.kind === 213 /* SyntaxKind.ElementAccessExpression */ &&
770
+ return ((parent.kind === 219 /* SyntaxKind.ParenthesizedExpression */ && isTemplateLiteralContext(parent)) ||
771
+ (parent.kind === 214 /* SyntaxKind.ElementAccessExpression */ &&
760
772
  parent.argumentExpression === node));
761
773
  }
762
774
  function isTemplateLiteralContextualType(c, t) {
@@ -781,7 +793,7 @@ function checkArrayLiteral(c, node, checkMode) {
781
793
  (contextualType !== undefined && someType(contextualType, (t) => isTupleLikeContext(c, t)));
782
794
  let hasOmittedExpression = false;
783
795
  for (const e of elements) {
784
- if (e.kind === 231 /* SyntaxKind.SpreadElement */) {
796
+ if (e.kind === 232 /* SyntaxKind.SpreadElement */) {
785
797
  const spreadType = checkExpressionEx(c, e.expression, checkMode);
786
798
  if (isArrayLikeType(c, spreadType)) {
787
799
  elementTypes.push(spreadType);
@@ -801,13 +813,13 @@ function checkArrayLiteral(c, node, checkMode) {
801
813
  elementInfos.push(new TupleElementInfo(4 /* ElementFlags.Rest */, undefined));
802
814
  }
803
815
  }
804
- else if (c.exactOptionalPropertyTypes && e.kind === 233 /* SyntaxKind.OmittedExpression */) {
816
+ else if (c.exactOptionalPropertyTypes && e.kind === 234 /* SyntaxKind.OmittedExpression */) {
805
817
  hasOmittedExpression = true;
806
818
  elementTypes.push(c.undefinedOrMissingType);
807
819
  elementInfos.push(new TupleElementInfo(2 /* ElementFlags.Optional */, undefined));
808
820
  }
809
821
  else {
810
- const t = e.kind === 233 /* SyntaxKind.OmittedExpression */
822
+ const t = e.kind === 234 /* SyntaxKind.OmittedExpression */
811
823
  ? c.undefinedWideningType
812
824
  : checkExpressionForMutableLocationEx(c, e, checkMode);
813
825
  if (inTupleContext &&
@@ -843,10 +855,10 @@ function checkArrayLiteral(c, node, checkMode) {
843
855
  }
844
856
  function isSpreadIntoCallOrNew(node) {
845
857
  let parent = node.parent;
846
- while (parent.kind === 218 /* SyntaxKind.ParenthesizedExpression */)
858
+ while (parent.kind === 219 /* SyntaxKind.ParenthesizedExpression */)
847
859
  parent = parent.parent;
848
- return (parent.kind === 231 /* SyntaxKind.SpreadElement */ &&
849
- (parent.parent.kind === 214 /* SyntaxKind.CallExpression */ || parent.parent.kind === 215 /* SyntaxKind.NewExpression */));
860
+ return (parent.kind === 232 /* SyntaxKind.SpreadElement */ &&
861
+ (parent.parent.kind === 215 /* SyntaxKind.CallExpression */ || parent.parent.kind === 216 /* SyntaxKind.NewExpression */));
850
862
  }
851
863
  function isTupleLikeContext(c, t) {
852
864
  if (isTupleLikeType(c, t))
@@ -870,7 +882,8 @@ export function isTupleLikeType(c, t) {
870
882
  /** Whether `t` is a mutable array, a mutable tuple, or assignable to `any[]`. */
871
883
  export function isMutableArrayLikeType(c, t) {
872
884
  return (isMutableArrayOrTuple(c, t) ||
873
- ((t.flags & (1 /* TypeFlags.Any */ | 12 /* TypeFlags.Nullable */)) === 0 && isTypeAssignableTo(c, t, c.anyArrayType)));
885
+ ((t.flags & (1 /* TypeFlags.Any */ | 12 /* TypeFlags.Nullable */ | 262144 /* TypeFlags.Never */)) === 0 &&
886
+ isTypeAssignableTo(c, t, c.anyArrayType)));
874
887
  }
875
888
  function createArrayLiteralType(c, t) {
876
889
  if ((t.objectFlags & 4 /* ObjectFlags.Reference */) === 0)
@@ -899,36 +912,59 @@ export function getPropertyNameOfObjectLiteralElement(c, element) {
899
912
  return String(Number(getText(name)));
900
913
  case 9 /* SyntaxKind.BigIntLiteral */:
901
914
  return parseBigIntText(getText(name));
902
- case 168 /* SyntaxKind.ComputedPropertyName */: {
915
+ case 169 /* SyntaxKind.ComputedPropertyName */: {
903
916
  const t = checkComputedPropertyName(c, name);
904
917
  return isTypeUsableAsPropertyName(t) ? getPropertyNameFromType(t) : undefined;
905
918
  }
906
919
  }
907
920
  return undefined;
908
921
  }
922
+ /** Whether `node` is the object literal of the `with` property of an `import()` call's options argument. */
923
+ function isInlineImportAttributes(node) {
924
+ const property = node.parent;
925
+ if (node.kind !== 212 /* SyntaxKind.ObjectLiteralExpression */ ||
926
+ property.kind !== 304 /* SyntaxKind.PropertyAssignment */ ||
927
+ getInitializer(property) !== node)
928
+ return false;
929
+ const name = getName(property);
930
+ if ((name.kind !== 79 /* SyntaxKind.Identifier */ && !isStringLiteralLike(name)) || getText(name) !== 'with')
931
+ return false;
932
+ const options = property.parent;
933
+ if (options.kind !== 212 /* SyntaxKind.ObjectLiteralExpression */)
934
+ return false;
935
+ let importCall = options;
936
+ while (importCall !== undefined && !isImportCall(importCall))
937
+ importCall = importCall.parent;
938
+ if (importCall === undefined)
939
+ return false;
940
+ const args = importCall.arguments.nodes;
941
+ return args.length > 1 && skipParentheses(args[1]) === options;
942
+ }
909
943
  /** Whether `node` is in an `as const` context, where literals keep their types. */
910
944
  export function isConstContext(c, node) {
911
945
  const parent = node.parent;
912
946
  if (parent === undefined)
913
947
  return false;
948
+ if (isInlineImportAttributes(node))
949
+ return true;
914
950
  // Literals contextually typed by a `const` type parameter are in a const context.
915
951
  if (isValidConstAssertionArgument(c, node) && isConstTypeVariable(c, getContextualType(c, node), 0))
916
952
  return true;
917
953
  switch (parent.kind) {
918
- case 235 /* SyntaxKind.AsExpression */:
919
- case 217 /* SyntaxKind.TypeAssertionExpression */:
954
+ case 236 /* SyntaxKind.AsExpression */:
955
+ case 218 /* SyntaxKind.TypeAssertionExpression */:
920
956
  return isConstTypeReference(getType(parent));
921
957
  // As in tsgo, a const context does not reach through `satisfies` or into the branches of a
922
958
  // conditional expression: those are in one only when their own contextual type is a `const`
923
959
  // type parameter (above).
924
- case 218 /* SyntaxKind.ParenthesizedExpression */:
925
- case 210 /* SyntaxKind.ArrayLiteralExpression */:
926
- case 231 /* SyntaxKind.SpreadElement */:
960
+ case 219 /* SyntaxKind.ParenthesizedExpression */:
961
+ case 211 /* SyntaxKind.ArrayLiteralExpression */:
962
+ case 232 /* SyntaxKind.SpreadElement */:
927
963
  return isConstContext(c, parent);
928
- case 303 /* SyntaxKind.PropertyAssignment */:
929
- case 304 /* SyntaxKind.ShorthandPropertyAssignment */:
964
+ case 304 /* SyntaxKind.PropertyAssignment */:
965
+ case 305 /* SyntaxKind.ShorthandPropertyAssignment */:
930
966
  return isConstContext(c, parent.parent);
931
- case 240 /* SyntaxKind.TemplateSpan */:
967
+ case 241 /* SyntaxKind.TemplateSpan */:
932
968
  return isConstContext(c, parent.parent);
933
969
  }
934
970
  return false;
@@ -942,21 +978,21 @@ function isValidConstAssertionArgument(c, node) {
942
978
  case 9 /* SyntaxKind.BigIntLiteral */:
943
979
  case 111 /* SyntaxKind.TrueKeyword */:
944
980
  case 96 /* SyntaxKind.FalseKeyword */:
945
- case 210 /* SyntaxKind.ArrayLiteralExpression */:
946
- case 211 /* SyntaxKind.ObjectLiteralExpression */:
947
- case 229 /* SyntaxKind.TemplateExpression */:
981
+ case 211 /* SyntaxKind.ArrayLiteralExpression */:
982
+ case 212 /* SyntaxKind.ObjectLiteralExpression */:
983
+ case 230 /* SyntaxKind.TemplateExpression */:
948
984
  return true;
949
- case 218 /* SyntaxKind.ParenthesizedExpression */:
985
+ case 219 /* SyntaxKind.ParenthesizedExpression */:
950
986
  return isValidConstAssertionArgument(c, getExpression(node));
951
- case 225 /* SyntaxKind.PrefixUnaryExpression */: {
987
+ case 226 /* SyntaxKind.PrefixUnaryExpression */: {
952
988
  const unary = node;
953
989
  const kind = unary.operand.kind;
954
990
  return ((unary.operator === 40 /* SyntaxKind.MinusToken */ &&
955
991
  (kind === 8 /* SyntaxKind.NumericLiteral */ || kind === 9 /* SyntaxKind.BigIntLiteral */)) ||
956
992
  (unary.operator === 39 /* SyntaxKind.PlusToken */ && kind === 8 /* SyntaxKind.NumericLiteral */));
957
993
  }
958
- case 212 /* SyntaxKind.PropertyAccessExpression */:
959
- case 213 /* SyntaxKind.ElementAccessExpression */: {
994
+ case 213 /* SyntaxKind.PropertyAccessExpression */:
995
+ case 214 /* SyntaxKind.ElementAccessExpression */: {
960
996
  const expr = skipParentheses(getExpression(node));
961
997
  const symbol = isEntityNameExpression(expr, false)
962
998
  ? resolveEntityName(c, expr, 111551 /* SymbolFlags.Value */, true, false, undefined)
@@ -967,7 +1003,7 @@ function isValidConstAssertionArgument(c, node) {
967
1003
  return false;
968
1004
  }
969
1005
  export function isConstTypeReference(node) {
970
- if (node.kind !== 184 /* SyntaxKind.TypeReference */)
1006
+ if (node.kind !== 185 /* SyntaxKind.TypeReference */)
971
1007
  return false;
972
1008
  const ref = node;
973
1009
  return (ref.typeName.kind === 79 /* SyntaxKind.Identifier */ && getText(ref.typeName) === 'const' && ref.typeArguments === undefined);
@@ -1021,11 +1057,11 @@ export function checkNonNullTypeEx(c, t, node, isCallee) {
1021
1057
  if (isEntityNameExpression(node, false)) {
1022
1058
  const nodeText = entityNameToString(node);
1023
1059
  if (nodeText.length < 100) {
1024
- c.error(node, 1862 /* Diagnostics.X_0_is_of_type_unknown */, nodeText);
1060
+ c.error(node, 1882 /* Diagnostics.X_0_is_of_type_unknown */, nodeText);
1025
1061
  return c.errorType;
1026
1062
  }
1027
1063
  }
1028
- c.error(node, 724 /* Diagnostics.Object_is_of_type_unknown */);
1064
+ c.error(node, 731 /* Diagnostics.Object_is_of_type_unknown */);
1029
1065
  return c.errorType;
1030
1066
  }
1031
1067
  const facts = getTypeFacts(c, t, 50331648 /* TypeFacts.IsUndefinedOrNull */);
@@ -1042,33 +1078,33 @@ export function checkNonNullTypeEx(c, t, node, isCallee) {
1042
1078
  function reportCannotInvokePossiblyNullOrUndefinedError(c, node, facts) {
1043
1079
  c.error(node, (facts & 16777216 /* TypeFacts.IsUndefined */) !== 0
1044
1080
  ? (facts & 33554432 /* TypeFacts.IsNull */) !== 0
1045
- ? 855 /* Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined */
1046
- : 854 /* Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined */
1047
- : 853 /* Diagnostics.Cannot_invoke_an_object_which_is_possibly_null */);
1081
+ ? 862 /* Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined */
1082
+ : 861 /* Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined */
1083
+ : 860 /* Diagnostics.Cannot_invoke_an_object_which_is_possibly_null */);
1048
1084
  }
1049
1085
  function reportObjectPossiblyNullOrUndefinedError(c, node, facts) {
1050
1086
  if (node.kind === 105 /* SyntaxKind.NullKeyword */) {
1051
- c.error(node, 1866 /* Diagnostics.The_value_0_cannot_be_used_here */, 'null');
1087
+ c.error(node, 1886 /* Diagnostics.The_value_0_cannot_be_used_here */, 'null');
1052
1088
  return;
1053
1089
  }
1054
1090
  const nodeText = isEntityNameExpression(node, false) ? entityNameToString(node) : '';
1055
1091
  if (nodeText !== '' && nodeText.length < 100) {
1056
1092
  if (node.kind === 79 /* SyntaxKind.Identifier */ && nodeText === 'undefined') {
1057
- c.error(node, 1866 /* Diagnostics.The_value_0_cannot_be_used_here */, 'undefined');
1093
+ c.error(node, 1886 /* Diagnostics.The_value_0_cannot_be_used_here */, 'undefined');
1058
1094
  return;
1059
1095
  }
1060
1096
  c.error(node, (facts & 16777216 /* TypeFacts.IsUndefined */) !== 0
1061
1097
  ? (facts & 33554432 /* TypeFacts.IsNull */) !== 0
1062
- ? 1865 /* Diagnostics.X_0_is_possibly_null_or_undefined */
1063
- : 1864 /* Diagnostics.X_0_is_possibly_undefined */
1064
- : 1863 /* Diagnostics.X_0_is_possibly_null */, nodeText);
1098
+ ? 1885 /* Diagnostics.X_0_is_possibly_null_or_undefined */
1099
+ : 1884 /* Diagnostics.X_0_is_possibly_undefined */
1100
+ : 1883 /* Diagnostics.X_0_is_possibly_null */, nodeText);
1065
1101
  }
1066
1102
  else {
1067
1103
  c.error(node, (facts & 16777216 /* TypeFacts.IsUndefined */) !== 0
1068
1104
  ? (facts & 33554432 /* TypeFacts.IsNull */) !== 0
1069
- ? 691 /* Diagnostics.Object_is_possibly_null_or_undefined */
1070
- : 690 /* Diagnostics.Object_is_possibly_undefined */
1071
- : 689 /* Diagnostics.Object_is_possibly_null */);
1105
+ ? 698 /* Diagnostics.Object_is_possibly_null_or_undefined */
1106
+ : 697 /* Diagnostics.Object_is_possibly_undefined */
1107
+ : 696 /* Diagnostics.Object_is_possibly_null */);
1072
1108
  }
1073
1109
  }
1074
1110
  /** `checkNonNullType`, also reporting a `void` type as possibly undefined. */
@@ -1079,15 +1115,15 @@ export function checkNonNullNonVoidType(c, t, node) {
1079
1115
  if (isEntityNameExpression(node, false)) {
1080
1116
  const nodeText = entityNameToString(node);
1081
1117
  if (node.kind === 79 /* SyntaxKind.Identifier */ && nodeText === 'undefined') {
1082
- c.error(node, 1866 /* Diagnostics.The_value_0_cannot_be_used_here */, nodeText);
1118
+ c.error(node, 1886 /* Diagnostics.The_value_0_cannot_be_used_here */, nodeText);
1083
1119
  return nonNullType;
1084
1120
  }
1085
1121
  if (nodeText.length < 100) {
1086
- c.error(node, 1864 /* Diagnostics.X_0_is_possibly_undefined */, nodeText);
1122
+ c.error(node, 1884 /* Diagnostics.X_0_is_possibly_undefined */, nodeText);
1087
1123
  return nonNullType;
1088
1124
  }
1089
1125
  }
1090
- c.error(node, 690 /* Diagnostics.Object_is_possibly_undefined */);
1126
+ c.error(node, 697 /* Diagnostics.Object_is_possibly_undefined */);
1091
1127
  return nonNullType;
1092
1128
  }
1093
1129
  export function entityNameToString(node) {
@@ -1096,13 +1132,13 @@ export function entityNameToString(node) {
1096
1132
  return getText(node);
1097
1133
  case 109 /* SyntaxKind.ThisKeyword */:
1098
1134
  return 'this';
1099
- case 212 /* SyntaxKind.PropertyAccessExpression */: {
1135
+ case 213 /* SyntaxKind.PropertyAccessExpression */: {
1100
1136
  const access = node;
1101
1137
  return entityNameToString(access.expression) + '.' + entityNameToString(access.name);
1102
1138
  }
1103
- case 167 /* SyntaxKind.QualifiedName */: {
1139
+ case 168 /* SyntaxKind.QualifiedName */: {
1104
1140
  const q = node;
1105
- return entityNameToString(q.left) + '.' + q.right.text;
1141
+ return entityNameToString(q.left) + '.' + getText(q.right);
1106
1142
  }
1107
1143
  }
1108
1144
  return getText(node);
@@ -1137,41 +1173,37 @@ export function getFlowTypeOfAccessExpression(c, node, prop, propTypeIn, errorNo
1137
1173
  if (propType === c.autoType)
1138
1174
  return getFlowTypeOfAutoTypedProperty(c, node, prop);
1139
1175
  propType = getNarrowableTypeForReference(c, propType, node, checkMode);
1140
- // `this.x` in the constructor of x's class starts out uninitialized under strictPropertyInitialization.
1176
+ // `this.x` in the constructor of x's class starts out uninitialized under strictPropertyInitialization,
1177
+ // and a JavaScript `this.x = …` declaration is unassigned before it in its own function.
1141
1178
  let assumeUninitialized = false;
1142
- const expression = getExpression(node);
1143
- if (c.strictNullChecks &&
1144
- c.strictPropertyInitialization &&
1145
- expression !== undefined &&
1146
- expression.kind === 109 /* SyntaxKind.ThisKeyword */ &&
1147
- prop !== undefined) {
1179
+ if (c.strictNullChecks && prop !== undefined) {
1148
1180
  const declaration = prop.valueDeclaration;
1149
- if (declaration !== undefined && isPropertyWithoutInitializer(declaration) && !isStatic(declaration)) {
1150
- const flowContainer = getControlFlowContainer(node);
1151
- assumeUninitialized =
1152
- flowContainer.kind === 177 /* SyntaxKind.Constructor */ &&
1153
- flowContainer.parent === declaration.parent &&
1154
- (declaration.flags & 8388608 /* NodeFlags.Ambient */) === 0;
1181
+ const expression = getExpression(node);
1182
+ if (c.strictPropertyInitialization && expression !== undefined && expression.kind === 109 /* SyntaxKind.ThisKeyword */) {
1183
+ if (declaration !== undefined && isPropertyWithoutInitializer(declaration) && !isStatic(declaration)) {
1184
+ const flowContainer = getControlFlowContainer(node);
1185
+ assumeUninitialized =
1186
+ flowContainer.kind === 178 /* SyntaxKind.Constructor */ &&
1187
+ flowContainer.parent === declaration.parent &&
1188
+ (declaration.flags & 8388608 /* NodeFlags.Ambient */) === 0;
1189
+ }
1155
1190
  }
1156
- }
1157
- // A JavaScript `this.x = …` declaration is unassigned before it in its own function.
1158
- if (c.strictNullChecks && prop !== undefined && !assumeUninitialized) {
1159
- const declaration = prop.valueDeclaration;
1160
- assumeUninitialized =
1161
- declaration instanceof BinaryExpression &&
1162
- declaration.left.kind === 212 /* SyntaxKind.PropertyAccessExpression */ &&
1163
- getControlFlowContainer(node) === getControlFlowContainer(declaration);
1191
+ else
1192
+ assumeUninitialized =
1193
+ declaration instanceof BinaryExpression &&
1194
+ declaration.left.kind === 213 /* SyntaxKind.PropertyAccessExpression */ &&
1195
+ getControlFlowContainer(node) === getControlFlowContainer(declaration);
1164
1196
  }
1165
1197
  const initialType = assumeUninitialized ? getOptionalType(c, propType, false) : propType;
1166
1198
  const flowType = getFlowTypeOfReference(c, node, propType, initialType, undefined);
1167
1199
  if (assumeUninitialized && !containsUndefinedType(propType) && containsUndefinedType(flowType)) {
1168
- c.error(errorNode, 719 /* Diagnostics.Property_0_is_used_before_being_assigned */, symbolToString(c, prop));
1200
+ c.error(errorNode, 726 /* Diagnostics.Property_0_is_used_before_being_assigned */, symbolToString(c, prop));
1169
1201
  return propType;
1170
1202
  }
1171
1203
  return assignmentKind !== 0 /* AssignmentKind.None */ ? getBaseTypeOfLiteralType(c, flowType) : flowType;
1172
1204
  }
1173
1205
  function isPropertyWithoutInitializer(node) {
1174
- return (node.kind === 173 /* SyntaxKind.PropertyDeclaration */ &&
1206
+ return (node.kind === 174 /* SyntaxKind.PropertyDeclaration */ &&
1175
1207
  !hasSyntacticModifier(node, 64 /* ModifierFlags.Abstract */) &&
1176
1208
  node.postfixToken === undefined &&
1177
1209
  getInitializer(node) === undefined);
@@ -1194,7 +1226,7 @@ function checkElementAccessExpression(c, node, _checkMode) {
1194
1226
  const isAssignment = assignmentKind !== 0 /* AssignmentKind.None */;
1195
1227
  const objectType = isAssignment || isMethodAccessForCall(node) ? getWidenedType(c, exprType) : exprType;
1196
1228
  if (isConstEnumObjectTypeLocal(objectType) && !isStringLiteralLike(indexExpression)) {
1197
- c.error(indexExpression, 640 /* Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal */);
1229
+ c.error(indexExpression, 647 /* Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal */);
1198
1230
  return c.errorType;
1199
1231
  }
1200
1232
  const effectiveIndexType = isForInVariableForNumericPropertyNames(c, indexExpression) ? c.numberType : indexType;
@@ -1214,18 +1246,14 @@ export function checkIndexedAccessIndexType(c, t, accessNode) {
1214
1246
  return t;
1215
1247
  const objectType = t.objectType;
1216
1248
  const indexType = t.indexType;
1217
- // Remapping mapped types don't defer their index types.
1218
- const objectIndexType = isGenericMappedType(c, objectType) &&
1219
- getMappedTypeNameTypeKind(c, objectType) === 2 /* MappedTypeNameTypeKind.Remapping */
1220
- ? getIndexForMappedType(c, objectType, 0 /* IndexFlags.None */)
1221
- : getIndexTypeEx(c, objectType, 0 /* IndexFlags.None */);
1222
1249
  const hasNumberIndexInfo = getIndexInfoOfType(c, objectType, c.numberType) !== undefined;
1223
- if (everyType(indexType, (u) => isTypeAssignableTo(c, u, objectIndexType) || (hasNumberIndexInfo && isApplicableIndexType(c, u, c.numberType)))) {
1224
- if (accessNode.kind === 213 /* SyntaxKind.ElementAccessExpression */ &&
1250
+ if (everyType(indexType, (u) => isTypeAssignableTo(c, u, getIndexTypeEx(c, objectType, 0 /* IndexFlags.None */)) ||
1251
+ (hasNumberIndexInfo && isApplicableIndexType(c, u, c.numberType)))) {
1252
+ if (accessNode.kind === 214 /* SyntaxKind.ElementAccessExpression */ &&
1225
1253
  isAssignmentTarget(accessNode) &&
1226
1254
  (objectType.objectFlags & 32 /* ObjectFlags.Mapped */) !== 0 &&
1227
1255
  (getMappedTypeModifiers(objectType) & 1 /* MappedTypeModifiers.IncludeReadonly */) !== 0)
1228
- c.error(accessNode, 698 /* Diagnostics.Index_signature_in_type_0_only_permits_reading */, typeToString(c, objectType));
1256
+ c.error(accessNode, 705 /* Diagnostics.Index_signature_in_type_0_only_permits_reading */, typeToString(c, objectType));
1229
1257
  return t;
1230
1258
  }
1231
1259
  if (isGenericObjectType(c, objectType)) {
@@ -1236,12 +1264,12 @@ export function checkIndexedAccessIndexType(c, t, accessNode) {
1236
1264
  (getDeclarationModifierFlagsFromSymbol(c, propertySymbol, false) &
1237
1265
  6 /* ModifierFlags.NonPublicAccessibilityModifier */) !==
1238
1266
  0) {
1239
- c.error(accessNode, 1091 /* Diagnostics.Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter */, propertyName);
1267
+ c.error(accessNode, 1098 /* Diagnostics.Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter */, propertyName);
1240
1268
  return c.errorType;
1241
1269
  }
1242
1270
  }
1243
1271
  }
1244
- c.error(accessNode, 693 /* Diagnostics.Type_0_cannot_be_used_to_index_type_1 */, typeToString(c, indexType), typeToString(c, objectType));
1272
+ c.error(accessNode, 700 /* Diagnostics.Type_0_cannot_be_used_to_index_type_1 */, typeToString(c, indexType), typeToString(c, objectType));
1245
1273
  return c.errorType;
1246
1274
  }
1247
1275
  function getConstituentProperty(c, objectType, propertyName) {
@@ -1275,7 +1303,7 @@ function isForInVariableForNumericPropertyNames(c, expr) {
1275
1303
  let child = expr;
1276
1304
  let node = expr.parent;
1277
1305
  while (node !== undefined) {
1278
- if (node.kind === 250 /* SyntaxKind.ForInStatement */) {
1306
+ if (node.kind === 251 /* SyntaxKind.ForInStatement */) {
1279
1307
  const statement = node;
1280
1308
  if (child === statement.statement &&
1281
1309
  getForInVariableSymbol(c, statement) === symbol &&
@@ -1289,7 +1317,7 @@ function isForInVariableForNumericPropertyNames(c, expr) {
1289
1317
  }
1290
1318
  function getForInVariableSymbol(c, node) {
1291
1319
  const initializer = node.initializer;
1292
- if (initializer.kind === 262 /* SyntaxKind.VariableDeclarationList */) {
1320
+ if (initializer.kind === 263 /* SyntaxKind.VariableDeclarationList */) {
1293
1321
  const declarations = initializer.declarations.nodes;
1294
1322
  return declarations.length > 0 ? getSymbolOfDeclaration(c, declarations[0]) : undefined;
1295
1323
  }
@@ -1300,21 +1328,26 @@ function hasNumericPropertyNames(c, t) {
1300
1328
  }
1301
1329
  // ---- Assertions
1302
1330
  function checkAssertion(c, node, checkMode) {
1331
+ if (node.kind === 218 /* SyntaxKind.TypeAssertionExpression */) {
1332
+ const file = getSourceFileOfNode(node);
1333
+ if (fileExtensionIsOneOf(file.fileName, ['.mts', '.cts']))
1334
+ grammarErrorOnNode(c, node, 1749 /* Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead */);
1335
+ }
1303
1336
  // `<T>expr`, over `<T>`.
1304
- if (node.kind === 217 /* SyntaxKind.TypeAssertionExpression */ && shouldCheckErasableSyntax(c, node)) {
1337
+ if (node.kind === 218 /* SyntaxKind.TypeAssertionExpression */ && shouldCheckErasableSyntax(c, node)) {
1305
1338
  const file = getSourceFileOfNode(node);
1306
1339
  c.addDiagnostic(new Diagnostic(file.diagnosticFile(), skipTrivia(file.text, node.pos), getExpression(node).pos, 243 /* Diagnostics.This_syntax_is_not_allowed_when_erasableSyntaxOnly_is_enabled */, []));
1307
1340
  }
1341
+ const exprType = checkExpressionEx(c, getExpression(node), checkMode);
1342
+ // The type node is checked in every case, including the `const` of `x as const`.
1343
+ checkTypeNodeIfPresent(c, getType(node));
1308
1344
  if (isConstTypeReference(getType(node))) {
1309
- const exprType = checkExpressionEx(c, getExpression(node), checkMode);
1310
1345
  if (!isValidConstAssertionArgument(c, getExpression(node)))
1311
1346
  c.error(getExpression(node), 289 /* Diagnostics.A_const_assertion_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array_or_object_literals */);
1312
1347
  return getRegularTypeOfLiteralType(c, exprType);
1313
1348
  }
1314
- const exprType = checkExpressionEx(c, getExpression(node), checkMode);
1315
1349
  // The operand is compared with the asserted type once, after the last check of the operand.
1316
1350
  c.nodeLinks(node).assertionExpressionType = exprType;
1317
- checkTypeNodeIfPresent(c, getType(node));
1318
1351
  checkNodeDeferred(c, node);
1319
1352
  return getTypeFromTypeNode(c, getType(node));
1320
1353
  }
@@ -1332,7 +1365,7 @@ function checkAssertionCompatibility(c, node, rawExprType, targetType) {
1332
1365
  if (isErrorType(c, targetType))
1333
1366
  return;
1334
1367
  if (!isTypeComparableTo(c, targetType, getWidenedType(c, exprType)))
1335
- checkTypeComparableTo(c, exprType, targetType, node, 528 /* Diagnostics.Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the_other_If_this_was_intentional_convert_the_expression_to_unknown_first */);
1368
+ checkTypeComparableTo(c, exprType, targetType, node, 535 /* Diagnostics.Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the_other_If_this_was_intentional_convert_the_expression_to_unknown_first */);
1336
1369
  }
1337
1370
  function checkSatisfiesExpression(c, node, checkMode) {
1338
1371
  const expr = getExpression(node);