tsc-ts 0.0.5 → 0.0.7

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 (203) hide show
  1. package/README.md +1 -1
  2. package/dist/api/compiler/ast.d.ts +67 -27
  3. package/dist/api/compiler/ast.js +156 -55
  4. package/dist/api/compiler/binder-utilities.js +4 -3
  5. package/dist/api/compiler/binder.js +14 -13
  6. package/dist/api/compiler/checker-calls.js +7 -6
  7. package/dist/api/compiler/checker-contextual.js +1 -1
  8. package/dist/api/compiler/checker-declaration-order.js +2 -1
  9. package/dist/api/compiler/checker-declarations.js +14 -14
  10. package/dist/api/compiler/checker-declared-types.d.ts +1 -1
  11. package/dist/api/compiler/checker-declared-types.js +12 -11
  12. package/dist/api/compiler/checker-decorators.js +3 -3
  13. package/dist/api/compiler/checker-deprecation.js +17 -18
  14. package/dist/api/compiler/checker-destructuring.d.ts +1 -1
  15. package/dist/api/compiler/checker-destructuring.js +3 -3
  16. package/dist/api/compiler/checker-elaboration.js +8 -7
  17. package/dist/api/compiler/checker-emit-helpers.d.ts +2 -1
  18. package/dist/api/compiler/checker-emit-helpers.js +5 -4
  19. package/dist/api/compiler/checker-emit-resolver.d.ts +1 -1
  20. package/dist/api/compiler/checker-emit-resolver.js +5 -4
  21. package/dist/api/compiler/checker-grammar.js +23 -9
  22. package/dist/api/compiler/checker-heritage.d.ts +1 -1
  23. package/dist/api/compiler/checker-heritage.js +14 -13
  24. package/dist/api/compiler/checker-inference.d.ts +21 -11
  25. package/dist/api/compiler/checker-inference.js +57 -34
  26. package/dist/api/compiler/checker-javascript.d.ts +1 -1
  27. package/dist/api/compiler/checker-javascript.js +5 -4
  28. package/dist/api/compiler/checker-jsx.d.ts +1 -1
  29. package/dist/api/compiler/checker-jsx.js +4 -4
  30. package/dist/api/compiler/checker-literals.js +2 -2
  31. package/dist/api/compiler/checker-members.d.ts +32 -3
  32. package/dist/api/compiler/checker-members.js +240 -53
  33. package/dist/api/compiler/checker-modules.d.ts +15 -1
  34. package/dist/api/compiler/checker-modules.js +86 -14
  35. package/dist/api/compiler/checker-object-literals.d.ts +1 -1
  36. package/dist/api/compiler/checker-object-literals.js +11 -7
  37. package/dist/api/compiler/checker-overloads.d.ts +1 -1
  38. package/dist/api/compiler/checker-overloads.js +4 -3
  39. package/dist/api/compiler/checker-property-access.d.ts +1 -1
  40. package/dist/api/compiler/checker-property-access.js +2 -2
  41. package/dist/api/compiler/checker-services.js +2 -2
  42. package/dist/api/compiler/checker-signatures.d.ts +1 -1
  43. package/dist/api/compiler/checker-signatures.js +9 -8
  44. package/dist/api/compiler/checker-symbol-types.d.ts +2 -18
  45. package/dist/api/compiler/checker-symbol-types.js +22 -952
  46. package/dist/api/compiler/checker-symbols.d.ts +2 -2
  47. package/dist/api/compiler/checker-symbols.js +29 -27
  48. package/dist/api/compiler/checker-type-factory.d.ts +2 -2
  49. package/dist/api/compiler/checker-type-factory.js +57 -16
  50. package/dist/api/compiler/checker-type-nodes.d.ts +1 -1
  51. package/dist/api/compiler/checker-type-nodes.js +2 -2
  52. package/dist/api/compiler/checker-type-operators.d.ts +1 -1
  53. package/dist/api/compiler/checker-type-operators.js +5 -5
  54. package/dist/api/compiler/checker-types.d.ts +73 -7
  55. package/dist/api/compiler/checker-types.js +220 -43
  56. package/dist/api/compiler/checker-unused.d.ts +1 -1
  57. package/dist/api/compiler/checker-unused.js +3 -3
  58. package/dist/api/compiler/checker.d.ts +45 -8
  59. package/dist/api/compiler/checker.js +46 -9
  60. package/dist/api/compiler/diagnostics.d.ts +2 -8
  61. package/dist/api/compiler/diagnostics.js +13 -45
  62. package/dist/api/compiler/file-include.d.ts +35 -8
  63. package/dist/api/compiler/file-include.js +81 -18
  64. package/dist/api/compiler/file-loader.d.ts +33 -4
  65. package/dist/api/compiler/file-loader.js +90 -24
  66. package/dist/api/compiler/instantiation.d.ts +1 -1
  67. package/dist/api/compiler/instantiation.js +86 -50
  68. package/dist/api/compiler/link-tables.d.ts +69 -0
  69. package/dist/api/compiler/link-tables.js +236 -0
  70. package/dist/api/compiler/name-resolver.js +3 -3
  71. package/dist/api/compiler/node-builder-names.d.ts +1 -1
  72. package/dist/api/compiler/node-builder-names.js +12 -12
  73. package/dist/api/compiler/node-builder-pseudo.d.ts +1 -1
  74. package/dist/api/compiler/node-builder-pseudo.js +2 -1
  75. package/dist/api/compiler/node-builder.d.ts +1 -1
  76. package/dist/api/compiler/node-builder.js +16 -16
  77. package/dist/api/compiler/parallel-parse.d.ts +2 -0
  78. package/dist/api/compiler/parallel-parse.js +7 -1
  79. package/dist/api/compiler/parser.d.ts +33 -16
  80. package/dist/api/compiler/parser.js +127 -98
  81. package/dist/api/compiler/printer/emit-context.d.ts +5 -2
  82. package/dist/api/compiler/printer/emit-context.js +19 -13
  83. package/dist/api/compiler/printer/factory-base.js +8 -8
  84. package/dist/api/compiler/printer/factory.js +4 -4
  85. package/dist/api/compiler/printer/printer.js +6 -6
  86. package/dist/api/compiler/program-checker.d.ts +5 -0
  87. package/dist/api/compiler/program-checker.js +14 -1
  88. package/dist/api/compiler/program.js +9 -1
  89. package/dist/api/compiler/relations.d.ts +1 -1
  90. package/dist/api/compiler/relations.js +18 -13
  91. package/dist/api/compiler/reparser.js +13 -5
  92. package/dist/api/compiler/symbol-accessibility.d.ts +1 -1
  93. package/dist/api/compiler/symbol-accessibility.js +123 -26
  94. package/dist/api/compiler/symbol.d.ts +45 -3
  95. package/dist/api/compiler/symbol.js +121 -10
  96. package/dist/api/compiler/transformers/alias-references.d.ts +1 -1
  97. package/dist/api/compiler/transformers/alias-references.js +2 -1
  98. package/dist/api/compiler/transformers/class-fields.js +3 -3
  99. package/dist/api/compiler/transformers/commonjs-module.js +3 -3
  100. package/dist/api/compiler/transformers/declarations-diagnostics.js +2 -1
  101. package/dist/api/compiler/transformers/declarations-pseudo.js +6 -4
  102. package/dist/api/compiler/transformers/declarations-syntactic.d.ts +1 -1
  103. package/dist/api/compiler/transformers/declarations-syntactic.js +9 -9
  104. package/dist/api/compiler/transformers/declarations-tracker.d.ts +1 -1
  105. package/dist/api/compiler/transformers/declarations-tracker.js +3 -2
  106. package/dist/api/compiler/transformers/declarations.js +6 -5
  107. package/dist/api/compiler/transformers/module.js +2 -2
  108. package/dist/api/compiler/transformers/optional-chain.js +3 -3
  109. package/dist/api/compiler/transformers/reference-resolver.d.ts +2 -1
  110. package/dist/api/compiler/transformers/reference-resolver.js +26 -24
  111. package/dist/api/compiler/transformers/subtree-facts.d.ts +1 -0
  112. package/dist/api/compiler/transformers/subtree-facts.js +9 -7
  113. package/dist/api/compiler/transformers/syntax-facts.d.ts +1 -0
  114. package/dist/api/compiler/transformers/syntax-facts.js +9 -5
  115. package/dist/api/compiler/transformers/tagged-template.js +2 -2
  116. package/dist/api/compiler/transformers/type-eraser.js +2 -2
  117. package/dist/api/compiler/transformers/type-serialization.js +12 -12
  118. package/dist/api/compiler/transformers/visitor-base.js +3 -3
  119. package/dist/api/compiler/tsconfig.js +2 -2
  120. package/package.json +9 -9
  121. package/src/compiler/ast.ts +211 -78
  122. package/src/compiler/binder-utilities.ts +4 -3
  123. package/src/compiler/binder.ts +26 -16
  124. package/src/compiler/checker-calls.ts +8 -6
  125. package/src/compiler/checker-contextual.ts +1 -1
  126. package/src/compiler/checker-declaration-order.ts +2 -2
  127. package/src/compiler/checker-declarations.ts +21 -14
  128. package/src/compiler/checker-declared-types.ts +12 -12
  129. package/src/compiler/checker-decorators.ts +3 -3
  130. package/src/compiler/checker-deprecation.ts +17 -21
  131. package/src/compiler/checker-destructuring.ts +3 -3
  132. package/src/compiler/checker-elaboration.ts +8 -8
  133. package/src/compiler/checker-emit-helpers.ts +5 -4
  134. package/src/compiler/checker-emit-resolver.ts +5 -5
  135. package/src/compiler/checker-grammar.ts +22 -8
  136. package/src/compiler/checker-heritage.ts +21 -14
  137. package/src/compiler/checker-inference.ts +66 -34
  138. package/src/compiler/checker-javascript.ts +5 -5
  139. package/src/compiler/checker-jsx.ts +12 -8
  140. package/src/compiler/checker-literals.ts +2 -2
  141. package/src/compiler/checker-members.ts +255 -47
  142. package/src/compiler/checker-modules.ts +115 -14
  143. package/src/compiler/checker-object-literals.ts +22 -6
  144. package/src/compiler/checker-overloads.ts +6 -6
  145. package/src/compiler/checker-property-access.ts +2 -2
  146. package/src/compiler/checker-services.ts +2 -2
  147. package/src/compiler/checker-signatures.ts +9 -9
  148. package/src/compiler/checker-symbol-types.ts +20 -940
  149. package/src/compiler/checker-symbols.ts +42 -35
  150. package/src/compiler/checker-type-factory.ts +53 -16
  151. package/src/compiler/checker-type-nodes.ts +2 -2
  152. package/src/compiler/checker-type-operators.ts +13 -5
  153. package/src/compiler/checker-types.ts +223 -43
  154. package/src/compiler/checker-unused.ts +3 -3
  155. package/src/compiler/checker.ts +50 -9
  156. package/src/compiler/decoder.ts +5 -4
  157. package/src/compiler/diagnostics.ts +14 -48
  158. package/src/compiler/encoder.ts +10 -5
  159. package/src/compiler/file-include.ts +85 -17
  160. package/src/compiler/file-loader.ts +104 -35
  161. package/src/compiler/incremental.ts +39 -5
  162. package/src/compiler/instantiation.ts +99 -55
  163. package/src/compiler/link-tables.ts +245 -0
  164. package/src/compiler/name-resolver.ts +3 -3
  165. package/src/compiler/node-builder-names.ts +21 -19
  166. package/src/compiler/node-builder-pseudo.ts +2 -2
  167. package/src/compiler/node-builder.ts +24 -16
  168. package/src/compiler/parallel-check.ts +11 -8
  169. package/src/compiler/parallel-parse.ts +8 -1
  170. package/src/compiler/parse-thread.ts +0 -4
  171. package/src/compiler/parser.ts +173 -93
  172. package/src/compiler/printer/emit-context.ts +20 -15
  173. package/src/compiler/printer/factory-base.ts +14 -7
  174. package/src/compiler/printer/factory.ts +5 -3
  175. package/src/compiler/printer/printer.ts +8 -6
  176. package/src/compiler/program-checker.ts +12 -1
  177. package/src/compiler/program.ts +8 -1
  178. package/src/compiler/relations.ts +20 -12
  179. package/src/compiler/reparser.ts +14 -4
  180. package/src/compiler/symbol-accessibility.ts +120 -25
  181. package/src/compiler/symbol.ts +127 -9
  182. package/src/compiler/transformers/alias-references.ts +2 -2
  183. package/src/compiler/transformers/class-fields.ts +12 -2
  184. package/src/compiler/transformers/commonjs-module.ts +3 -2
  185. package/src/compiler/transformers/declarations-diagnostics.ts +2 -1
  186. package/src/compiler/transformers/declarations-pseudo.ts +9 -5
  187. package/src/compiler/transformers/declarations-syntactic.ts +17 -9
  188. package/src/compiler/transformers/declarations-tracker.ts +3 -3
  189. package/src/compiler/transformers/declarations.ts +7 -7
  190. package/src/compiler/transformers/module.ts +2 -1
  191. package/src/compiler/transformers/optional-chain.ts +5 -2
  192. package/src/compiler/transformers/reference-resolver.ts +37 -25
  193. package/src/compiler/transformers/subtree-facts.ts +15 -6
  194. package/src/compiler/transformers/syntax-facts.ts +10 -5
  195. package/src/compiler/transformers/tagged-template.ts +2 -2
  196. package/src/compiler/transformers/type-eraser.ts +2 -1
  197. package/src/compiler/transformers/type-serialization.ts +12 -12
  198. package/src/compiler/transformers/visitor-base.ts +10 -5
  199. package/src/compiler/tsc-build.ts +17 -13
  200. package/src/compiler/tsc-cli.ts +9 -6
  201. package/src/compiler/tsc-compile.ts +16 -7
  202. package/src/compiler/tsc-watch.ts +94 -26
  203. package/src/compiler/tsconfig.ts +2 -1
@@ -4,6 +4,7 @@
4
4
  // Fields of `instanceof`-narrowed nodes are read through `as` casts: scriptc reads them
5
5
  // statically, but reads fields of a narrowed value dynamically.
6
6
  import {
7
+ appendToList,
7
8
  BinaryExpression,
8
9
  BindingElement,
9
10
  CallExpression,
@@ -41,6 +42,7 @@ import {
41
42
  PrefixUnaryExpression,
42
43
  PropertyAccessExpression,
43
44
  QualifiedName,
45
+ ReferenceIdentifier,
44
46
  type SourceFile,
45
47
  SwitchStatement,
46
48
  TryStatement,
@@ -71,6 +73,8 @@ import {
71
73
  setNextContainer,
72
74
  setReturnFlowNode,
73
75
  setSymbol,
76
+ callQuestionDotToken,
77
+ callTypeArguments,
74
78
  } from './ast.js';
75
79
  import {
76
80
  isAmbientModule,
@@ -150,18 +154,21 @@ import { Diagnostic, type DiagnosticMessage, Diagnostics } from './diagnostics.j
150
154
  import { FlowFlags, FlowNode, FlowReduceLabel, FlowSwitchClause } from './flow.js';
151
155
  import { removeFileExtension } from './path.js';
152
156
  import { getIdentifierToken, tokenToString } from './scanner.js';
157
+ import { SyntaxKind } from './syntax-kind.js';
153
158
  import {
154
- InternalSymbolName,
155
- Symbol,
156
- SymbolFlags,
157
- type SymbolTable,
158
159
  addDeclaration,
160
+ copyDeclarations,
161
+ declarationCount,
162
+ getDeclarations,
159
163
  getExports,
160
164
  getMembers,
161
165
  getSymbolId,
166
+ InternalSymbolName,
162
167
  internalSymbolNamePrefix,
168
+ Symbol,
169
+ SymbolFlags,
170
+ type SymbolTable,
163
171
  } from './symbol.js';
164
- import { SyntaxKind } from './syntax-kind.js';
165
172
 
166
173
  /** How a node scopes declarations and control flow. */
167
174
  export const enum ContainerFlags {
@@ -518,7 +525,7 @@ class Binder extends NodeVisitor {
518
525
  messageNeedsName = false;
519
526
  }
520
527
  let multipleDefaultExports = false;
521
- if (symbol.declarations.length !== 0) {
528
+ if (declarationCount(symbol) !== 0) {
522
529
  // A default export (by modifier, or `export default` assignment) after another one.
523
530
  if (isDefaultExport || (node instanceof ExportAssignment && !(node as ExportAssignment).isExportEquals)) {
524
531
  message = Diagnostics.A_module_cannot_have_multiple_default_exports;
@@ -545,7 +552,7 @@ class Binder extends NodeVisitor {
545
552
  ]),
546
553
  );
547
554
  }
548
- const declarations = symbol.declarations;
555
+ const declarations = getDeclarations(symbol);
549
556
  for (let index = 0; index < declarations.length; index++) {
550
557
  const declaration = declarations[index]!;
551
558
  const decl = getNameOfDeclaration(declaration) ?? declaration;
@@ -742,7 +749,7 @@ class Binder extends NodeVisitor {
742
749
  addDeclarationToSymbol(symbol: Symbol, node: Node, symbolFlags: SymbolFlags): void {
743
750
  symbol.flags |= symbolFlags;
744
751
  setSymbol(node, symbol);
745
- if (symbol.declarations.indexOf(node) < 0) addDeclaration(symbol, node);
752
+ if (getDeclarations(symbol).indexOf(node) < 0) addDeclaration(symbol, node);
746
753
  // A const-enum-only namespace merged with a class, function or regular enum isn't one anymore.
747
754
  if (
748
755
  (symbol.flags & SymbolFlags.ConstEnumOnlyModule) !== 0 &&
@@ -791,7 +798,7 @@ class Binder extends NodeVisitor {
791
798
  }
792
799
 
793
800
  addDiagnostic(diagnostic: Diagnostic): void {
794
- this.file.bindDiagnostics.push(diagnostic);
801
+ this.file.bindDiagnostics = appendToList(this.file.bindDiagnostics, diagnostic);
795
802
  }
796
803
 
797
804
  // Traversal
@@ -805,7 +812,7 @@ class Binder extends NodeVisitor {
805
812
  // the container's locals; anonymous declarations like type literals go in no table.
806
813
  switch (node.kind) {
807
814
  case SyntaxKind.Identifier:
808
- (node as Identifier).flowNode = this.currentFlowValue();
815
+ if (node instanceof ReferenceIdentifier) node.flowNode = this.currentFlowValue();
809
816
  this.checkContextualIdentifier(node as Identifier);
810
817
  break;
811
818
  case SyntaxKind.ThisKeyword:
@@ -1153,7 +1160,7 @@ class Binder extends NodeVisitor {
1153
1160
  symbol.valueDeclaration = this.file;
1154
1161
  if (name === 'module') {
1155
1162
  const exportsProperty = this.newSymbol(SymbolFlags.ModuleExports | SymbolFlags.Property, 'exports');
1156
- exportsProperty.declarations = symbol.declarations;
1163
+ copyDeclarations(exportsProperty, symbol);
1157
1164
  exportsProperty.valueDeclaration = this.file;
1158
1165
  exportsProperty.parent = symbol;
1159
1166
  getMembers(symbol).set('exports', exportsProperty);
@@ -1881,8 +1888,8 @@ class Binder extends NodeVisitor {
1881
1888
  this.bindOptional((node as ElementAccessExpression).questionDotToken);
1882
1889
  this.bind((node as ElementAccessExpression).argumentExpression);
1883
1890
  } else if (node instanceof CallExpression) {
1884
- this.bindOptional((node as CallExpression).questionDotToken);
1885
- this.bindNodes((node as CallExpression).typeArguments);
1891
+ this.bindOptional(callQuestionDotToken(node as CallExpression));
1892
+ this.bindNodes(callTypeArguments(node as CallExpression));
1886
1893
  this.bindNodes((node as CallExpression).arguments);
1887
1894
  }
1888
1895
  }
@@ -1893,7 +1900,7 @@ class Binder extends NodeVisitor {
1893
1900
  // An IIFE's flow node includes the evaluation of its arguments.
1894
1901
  const callee = skipParentheses(node.expression);
1895
1902
  if (callee.kind === SyntaxKind.FunctionExpression || callee.kind === SyntaxKind.ArrowFunction) {
1896
- this.bindNodes(node.typeArguments);
1903
+ this.bindNodes(callTypeArguments(node));
1897
1904
  this.bindNodes(node.arguments);
1898
1905
  this.bind(node.expression);
1899
1906
  } else {
@@ -1969,7 +1976,10 @@ class Binder extends NodeVisitor {
1969
1976
  if (starIndex >= 0 && text.indexOf('*', starIndex + 1) >= 0)
1970
1977
  this.errorOnFirstToken(name, Diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, [text]);
1971
1978
  else if (starIndex >= 0)
1972
- this.file.patternAmbientModules.push(new PatternAmbientModule(text, starIndex, symbol));
1979
+ this.file.patternAmbientModules = appendToList(
1980
+ this.file.patternAmbientModules,
1981
+ new PatternAmbientModule(text, starIndex, symbol),
1982
+ );
1973
1983
  }
1974
1984
  return;
1975
1985
  }
@@ -2096,7 +2106,7 @@ class Binder extends NodeVisitor {
2096
2106
  const exports = getExports(symbol);
2097
2107
  const existing = exports.get('prototype');
2098
2108
  if (existing !== undefined)
2099
- this.errorOnNode(existing.declarations[0]!, Diagnostics.Duplicate_identifier_0, ['prototype']);
2109
+ this.errorOnNode(existing.declaration!, Diagnostics.Duplicate_identifier_0, ['prototype']);
2100
2110
  exports.set('prototype', prototypeSymbol);
2101
2111
  prototypeSymbol.parent = symbol;
2102
2112
  }
@@ -25,6 +25,8 @@ import {
25
25
  getNodeId,
26
26
  getBody,
27
27
  getSymbol,
28
+ callQuestionDotToken,
29
+ callTypeArguments,
28
30
  } from './ast.js';
29
31
  import {
30
32
  canHaveDecorators,
@@ -46,7 +48,6 @@ import { Diagnostic, type DiagnosticMessage, Diagnostics, chainDiagnostic } from
46
48
  import { resolveInstanceofExpression } from './checker-operators.js';
47
49
  import { skipTrivia } from './scanner.js';
48
50
  import { SyntaxKind } from './syntax-kind.js';
49
- import { InternalSymbolName, type Symbol, SymbolFlags } from './symbol.js';
50
51
  import { TokenFlags } from './types.js';
51
52
  import { type Checker, createDiagnosticForNode } from './checker.js';
52
53
  import { checkSuperExpression } from './checker-super.js';
@@ -206,6 +207,7 @@ import {
206
207
  resolveJsxOpeningLikeElement,
207
208
  } from './checker-jsx.js';
208
209
  import { isCommonJSRequire, resolveExternalModuleTypeByLiteral } from './checker-javascript.js';
210
+ import { declarationCount, getDeclarations, InternalSymbolName, type Symbol, SymbolFlags } from './symbol.js';
209
211
 
210
212
  /** The type of an optional chain's expression with the chain's `undefined` removed. */
211
213
  export function getOptionalExpressionType(c: Checker, exprType: Type, expression: Node): Type {
@@ -238,7 +240,7 @@ export function checkCallExpression(c: Checker, node: Node, checkMode: CheckMode
238
240
  return getESSymbolLikeTypeForNode(c, walkUpParenthesizedExpressions(node.parent!));
239
241
  // An assertion call must name its target through explicitly typed declarations.
240
242
  if (
241
- call.questionDotToken === undefined &&
243
+ callQuestionDotToken(call) === undefined &&
242
244
  node.parent!.kind === SyntaxKind.ExpressionStatement &&
243
245
  (returnType.flags & TypeFlags.Void) !== 0 &&
244
246
  getTypePredicateOfSignature(c, signature) !== undefined
@@ -368,7 +370,7 @@ function resolveCallExpression(c: Checker, node: CallExpression, checkMode: Chec
368
370
  const callSignatures = getSignaturesOfType(c, apparentType, SignatureKind.Call);
369
371
  const numConstructSignatures = getSignaturesOfType(c, apparentType, SignatureKind.Construct).length;
370
372
  if (isUntypedFunctionCall(c, funcType, apparentType, callSignatures.length, numConstructSignatures)) {
371
- if (!isErrorType(c, funcType) && node.typeArguments !== undefined)
373
+ if (!isErrorType(c, funcType) && callTypeArguments(node) !== undefined)
372
374
  c.error(node, Diagnostics.Untyped_function_calls_may_not_accept_type_arguments);
373
375
  return resolveUntypedCall(c, node);
374
376
  }
@@ -382,7 +384,7 @@ function resolveCallExpression(c: Checker, node: CallExpression, checkMode: Chec
382
384
  // inferences can flow through function composition.
383
385
  if (
384
386
  (checkMode & CheckMode.SkipGenericFunctions) !== 0 &&
385
- node.typeArguments === undefined &&
387
+ callTypeArguments(node) === undefined &&
386
388
  someGenericFunctionReturningFunction(c, callSignatures)
387
389
  ) {
388
390
  skippedGenericFunction(c, node, checkMode);
@@ -1674,9 +1676,9 @@ function addImplementationSuccessElaboration(
1674
1676
  diagnostic: Diagnostic,
1675
1677
  ): void {
1676
1678
  const symbol = failed.declaration !== undefined ? getSymbol(failed.declaration) : undefined;
1677
- if (symbol === undefined || symbol.declarations.length <= 1) return;
1679
+ if (symbol === undefined || declarationCount(symbol) <= 1) return;
1678
1680
  let implementation: Node | undefined;
1679
- for (const d of symbol.declarations) {
1681
+ for (const d of getDeclarations(symbol)) {
1680
1682
  if (isFunctionLikeDeclarationKind(d.kind) && nodeIsPresent(getBody(d))) {
1681
1683
  implementation = d;
1682
1684
  break;
@@ -277,7 +277,7 @@ export function checkExpressionWithContextualType(
277
277
  checkMode | CheckMode.Contextual | (inferenceContext !== undefined ? CheckMode.Inferential : 0),
278
278
  );
279
279
  // Intra-expression inference sites only matter during this check.
280
- if (inferenceContext !== undefined) inferenceContext.intraExpressionInferenceSites = [];
280
+ if (inferenceContext !== undefined) inferenceContext.intraExpressionInferenceSites = undefined;
281
281
  // Contextually typed literals keep their literal types rather than widening during inference.
282
282
  if (
283
283
  maybeTypeOfKind(t, TypeFlags.Literal) &&
@@ -29,7 +29,6 @@ import { isFunctionLike } from './ast-utilities.js';
29
29
  import { type Checker, createDiagnosticForNode } from './checker.js';
30
30
  import { type Diagnostic, Diagnostics } from './diagnostics.js';
31
31
  import { ScriptTarget } from './options.js';
32
- import { type Symbol, SymbolFlags } from './symbol.js';
33
32
  import { getSymbolOfDeclaration } from './checker-symbols.js';
34
33
  import { getTypeOfSymbol } from './checker-symbol-types.js';
35
34
  import { isPropertyInitializedInStaticBlocks } from './checker-classes.js';
@@ -38,6 +37,7 @@ import { getExportSymbolOfValueSymbolIfExported } from './checker-symbols.js';
38
37
  import { getBaseTypes, getDeclaredTypeOfSymbol } from './checker-declared-types.js';
39
38
  import { getPropertyOfType } from './checker-members.js';
40
39
  import { FunctionFlags, getFunctionFlags } from './checker-utilities.js';
40
+ import { getDeclarations, type Symbol, SymbolFlags } from './symbol.js';
41
41
 
42
42
  /** Reports a block-scoped variable, class or enum resolved at `errorLocation` before its declaration. */
43
43
  export function checkResolvedBlockScopedVariable(c: Checker, resolved: Symbol, errorLocation: Node): void {
@@ -50,7 +50,7 @@ export function checkResolvedBlockScopedVariable(c: Checker, resolved: Symbol, e
50
50
  )
51
51
  return;
52
52
  let declaration: Node | undefined;
53
- for (const d of result.declarations) {
53
+ for (const d of getDeclarations(result)) {
54
54
  if (isBlockOrCatchScoped(d) || isClassLike(d) || d.kind === SyntaxKind.EnumDeclaration) {
55
55
  declaration = d;
56
56
  break;
@@ -62,7 +62,6 @@ import {
62
62
  isClassLike,
63
63
  } from './binder-utilities.js';
64
64
  import { Diagnostic, type DiagnosticMessage, Diagnostics } from './diagnostics.js';
65
- import { InternalSymbolName, type Symbol, SymbolFlags, getSymbolId } from './symbol.js';
66
65
  import { SyntaxKind } from './syntax-kind.js';
67
66
  import { type Checker, createDiagnosticForNode } from './checker.js';
68
67
  import { IntrinsicTypeKind, getLiteralTypeFromPropertyName, intrinsicTypeKind } from './checker-type-operators.js';
@@ -142,6 +141,14 @@ import { checkFunctionOrMethodSymbols } from './checker-overloads.js';
142
141
  import { checkJSDocFullSignature } from './checker-jsdoc.js';
143
142
  import { checkAliasSymbol } from './checker-modules.js';
144
143
  import { checkDecorators } from './checker-decorators.js';
144
+ import {
145
+ declarationCount,
146
+ getDeclarations,
147
+ getSymbolId,
148
+ InternalSymbolName,
149
+ type Symbol,
150
+ SymbolFlags,
151
+ } from './symbol.js';
145
152
 
146
153
  // ---- Variables and parameters
147
154
 
@@ -250,8 +257,8 @@ export function checkVariableLikeDeclaration(c: Checker, node: Node): void {
250
257
  checkTypeAssignableToAndOptionallyElaborate(c, initType, t, node, initializer);
251
258
  checkUsingDeclarationInitializer(c, node, initializer, initType);
252
259
  }
253
- if (name !== undefined && symbol.declarations.length > 1) {
254
- for (const d of symbol.declarations) {
260
+ if (name !== undefined && declarationCount(symbol) > 1) {
261
+ for (const d of getDeclarations(symbol)) {
255
262
  if (d !== node && isVariableLike(d) && !areDeclarationFlagsIdentical(d, node)) {
256
263
  reportNonIdenticalModifiers(c, name);
257
264
  break;
@@ -786,15 +793,15 @@ export function checkEnumDeclaration(c: Checker, node: Node): void {
786
793
  const links = c.symbolLinks(symbol);
787
794
  if (links.enumChecked) return;
788
795
  links.enumChecked = true;
789
- if (symbol.declarations.length > 1) {
796
+ if (declarationCount(symbol) > 1) {
790
797
  const enumIsConst = isEnumConst(node);
791
- for (const d of symbol.declarations)
798
+ for (const d of getDeclarations(symbol))
792
799
  if (d.kind === SyntaxKind.EnumDeclaration && isEnumConst(d) !== enumIsConst)
793
800
  c.error(getNameOfDeclaration(d), Diagnostics.Enum_declarations_must_all_be_const_or_non_const);
794
801
  }
795
802
  // Only one declaration of a merged enum may continue automatic numbering from zero.
796
803
  let seenEnumMissingInitialInitializer = false;
797
- for (const d of symbol.declarations) {
804
+ for (const d of getDeclarations(symbol)) {
798
805
  if (d.kind !== SyntaxKind.EnumDeclaration) continue;
799
806
  const members = (d as EnumDeclaration).members.nodes;
800
807
  if (members.length === 0 || getInitializer(members[0]!) !== undefined) continue;
@@ -851,7 +858,7 @@ export function checkModuleDeclaration(c: Checker, node: Node): void {
851
858
  Diagnostics.Namespaces_are_not_allowed_in_global_script_files_when_0_is_enabled_If_this_file_is_not_intended_to_be_a_global_script_set_moduleDetection_to_force_or_add_an_empty_export_statement,
852
859
  c.compilerOptions.verbatimModuleSyntax === true ? 'verbatimModuleSyntax' : 'isolatedModules',
853
860
  );
854
- if (symbol.declarations.length > 1) {
861
+ if (declarationCount(symbol) > 1) {
855
862
  const classOrFunction = getFirstNonAmbientClassOrFunctionDeclaration(symbol);
856
863
  if (classOrFunction !== undefined) {
857
864
  if (getSourceFileOfNode(node) !== getSourceFileOfNode(classOrFunction))
@@ -907,7 +914,7 @@ export function isInstantiatedModule(node: Node, preserveConstEnums: boolean): b
907
914
  }
908
915
 
909
916
  function getFirstNonAmbientClassOrFunctionDeclaration(symbol: Symbol): Node | undefined {
910
- for (const d of symbol.declarations)
917
+ for (const d of getDeclarations(symbol))
911
918
  if (
912
919
  (d.kind === SyntaxKind.ClassDeclaration ||
913
920
  (d.kind === SyntaxKind.FunctionDeclaration && nodeIsPresent(getBody(d)))) &&
@@ -995,16 +1002,16 @@ export function checkExternalModuleExports(c: Checker, node: Node): void {
995
1002
  if (id === InternalSymbolName.ExportStar || (symbol.flags & (SymbolFlags.Namespace | SymbolFlags.Enum)) !== 0)
996
1003
  continue;
997
1004
  let count = 0;
998
- for (const d of symbol.declarations)
1005
+ for (const d of getDeclarations(symbol))
999
1006
  if (isNotOverload(d) && !isAccessorDeclaration(d) && d.kind !== SyntaxKind.InterfaceDeclaration) count++;
1000
1007
  // A type alias may merge with one value.
1001
1008
  if ((symbol.flags & SymbolFlags.TypeAlias) !== 0 && count <= 2) continue;
1002
1009
  if (count <= 1) continue;
1003
1010
  let allExportsProperties = true;
1004
- for (const d of symbol.declarations)
1011
+ for (const d of getDeclarations(symbol))
1005
1012
  if (getAssignmentDeclarationKind(d) !== JSDeclarationKind.ExportsProperty) allExportsProperties = false;
1006
1013
  if (allExportsProperties) continue;
1007
- for (const d of symbol.declarations)
1014
+ for (const d of getDeclarations(symbol))
1008
1015
  if (isNotOverload(d)) c.error(d, Diagnostics.Cannot_redeclare_exported_variable_0, id);
1009
1016
  }
1010
1017
  }
@@ -1063,7 +1070,7 @@ export function checkExportsOnMergedDeclarations(c: Checker, node: Node): void {
1063
1070
  let exported = DeclarationSpaces.None;
1064
1071
  let nonExported = DeclarationSpaces.None;
1065
1072
  let defaultExported = DeclarationSpaces.None;
1066
- for (const d of symbol.declarations) {
1073
+ for (const d of getDeclarations(symbol)) {
1067
1074
  const spaces = getDeclarationSpaces(c, d);
1068
1075
  const flags = getEffectiveDeclarationFlags(d, ModifierFlags.Export | ModifierFlags.Default);
1069
1076
  if ((flags & ModifierFlags.Export) !== 0) {
@@ -1075,7 +1082,7 @@ export function checkExportsOnMergedDeclarations(c: Checker, node: Node): void {
1075
1082
  const commonForExportsAndLocals = exported & nonExported;
1076
1083
  const commonForDefaultAndNonDefault = defaultExported & nonDefaultExported;
1077
1084
  if (commonForExportsAndLocals === 0 && commonForDefaultAndNonDefault === 0) return;
1078
- for (const d of symbol.declarations) {
1085
+ for (const d of getDeclarations(symbol)) {
1079
1086
  const spaces = getDeclarationSpaces(c, d);
1080
1087
  const name = getNameOfDeclaration(d);
1081
1088
  const text = declarationNameToString(getSourceFileOfNode(d), name);
@@ -1136,7 +1143,7 @@ function getAliasDeclarationSpaces(c: Checker, node: Node): DeclarationSpaces {
1136
1143
  const symbol = getSymbolOfDeclaration(c, node);
1137
1144
  if (symbol === undefined) return DeclarationSpaces.None;
1138
1145
  let result = DeclarationSpaces.None;
1139
- for (const d of resolveAlias(c, symbol).declarations) result |= getDeclarationSpaces(c, d);
1146
+ for (const d of getDeclarations(resolveAlias(c, symbol))) result |= getDeclarationSpaces(c, d);
1140
1147
  return result;
1141
1148
  }
1142
1149
 
@@ -21,7 +21,6 @@ import {
21
21
  } from './ast.js';
22
22
  import { getSourceFileOfNode, isEnumConst, isObjectLiteralMethod } from './binder-utilities.js';
23
23
  import { Diagnostics } from './diagnostics.js';
24
- import { type Symbol, SymbolFlags } from './symbol.js';
25
24
  import { SyntaxKind } from './syntax-kind.js';
26
25
  import { type Checker, createDiagnosticForNode } from './checker.js';
27
26
  import { elaborateNeverIntersection } from './checker-property-access.js';
@@ -88,6 +87,7 @@ import { getIndexedAccessType, isGenericMappedType } from './checker-type-operat
88
87
  import { getSignatureInstantiation } from './checker-signatures.js';
89
88
  import { evaluateEnumMember, EvaluatedFlags, EvaluatedKind } from './checker-evaluator.js';
90
89
  import { checkTypeAssignableTo, isTypeIdenticalTo } from './relations.js';
90
+ import { getDeclarations, type Symbol, SymbolFlags } from './symbol.js';
91
91
 
92
92
  export { getParentOfSymbol };
93
93
 
@@ -153,7 +153,7 @@ export function getDeclaredTypeOfClassOrInterface(c: Checker, symbol: Symbol): I
153
153
  }
154
154
 
155
155
  function isThislessInterface(c: Checker, symbol: Symbol): boolean {
156
- for (const declaration of symbol.declarations) {
156
+ for (const declaration of getDeclarations(symbol)) {
157
157
  if (declaration.kind !== SyntaxKind.InterfaceDeclaration) continue;
158
158
  if ((declaration.flags & NodeFlags.ContainsThis) !== 0) return false;
159
159
  for (const node of getExtendsHeritageClauseElements(declaration)) {
@@ -201,7 +201,7 @@ export function getExtendsHeritageClauseElement(node: Node): Node | undefined {
201
201
  }
202
202
 
203
203
  export function getClassLikeDeclarationOfSymbol(symbol: Symbol): Node | undefined {
204
- for (const d of symbol.declarations)
204
+ for (const d of getDeclarations(symbol))
205
205
  if (d.kind === SyntaxKind.ClassDeclaration || d.kind === SyntaxKind.ClassExpression) return d;
206
206
  return undefined;
207
207
  }
@@ -210,7 +210,7 @@ function getOuterTypeParametersOfClassOrInterface(c: Checker, symbol: Symbol): T
210
210
  let declaration = symbol.valueDeclaration;
211
211
  if ((symbol.flags & (SymbolFlags.Class | SymbolFlags.Function)) === 0) {
212
212
  declaration = undefined;
213
- for (const d of symbol.declarations) {
213
+ for (const d of getDeclarations(symbol)) {
214
214
  if (d.kind === SyntaxKind.InterfaceDeclaration) {
215
215
  declaration = d;
216
216
  break;
@@ -310,7 +310,7 @@ export function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(c: Checker,
310
310
  }
311
311
 
312
312
  function appendLocalTypeParameters(c: Checker, types: Type[], symbol: Symbol): Type[] {
313
- for (const node of symbol.declarations) {
313
+ for (const node of getDeclarations(symbol)) {
314
314
  if (
315
315
  node.kind === SyntaxKind.InterfaceDeclaration ||
316
316
  node.kind === SyntaxKind.ClassDeclaration ||
@@ -343,7 +343,7 @@ export function getDeclaredTypeOfTypeAlias(c: Checker, symbol: Symbol): Type {
343
343
  if (links.declaredType !== undefined) return links.declaredType;
344
344
  if (!pushTypeResolution(c, symbol, TypeSystemPropertyName.DeclaredType)) return c.errorType;
345
345
  let declaration: Node | undefined;
346
- for (const d of symbol.declarations)
346
+ for (const d of getDeclarations(symbol))
347
347
  if (d.kind === SyntaxKind.TypeAliasDeclaration || d.kind === SyntaxKind.JSTypeAliasDeclaration) {
348
348
  declaration = d;
349
349
  break;
@@ -374,7 +374,7 @@ export function getDeclaredTypeOfEnum(c: Checker, symbol: Symbol): Type {
374
374
  const links = c.symbolLinks(symbol);
375
375
  if (links.declaredType !== undefined) return links.declaredType;
376
376
  const memberTypes: Type[] = [];
377
- for (const declaration of symbol.declarations) {
377
+ for (const declaration of getDeclarations(symbol)) {
378
378
  if (declaration.kind !== SyntaxKind.EnumDeclaration) continue;
379
379
  for (const member of (declaration as EnumDeclaration).members.nodes) {
380
380
  if (!hasBindableName(member)) continue;
@@ -561,7 +561,7 @@ export function getBaseTypes(c: Checker, t: Type): Type[] {
561
561
  if ((t.symbol!.flags & SymbolFlags.Interface) !== 0) resolveBaseTypesOfInterface(c, t as InterfaceType);
562
562
  }
563
563
  if (!popTypeResolution(c))
564
- for (const declaration of t.symbol!.declarations)
564
+ for (const declaration of getDeclarations(t.symbol!))
565
565
  if (declaration.kind === SyntaxKind.ClassDeclaration || declaration.kind === SyntaxKind.InterfaceDeclaration)
566
566
  reportCircularBaseType(c, declaration, t);
567
567
  // Circular defaults may leave members partially resolved; reset them.
@@ -659,7 +659,7 @@ function isInJS(node: Node): boolean {
659
659
  }
660
660
 
661
661
  function resolveBaseTypesOfInterface(c: Checker, t: InterfaceType): void {
662
- for (const declaration of t.symbol!.declarations) {
662
+ for (const declaration of getDeclarations(t.symbol!)) {
663
663
  if (declaration.kind !== SyntaxKind.InterfaceDeclaration) continue;
664
664
  for (const node of getExtendsHeritageClauseElements(declaration)) {
665
665
  const baseType = getReducedType(c, getTypeFromTypeNode(c, node));
@@ -798,7 +798,7 @@ export function hasNonCircularBaseConstraint(c: Checker, t: Type): boolean {
798
798
 
799
799
  export function getConstraintDeclaration(t: Type): Node | undefined {
800
800
  if (t.symbol !== undefined)
801
- for (const d of t.symbol.declarations)
801
+ for (const d of getDeclarations(t.symbol))
802
802
  if (d.kind === SyntaxKind.TypeParameter) {
803
803
  const constraint = (d as TypeParameterDeclaration).constraint;
804
804
  if (constraint !== undefined) return constraint;
@@ -850,7 +850,7 @@ export function getResolvedTypeParameterDefault(c: Checker, t: TypeParameter): T
850
850
  side.resolvedDefaultType = c.resolvingDefaultType;
851
851
  let defaultType: Type = c.noConstraintType;
852
852
  if (t.symbol !== undefined)
853
- for (const d of t.symbol.declarations)
853
+ for (const d of getDeclarations(t.symbol))
854
854
  if (d.kind === SyntaxKind.TypeParameter) {
855
855
  const node = (d as TypeParameterDeclaration).defaultType;
856
856
  if (node !== undefined) {
@@ -878,7 +878,7 @@ export function getMinTypeArgumentCount(c: Checker, typeParameters: readonly Typ
878
878
  /** Whether a type parameter is declared with a default, without resolving it. */
879
879
  function hasTypeParameterDefault(t: Type): boolean {
880
880
  if (t.symbol === undefined) return false;
881
- for (const d of t.symbol.declarations)
881
+ for (const d of getDeclarations(t.symbol))
882
882
  if (d.kind === SyntaxKind.TypeParameter && (d as TypeParameterDeclaration).defaultType !== undefined) return true;
883
883
  return false;
884
884
  }
@@ -37,7 +37,6 @@ import {
37
37
  isAutoAccessorPropertyDeclaration,
38
38
  } from './binder-utilities.js';
39
39
  import { type DiagnosticMessage, Diagnostics } from './diagnostics.js';
40
- import { type Symbol, SymbolFlags, getSymbolId } from './symbol.js';
41
40
  import { SyntaxKind } from './syntax-kind.js';
42
41
  import { type Checker, createDiagnosticForNode } from './checker.js';
43
42
  import { ModuleKind, getEmitModuleKind, ScriptTarget, getUseDefineForClassFields } from './options.js';
@@ -89,6 +88,7 @@ import {
89
88
  getGlobalClassSetterDecoratorContextType,
90
89
  getGlobalTypedPropertyDescriptorType,
91
90
  } from './checker-globals.js';
91
+ import { getDeclarations, getSymbolId, type Symbol, SymbolFlags } from './symbol.js';
92
92
 
93
93
  // ---- Checks
94
94
 
@@ -230,12 +230,12 @@ function checkMetadataTypeImport(c: Checker, typeNode: Node | undefined): void {
230
230
  (typeName.kind === SyntaxKind.Identifier ? SymbolFlags.Type : SymbolFlags.Namespace) | SymbolFlags.Alias;
231
231
  const rootSymbol = resolveName(c, rootName, getText(rootName), meaning, undefined, true, false);
232
232
  if (rootSymbol === undefined || (rootSymbol.flags & SymbolFlags.Alias) === 0 || symbolIsValue(c, rootSymbol)) return;
233
- if (rootSymbol.declarations.some(isTypeOnlyImportOrExportDeclaration)) return;
233
+ if (getDeclarations(rootSymbol).some(isTypeOnlyImportOrExportDeclaration)) return;
234
234
  const diagnostic = c.error(
235
235
  typeName,
236
236
  Diagnostics.A_type_referenced_in_a_decorated_signature_must_be_imported_with_import_type_or_a_namespace_import_when_isolatedModules_and_emitDecoratorMetadata_are_enabled,
237
237
  );
238
- const aliasDeclaration = rootSymbol.declarations.find(isAliasSymbolDeclaration);
238
+ const aliasDeclaration = getDeclarations(rootSymbol).find(isAliasSymbolDeclaration);
239
239
  if (aliasDeclaration !== undefined)
240
240
  diagnostic.addRelatedInfo(
241
241
  createDiagnosticForNode(aliasDeclaration, Diagnostics.X_0_was_imported_here, [getText(rootName)]),
@@ -24,7 +24,6 @@ import { type Checker, createDiagnosticForNode } from './checker.js';
24
24
  import { type Signature, SignatureFlags, type Type } from './checker-types.js';
25
25
  import { type Diagnostic, Diagnostics } from './diagnostics.js';
26
26
  import { getJSDoc } from './parser.js';
27
- import { type Symbol, SymbolFlags } from './symbol.js';
28
27
  import { SyntaxKind } from './syntax-kind.js';
29
28
  import { getDeclarationOfAliasSymbol, getParentOfSymbol, resolveAlias } from './checker-symbols.js';
30
29
  import { getTargetOfAliasDeclaration } from './checker-modules.js';
@@ -33,6 +32,7 @@ import { entityNameToString } from './checker-expressions.js';
33
32
  import { isErrorType } from './checker-type-factory.js';
34
33
  import { getPropertyOfType } from './checker-members.js';
35
34
  import { signatureToString } from './type-printer.js';
35
+ import { declarationCount, getDeclarations, type Symbol, SymbolFlags } from './symbol.js';
36
36
 
37
37
  /** Whether `declaration`, or the statement it belongs to, has a `@deprecated` JSDoc tag. */
38
38
  export function isDeprecatedDeclaration(declaration: Node): boolean {
@@ -56,7 +56,7 @@ function getJSDocDeprecatedTag(node: Node): Node | undefined {
56
56
  * members when all are.
57
57
  */
58
58
  export function isDeprecatedSymbol(c: Checker, symbol: Symbol): boolean {
59
- const declarations = symbol.declarations;
59
+ const declarations = getDeclarations(symbol);
60
60
  const parentSymbol = getParentOfSymbol(c, symbol);
61
61
  if (parentSymbol !== undefined && declarations.length > 1)
62
62
  return (parentSymbol.flags & SymbolFlags.Interface) !== 0
@@ -208,7 +208,7 @@ function isUncalledFunctionReference(c: Checker, node: Node, symbol: Symbol): bo
208
208
  node.kind === SyntaxKind.Identifier &&
209
209
  hasMatchingArgument(c, parent, node)
210
210
  );
211
- for (const d of symbol.declarations) if (isFunctionLikeKind(d.kind) && !isDeprecatedDeclaration(d)) return false;
211
+ for (const d of getDeclarations(symbol)) if (isFunctionLikeKind(d.kind) && !isDeprecatedDeclaration(d)) return false;
212
212
  return true;
213
213
  }
214
214
 
@@ -263,9 +263,9 @@ export function resolveAliasWithDeprecationCheck(c: Checker, symbol: Symbol, loc
263
263
  while ((current.flags & SymbolFlags.Alias) !== 0) {
264
264
  const target = getImmediateAliasedSymbol(c, current);
265
265
  if (target === undefined || target === targetSymbol) break;
266
- if (target.declarations.length !== 0) {
266
+ if (declarationCount(target) !== 0) {
267
267
  if (isDeprecatedSymbol(c, target)) {
268
- addDeprecatedSuggestion(c, location, target.declarations, target.name);
268
+ addDeprecatedSuggestion(c, location, getDeclarations(target), target.name);
269
269
  break;
270
270
  }
271
271
  if (current === targetSymbol) break;
@@ -288,11 +288,11 @@ function getImmediateAliasedSymbol(c: Checker, symbol: Symbol): Symbol | undefin
288
288
  export function checkDeprecatedIdentifier(c: Checker, node: Node, localOrExportSymbol: Symbol): void {
289
289
  const targetSymbol = resolveAliasWithDeprecationCheck(c, localOrExportSymbol, node);
290
290
  if (
291
- targetSymbol.declarations.length !== 0 &&
291
+ declarationCount(targetSymbol) !== 0 &&
292
292
  isDeprecatedSymbol(c, targetSymbol) &&
293
293
  isUncalledFunctionReference(c, node, targetSymbol)
294
294
  )
295
- addDeprecatedSuggestion(c, node, targetSymbol.declarations, getText(node));
295
+ addDeprecatedSuggestion(c, node, getDeclarations(targetSymbol), getText(node));
296
296
  }
297
297
 
298
298
  /** Reports a property access to a deprecated property. */
@@ -301,9 +301,9 @@ export function checkDeprecatedProperty(c: Checker, node: Node, right: Node, pro
301
301
  if (
302
302
  isDeprecatedSymbol(c, targetPropSymbol) &&
303
303
  isUncalledFunctionReference(c, node, targetPropSymbol) &&
304
- targetPropSymbol.declarations.length !== 0
304
+ declarationCount(targetPropSymbol) !== 0
305
305
  )
306
- addDeprecatedSuggestion(c, right, targetPropSymbol.declarations, getText(right));
306
+ addDeprecatedSuggestion(c, right, getDeclarations(targetPropSymbol), getText(right));
307
307
  }
308
308
 
309
309
  /** Reports a property access resolved through a deprecated index signature. */
@@ -314,11 +314,7 @@ export function checkDeprecatedIndexSignature(c: Checker, right: Node, declarati
314
314
 
315
315
  /** Reports an element access or indexed access type selecting a deprecated property. */
316
316
  export function checkDeprecatedIndexedAccess(c: Checker, accessNode: Node, prop: Symbol, propName: string): void {
317
- if (
318
- prop.declarations.length === 0 ||
319
- !isDeprecatedSymbol(c, prop) ||
320
- !isUncalledFunctionReference(c, accessNode, prop)
321
- )
317
+ if (declarationCount(prop) === 0 || !isDeprecatedSymbol(c, prop) || !isUncalledFunctionReference(c, accessNode, prop))
322
318
  return;
323
319
  const deprecatedNode =
324
320
  accessNode.kind === SyntaxKind.ElementAccessExpression
@@ -326,7 +322,7 @@ export function checkDeprecatedIndexedAccess(c: Checker, accessNode: Node, prop:
326
322
  : accessNode.kind === SyntaxKind.IndexedAccessType
327
323
  ? (accessNode as IndexedAccessTypeNode).indexType
328
324
  : accessNode;
329
- addDeprecatedSuggestion(c, deprecatedNode, prop.declarations, propName);
325
+ addDeprecatedSuggestion(c, deprecatedNode, getDeclarations(prop), propName);
330
326
  }
331
327
 
332
328
  /** Reports a type reference or import type naming a deprecated type. */
@@ -334,9 +330,9 @@ export function checkDeprecatedTypeReference(c: Checker, node: Node, type: Type)
334
330
  if (isErrorType(c, type)) return;
335
331
  const symbol = c.resolvedSymbols.get(node.id);
336
332
  if (symbol === undefined) return;
337
- for (const d of symbol.declarations) {
333
+ for (const d of getDeclarations(symbol)) {
338
334
  if (isTypeDeclaration(d) && isDeprecatedDeclaration(d)) {
339
- addDeprecatedSuggestion(c, getDeprecatedSuggestionNode(node), symbol.declarations, symbol.name);
335
+ addDeprecatedSuggestion(c, getDeprecatedSuggestionNode(node), getDeclarations(symbol), symbol.name);
340
336
  return;
341
337
  }
342
338
  }
@@ -345,8 +341,8 @@ export function checkDeprecatedTypeReference(c: Checker, node: Node, type: Type)
345
341
  /** Reports an import specifier importing a deprecated declaration. */
346
342
  export function checkDeprecatedImportSpecifier(c: Checker, node: Node, symbol: Symbol): void {
347
343
  const targetSymbol = resolveAliasWithDeprecationCheck(c, symbol, node);
348
- if (isDeprecatedSymbol(c, targetSymbol) && targetSymbol.declarations.length !== 0)
349
- addDeprecatedSuggestion(c, node, targetSymbol.declarations, targetSymbol.name);
344
+ if (isDeprecatedSymbol(c, targetSymbol) && declarationCount(targetSymbol) !== 0)
345
+ addDeprecatedSuggestion(c, node, getDeclarations(targetSymbol), targetSymbol.name);
350
346
  }
351
347
 
352
348
  /** Reports a JSX attribute setting a deprecated property of the element's contextual props type. */
@@ -354,6 +350,6 @@ export function checkDeprecatedJsxAttribute(c: Checker, contextualType: Type, at
354
350
  const name = attribute.name;
355
351
  if (name.kind !== SyntaxKind.Identifier) return;
356
352
  const prop = getPropertyOfType(c, contextualType, getText(name));
357
- if (prop !== undefined && prop.declarations.length !== 0 && isDeprecatedSymbol(c, prop))
358
- addDeprecatedSuggestion(c, name, prop.declarations, getText(name));
353
+ if (prop !== undefined && declarationCount(prop) !== 0 && isDeprecatedSymbol(c, prop))
354
+ addDeprecatedSuggestion(c, name, getDeclarations(prop), getText(name));
359
355
  }
@@ -33,7 +33,6 @@ import {
33
33
  isPrivateIdentifierClassElementDeclaration,
34
34
  } from './binder-utilities.js';
35
35
  import { Diagnostics } from './diagnostics.js';
36
- import { CheckFlags, SymbolFlags, type Symbol, getSymbolId } from './symbol.js';
37
36
  import { SyntaxKind } from './syntax-kind.js';
38
37
  import type { Checker } from './checker.js';
39
38
  import {
@@ -116,6 +115,7 @@ import { TypeFacts, getNonNullableType, getTypeWithFacts, hasTypeFacts } from '.
116
115
  import { sliceTupleType } from './checker-signatures.js';
117
116
  import { getPropertyNameFromType, isTypeUsableAsPropertyName, maybeTypeOfKind } from './checker-utilities.js';
118
117
  import { checkPropertyAccessibility } from './checker-property-access.js';
118
+ import { CheckFlags, copyDeclarations, getDeclarations, getSymbolId, type Symbol, SymbolFlags } from './symbol.js';
119
119
 
120
120
  function isBindingPatternNode(node: Node | undefined): boolean {
121
121
  return (
@@ -766,7 +766,7 @@ export function isSpreadableProperty(prop: Symbol): boolean {
766
766
  (prop.flags & (SymbolFlags.Method | SymbolFlags.GetAccessor | SymbolFlags.SetAccessor)) === 0;
767
767
  let hasPrivateName = false;
768
768
  let inClass = false;
769
- for (const d of prop.declarations) {
769
+ for (const d of getDeclarations(prop)) {
770
770
  if (isPrivateIdentifierClassElementDeclaration(d)) hasPrivateName = true;
771
771
  if (d.parent !== undefined && isClassLike(d.parent)) inClass = true;
772
772
  }
@@ -785,7 +785,7 @@ export function getSpreadSymbol(c: Checker, prop: Symbol, readonly: boolean): Sy
785
785
  );
786
786
  const id = getSymbolId(result);
787
787
  c.symbolTypes.set(id, isSetonlyAccessor ? c.undefinedType : getTypeOfSymbol(c, prop));
788
- result.declarations = prop.declarations;
788
+ copyDeclarations(result, prop);
789
789
  c.symbolNameTypes.set(id, c.symbolNameTypes.get(getSymbolId(prop)));
790
790
  c.symbolSyntheticOrigins.set(id, prop);
791
791
  return result;