tsc-ts 0.0.5 → 0.0.6

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 (171) hide show
  1. package/README.md +1 -1
  2. package/dist/api/compiler/ast.d.ts +10 -9
  3. package/dist/api/compiler/ast.js +22 -16
  4. package/dist/api/compiler/binder-utilities.js +2 -1
  5. package/dist/api/compiler/binder.js +9 -8
  6. package/dist/api/compiler/checker-calls.js +3 -2
  7. package/dist/api/compiler/checker-declaration-order.js +2 -1
  8. package/dist/api/compiler/checker-declarations.js +14 -14
  9. package/dist/api/compiler/checker-declared-types.d.ts +1 -1
  10. package/dist/api/compiler/checker-declared-types.js +12 -11
  11. package/dist/api/compiler/checker-decorators.js +3 -3
  12. package/dist/api/compiler/checker-deprecation.js +17 -18
  13. package/dist/api/compiler/checker-destructuring.d.ts +1 -1
  14. package/dist/api/compiler/checker-destructuring.js +3 -3
  15. package/dist/api/compiler/checker-elaboration.js +8 -7
  16. package/dist/api/compiler/checker-emit-resolver.d.ts +1 -1
  17. package/dist/api/compiler/checker-emit-resolver.js +5 -4
  18. package/dist/api/compiler/checker-grammar.js +18 -4
  19. package/dist/api/compiler/checker-heritage.d.ts +1 -1
  20. package/dist/api/compiler/checker-heritage.js +14 -13
  21. package/dist/api/compiler/checker-inference.d.ts +1 -1
  22. package/dist/api/compiler/checker-inference.js +9 -9
  23. package/dist/api/compiler/checker-javascript.d.ts +1 -1
  24. package/dist/api/compiler/checker-javascript.js +5 -4
  25. package/dist/api/compiler/checker-jsx.d.ts +1 -1
  26. package/dist/api/compiler/checker-jsx.js +4 -4
  27. package/dist/api/compiler/checker-literals.js +2 -2
  28. package/dist/api/compiler/checker-members.d.ts +5 -3
  29. package/dist/api/compiler/checker-members.js +75 -53
  30. package/dist/api/compiler/checker-modules.d.ts +1 -1
  31. package/dist/api/compiler/checker-modules.js +13 -13
  32. package/dist/api/compiler/checker-object-literals.d.ts +1 -1
  33. package/dist/api/compiler/checker-object-literals.js +11 -7
  34. package/dist/api/compiler/checker-overloads.d.ts +1 -1
  35. package/dist/api/compiler/checker-overloads.js +4 -3
  36. package/dist/api/compiler/checker-property-access.d.ts +1 -1
  37. package/dist/api/compiler/checker-property-access.js +2 -2
  38. package/dist/api/compiler/checker-services.js +2 -2
  39. package/dist/api/compiler/checker-signatures.d.ts +1 -1
  40. package/dist/api/compiler/checker-signatures.js +9 -8
  41. package/dist/api/compiler/checker-symbol-types.d.ts +2 -18
  42. package/dist/api/compiler/checker-symbol-types.js +22 -952
  43. package/dist/api/compiler/checker-symbols.d.ts +2 -2
  44. package/dist/api/compiler/checker-symbols.js +29 -27
  45. package/dist/api/compiler/checker-type-factory.d.ts +2 -2
  46. package/dist/api/compiler/checker-type-factory.js +57 -16
  47. package/dist/api/compiler/checker-type-nodes.d.ts +1 -1
  48. package/dist/api/compiler/checker-type-nodes.js +2 -2
  49. package/dist/api/compiler/checker-type-operators.d.ts +1 -1
  50. package/dist/api/compiler/checker-type-operators.js +5 -5
  51. package/dist/api/compiler/checker-types.d.ts +73 -7
  52. package/dist/api/compiler/checker-types.js +220 -43
  53. package/dist/api/compiler/checker-unused.d.ts +1 -1
  54. package/dist/api/compiler/checker-unused.js +3 -3
  55. package/dist/api/compiler/checker.d.ts +29 -8
  56. package/dist/api/compiler/checker.js +29 -9
  57. package/dist/api/compiler/diagnostics.d.ts +2 -8
  58. package/dist/api/compiler/diagnostics.js +4 -40
  59. package/dist/api/compiler/file-include.d.ts +35 -8
  60. package/dist/api/compiler/file-include.js +81 -18
  61. package/dist/api/compiler/file-loader.d.ts +33 -4
  62. package/dist/api/compiler/file-loader.js +90 -24
  63. package/dist/api/compiler/instantiation.d.ts +1 -1
  64. package/dist/api/compiler/instantiation.js +86 -50
  65. package/dist/api/compiler/link-tables.d.ts +69 -0
  66. package/dist/api/compiler/link-tables.js +236 -0
  67. package/dist/api/compiler/name-resolver.js +3 -3
  68. package/dist/api/compiler/node-builder-names.d.ts +1 -1
  69. package/dist/api/compiler/node-builder-names.js +12 -12
  70. package/dist/api/compiler/node-builder-pseudo.d.ts +1 -1
  71. package/dist/api/compiler/node-builder-pseudo.js +2 -1
  72. package/dist/api/compiler/node-builder.d.ts +1 -1
  73. package/dist/api/compiler/node-builder.js +16 -16
  74. package/dist/api/compiler/parallel-parse.d.ts +2 -0
  75. package/dist/api/compiler/parallel-parse.js +4 -0
  76. package/dist/api/compiler/parser.d.ts +33 -16
  77. package/dist/api/compiler/parser.js +95 -76
  78. package/dist/api/compiler/printer/emit-context.d.ts +5 -2
  79. package/dist/api/compiler/printer/emit-context.js +19 -13
  80. package/dist/api/compiler/program-checker.js +3 -0
  81. package/dist/api/compiler/program.js +9 -1
  82. package/dist/api/compiler/relations.d.ts +1 -1
  83. package/dist/api/compiler/relations.js +10 -10
  84. package/dist/api/compiler/symbol-accessibility.d.ts +1 -1
  85. package/dist/api/compiler/symbol-accessibility.js +123 -26
  86. package/dist/api/compiler/symbol.d.ts +45 -3
  87. package/dist/api/compiler/symbol.js +121 -10
  88. package/dist/api/compiler/transformers/alias-references.d.ts +1 -1
  89. package/dist/api/compiler/transformers/alias-references.js +2 -1
  90. package/dist/api/compiler/transformers/declarations-diagnostics.js +2 -1
  91. package/dist/api/compiler/transformers/declarations-pseudo.js +4 -2
  92. package/dist/api/compiler/transformers/declarations-syntactic.d.ts +1 -1
  93. package/dist/api/compiler/transformers/declarations-syntactic.js +9 -9
  94. package/dist/api/compiler/transformers/declarations-tracker.d.ts +1 -1
  95. package/dist/api/compiler/transformers/declarations-tracker.js +3 -2
  96. package/dist/api/compiler/transformers/declarations.js +6 -5
  97. package/dist/api/compiler/transformers/reference-resolver.d.ts +2 -1
  98. package/dist/api/compiler/transformers/reference-resolver.js +26 -24
  99. package/dist/api/compiler/transformers/subtree-facts.d.ts +1 -0
  100. package/dist/api/compiler/transformers/subtree-facts.js +7 -5
  101. package/dist/api/compiler/transformers/syntax-facts.d.ts +1 -0
  102. package/dist/api/compiler/transformers/syntax-facts.js +9 -5
  103. package/dist/api/compiler/transformers/type-serialization.js +12 -12
  104. package/package.json +9 -9
  105. package/src/compiler/ast.ts +27 -19
  106. package/src/compiler/binder-utilities.ts +2 -2
  107. package/src/compiler/binder.ts +15 -11
  108. package/src/compiler/checker-calls.ts +3 -3
  109. package/src/compiler/checker-declaration-order.ts +2 -2
  110. package/src/compiler/checker-declarations.ts +21 -14
  111. package/src/compiler/checker-declared-types.ts +12 -12
  112. package/src/compiler/checker-decorators.ts +3 -3
  113. package/src/compiler/checker-deprecation.ts +17 -21
  114. package/src/compiler/checker-destructuring.ts +3 -3
  115. package/src/compiler/checker-elaboration.ts +8 -8
  116. package/src/compiler/checker-emit-resolver.ts +5 -5
  117. package/src/compiler/checker-grammar.ts +17 -5
  118. package/src/compiler/checker-heritage.ts +21 -14
  119. package/src/compiler/checker-inference.ts +17 -9
  120. package/src/compiler/checker-javascript.ts +5 -5
  121. package/src/compiler/checker-jsx.ts +12 -8
  122. package/src/compiler/checker-literals.ts +2 -2
  123. package/src/compiler/checker-members.ts +91 -47
  124. package/src/compiler/checker-modules.ts +23 -13
  125. package/src/compiler/checker-object-literals.ts +22 -6
  126. package/src/compiler/checker-overloads.ts +6 -6
  127. package/src/compiler/checker-property-access.ts +2 -2
  128. package/src/compiler/checker-services.ts +2 -2
  129. package/src/compiler/checker-signatures.ts +9 -9
  130. package/src/compiler/checker-symbol-types.ts +20 -940
  131. package/src/compiler/checker-symbols.ts +42 -35
  132. package/src/compiler/checker-type-factory.ts +53 -16
  133. package/src/compiler/checker-type-nodes.ts +2 -2
  134. package/src/compiler/checker-type-operators.ts +13 -5
  135. package/src/compiler/checker-types.ts +223 -43
  136. package/src/compiler/checker-unused.ts +3 -3
  137. package/src/compiler/checker.ts +31 -9
  138. package/src/compiler/diagnostics.ts +5 -44
  139. package/src/compiler/file-include.ts +85 -17
  140. package/src/compiler/file-loader.ts +104 -35
  141. package/src/compiler/incremental.ts +39 -5
  142. package/src/compiler/instantiation.ts +99 -55
  143. package/src/compiler/link-tables.ts +245 -0
  144. package/src/compiler/name-resolver.ts +3 -3
  145. package/src/compiler/node-builder-names.ts +21 -19
  146. package/src/compiler/node-builder-pseudo.ts +2 -2
  147. package/src/compiler/node-builder.ts +24 -16
  148. package/src/compiler/parallel-check.ts +11 -8
  149. package/src/compiler/parallel-parse.ts +5 -0
  150. package/src/compiler/parse-thread.ts +0 -4
  151. package/src/compiler/parser.ts +120 -70
  152. package/src/compiler/printer/emit-context.ts +20 -15
  153. package/src/compiler/program-checker.ts +2 -0
  154. package/src/compiler/program.ts +8 -1
  155. package/src/compiler/relations.ts +10 -10
  156. package/src/compiler/symbol-accessibility.ts +120 -25
  157. package/src/compiler/symbol.ts +127 -9
  158. package/src/compiler/transformers/alias-references.ts +2 -2
  159. package/src/compiler/transformers/declarations-diagnostics.ts +2 -1
  160. package/src/compiler/transformers/declarations-pseudo.ts +7 -4
  161. package/src/compiler/transformers/declarations-syntactic.ts +17 -9
  162. package/src/compiler/transformers/declarations-tracker.ts +3 -3
  163. package/src/compiler/transformers/declarations.ts +6 -6
  164. package/src/compiler/transformers/reference-resolver.ts +37 -25
  165. package/src/compiler/transformers/subtree-facts.ts +13 -5
  166. package/src/compiler/transformers/syntax-facts.ts +10 -5
  167. package/src/compiler/transformers/type-serialization.ts +12 -12
  168. package/src/compiler/tsc-build.ts +17 -13
  169. package/src/compiler/tsc-cli.ts +9 -6
  170. package/src/compiler/tsc-compile.ts +16 -7
  171. package/src/compiler/tsc-watch.ts +94 -26
@@ -12,6 +12,7 @@ import { entityNameToString } from './checker-expressions.js';
12
12
  import { isErrorType } from './checker-type-factory.js';
13
13
  import { getPropertyOfType } from './checker-members.js';
14
14
  import { signatureToString } from './type-printer.js';
15
+ import { declarationCount, getDeclarations } from './symbol.js';
15
16
  /** Whether `declaration`, or the statement it belongs to, has a `@deprecated` JSDoc tag. */
16
17
  export function isDeprecatedDeclaration(declaration) {
17
18
  if ((getCombinedNodeFlags(declaration) & 67108864 /* NodeFlags.PossiblyContainsDeprecatedTag */) === 0)
@@ -37,7 +38,7 @@ function getJSDocDeprecatedTag(node) {
37
38
  * members when all are.
38
39
  */
39
40
  export function isDeprecatedSymbol(c, symbol) {
40
- const declarations = symbol.declarations;
41
+ const declarations = getDeclarations(symbol);
41
42
  const parentSymbol = getParentOfSymbol(c, symbol);
42
43
  if (parentSymbol !== undefined && declarations.length > 1)
43
44
  return (parentSymbol.flags & 64 /* SymbolFlags.Interface */) !== 0
@@ -177,7 +178,7 @@ function isUncalledFunctionReference(c, node, symbol) {
177
178
  return ((parent.kind === 214 /* SyntaxKind.CallExpression */ || parent.kind === 215 /* SyntaxKind.NewExpression */) &&
178
179
  node.kind === 79 /* SyntaxKind.Identifier */ &&
179
180
  hasMatchingArgument(c, parent, node));
180
- for (const d of symbol.declarations)
181
+ for (const d of getDeclarations(symbol))
181
182
  if (isFunctionLikeKind(d.kind) && !isDeprecatedDeclaration(d))
182
183
  return false;
183
184
  return true;
@@ -231,9 +232,9 @@ export function resolveAliasWithDeprecationCheck(c, symbol, location) {
231
232
  const target = getImmediateAliasedSymbol(c, current);
232
233
  if (target === undefined || target === targetSymbol)
233
234
  break;
234
- if (target.declarations.length !== 0) {
235
+ if (declarationCount(target) !== 0) {
235
236
  if (isDeprecatedSymbol(c, target)) {
236
- addDeprecatedSuggestion(c, location, target.declarations, target.name);
237
+ addDeprecatedSuggestion(c, location, getDeclarations(target), target.name);
237
238
  break;
238
239
  }
239
240
  if (current === targetSymbol)
@@ -253,18 +254,18 @@ function getImmediateAliasedSymbol(c, symbol) {
253
254
  /** Resolves the alias an identifier refers to and reports a deprecated target. */
254
255
  export function checkDeprecatedIdentifier(c, node, localOrExportSymbol) {
255
256
  const targetSymbol = resolveAliasWithDeprecationCheck(c, localOrExportSymbol, node);
256
- if (targetSymbol.declarations.length !== 0 &&
257
+ if (declarationCount(targetSymbol) !== 0 &&
257
258
  isDeprecatedSymbol(c, targetSymbol) &&
258
259
  isUncalledFunctionReference(c, node, targetSymbol))
259
- addDeprecatedSuggestion(c, node, targetSymbol.declarations, getText(node));
260
+ addDeprecatedSuggestion(c, node, getDeclarations(targetSymbol), getText(node));
260
261
  }
261
262
  /** Reports a property access to a deprecated property. */
262
263
  export function checkDeprecatedProperty(c, node, right, prop) {
263
264
  const targetPropSymbol = resolveAliasWithDeprecationCheck(c, prop, right);
264
265
  if (isDeprecatedSymbol(c, targetPropSymbol) &&
265
266
  isUncalledFunctionReference(c, node, targetPropSymbol) &&
266
- targetPropSymbol.declarations.length !== 0)
267
- addDeprecatedSuggestion(c, right, targetPropSymbol.declarations, getText(right));
267
+ declarationCount(targetPropSymbol) !== 0)
268
+ addDeprecatedSuggestion(c, right, getDeclarations(targetPropSymbol), getText(right));
268
269
  }
269
270
  /** Reports a property access resolved through a deprecated index signature. */
270
271
  export function checkDeprecatedIndexSignature(c, right, declaration) {
@@ -273,16 +274,14 @@ export function checkDeprecatedIndexSignature(c, right, declaration) {
273
274
  }
274
275
  /** Reports an element access or indexed access type selecting a deprecated property. */
275
276
  export function checkDeprecatedIndexedAccess(c, accessNode, prop, propName) {
276
- if (prop.declarations.length === 0 ||
277
- !isDeprecatedSymbol(c, prop) ||
278
- !isUncalledFunctionReference(c, accessNode, prop))
277
+ if (declarationCount(prop) === 0 || !isDeprecatedSymbol(c, prop) || !isUncalledFunctionReference(c, accessNode, prop))
279
278
  return;
280
279
  const deprecatedNode = accessNode.kind === 213 /* SyntaxKind.ElementAccessExpression */
281
280
  ? accessNode.argumentExpression
282
281
  : accessNode.kind === 200 /* SyntaxKind.IndexedAccessType */
283
282
  ? accessNode.indexType
284
283
  : accessNode;
285
- addDeprecatedSuggestion(c, deprecatedNode, prop.declarations, propName);
284
+ addDeprecatedSuggestion(c, deprecatedNode, getDeclarations(prop), propName);
286
285
  }
287
286
  /** Reports a type reference or import type naming a deprecated type. */
288
287
  export function checkDeprecatedTypeReference(c, node, type) {
@@ -291,9 +290,9 @@ export function checkDeprecatedTypeReference(c, node, type) {
291
290
  const symbol = c.resolvedSymbols.get(node.id);
292
291
  if (symbol === undefined)
293
292
  return;
294
- for (const d of symbol.declarations) {
293
+ for (const d of getDeclarations(symbol)) {
295
294
  if (isTypeDeclaration(d) && isDeprecatedDeclaration(d)) {
296
- addDeprecatedSuggestion(c, getDeprecatedSuggestionNode(node), symbol.declarations, symbol.name);
295
+ addDeprecatedSuggestion(c, getDeprecatedSuggestionNode(node), getDeclarations(symbol), symbol.name);
297
296
  return;
298
297
  }
299
298
  }
@@ -301,8 +300,8 @@ export function checkDeprecatedTypeReference(c, node, type) {
301
300
  /** Reports an import specifier importing a deprecated declaration. */
302
301
  export function checkDeprecatedImportSpecifier(c, node, symbol) {
303
302
  const targetSymbol = resolveAliasWithDeprecationCheck(c, symbol, node);
304
- if (isDeprecatedSymbol(c, targetSymbol) && targetSymbol.declarations.length !== 0)
305
- addDeprecatedSuggestion(c, node, targetSymbol.declarations, targetSymbol.name);
303
+ if (isDeprecatedSymbol(c, targetSymbol) && declarationCount(targetSymbol) !== 0)
304
+ addDeprecatedSuggestion(c, node, getDeclarations(targetSymbol), targetSymbol.name);
306
305
  }
307
306
  /** Reports a JSX attribute setting a deprecated property of the element's contextual props type. */
308
307
  export function checkDeprecatedJsxAttribute(c, contextualType, attribute) {
@@ -310,6 +309,6 @@ export function checkDeprecatedJsxAttribute(c, contextualType, attribute) {
310
309
  if (name.kind !== 79 /* SyntaxKind.Identifier */)
311
310
  return;
312
311
  const prop = getPropertyOfType(c, contextualType, getText(name));
313
- if (prop !== undefined && prop.declarations.length !== 0 && isDeprecatedSymbol(c, prop))
314
- addDeprecatedSuggestion(c, name, prop.declarations, getText(name));
312
+ if (prop !== undefined && declarationCount(prop) !== 0 && isDeprecatedSymbol(c, prop))
313
+ addDeprecatedSuggestion(c, name, getDeclarations(prop), getText(name));
315
314
  }
@@ -1,7 +1,7 @@
1
1
  import { type BindingElement, type Node } from './ast.js';
2
- import { type Symbol } from './symbol.js';
3
2
  import type { Checker } from './checker.js';
4
3
  import { CheckMode, type Type } from './checker-types.js';
4
+ import { type Symbol } from './symbol.js';
5
5
  /** The type of a binding element, from the type of the declaration it destructures. */
6
6
  export declare function getTypeForBindingElement(c: Checker, declaration: Node): Type | undefined;
7
7
  export declare function getTypeForBindingElementParent(c: Checker, node: Node, checkMode: CheckMode): Type | undefined;
@@ -6,7 +6,6 @@ import { getElements, getInitializer, getName, getProperties, getSymbol, getType
6
6
  import { isLeftHandSideExpression } from './ast-utilities.js';
7
7
  import { getFlowTypeOfReference, getDestructuringPropertyName, getTypeOfInitializer } from './checker-narrowing.js';
8
8
  import { getRootDeclaration, isClassLike, isPartOfParameterDeclaration, isPrivateIdentifierClassElementDeclaration, } from './binder-utilities.js';
9
- import { getSymbolId } from './symbol.js';
10
9
  import { TupleElementInfo, } from './checker-types.js';
11
10
  import { cloneTypeReference, createAnonymousType, createArrayType, createTupleTypeEx, getElementTypes, getTypeReferenceArity, tupleTargetOf, everyType, filterType, getNumberLiteralType, getUnionType, getUnionTypeEx, isTupleType, mapType, newIndexInfo, someType, typesOf, } from './checker-type-factory.js';
12
11
  import { getIndexedAccessTypeEx, getIndexedAccessTypeOrUndefinedEx, getLiteralTypeFromProperty, getLiteralTypeFromPropertyName, isGenericIndexType, isGenericObjectType, } from './checker-type-operators.js';
@@ -23,6 +22,7 @@ import { getNonNullableType, getTypeWithFacts, hasTypeFacts } from './checker-fl
23
22
  import { sliceTupleType } from './checker-signatures.js';
24
23
  import { getPropertyNameFromType, isTypeUsableAsPropertyName, maybeTypeOfKind } from './checker-utilities.js';
25
24
  import { checkPropertyAccessibility } from './checker-property-access.js';
25
+ import { copyDeclarations, getDeclarations, getSymbolId } from './symbol.js';
26
26
  function isBindingPatternNode(node) {
27
27
  return (node !== undefined &&
28
28
  (node.kind === 207 /* SyntaxKind.ObjectBindingPattern */ || node.kind === 208 /* SyntaxKind.ArrayBindingPattern */));
@@ -548,7 +548,7 @@ export function isSpreadableProperty(prop) {
548
548
  const notMethodOrAccessor = (prop.flags & (8192 /* SymbolFlags.Method */ | 32768 /* SymbolFlags.GetAccessor */ | 65536 /* SymbolFlags.SetAccessor */)) === 0;
549
549
  let hasPrivateName = false;
550
550
  let inClass = false;
551
- for (const d of prop.declarations) {
551
+ for (const d of getDeclarations(prop)) {
552
552
  if (isPrivateIdentifierClassElementDeclaration(d))
553
553
  hasPrivateName = true;
554
554
  if (d.parent !== undefined && isClassLike(d.parent))
@@ -564,7 +564,7 @@ export function getSpreadSymbol(c, prop, readonly) {
564
564
  const result = c.newSymbolWithCheckFlags(4 /* SymbolFlags.Property */ | (prop.flags & 16777216 /* SymbolFlags.Optional */), prop.name, (prop.checkFlags & 4096 /* CheckFlags.Late */) | (readonly ? 8 /* CheckFlags.Readonly */ : 0));
565
565
  const id = getSymbolId(result);
566
566
  c.symbolTypes.set(id, isSetonlyAccessor ? c.undefinedType : getTypeOfSymbol(c, prop));
567
- result.declarations = prop.declarations;
567
+ copyDeclarations(result, prop);
568
568
  c.symbolNameTypes.set(id, c.symbolNameTypes.get(getSymbolId(prop)));
569
569
  c.symbolSyntheticOrigins.set(id, prop);
570
570
  return result;
@@ -18,6 +18,7 @@ import { createPromiseType } from './checker-iteration.js';
18
18
  import { getFunctionFlags } from './checker-utilities.js';
19
19
  import { typeToString } from './type-printer.js';
20
20
  import { elaborateJsxComponents } from './checker-jsx.js';
21
+ import { declarationCount } from './symbol.js';
21
22
  /** Checks that `source` relates to `target`, elaborating into `expr` when possible. */
22
23
  export function checkTypeRelatedToAndOptionallyElaborate(c, source, target, relation, errorNode, expr, headMessage, diagnosticOutput) {
23
24
  if (isTypeRelatedTo(c, source, target, relation))
@@ -221,11 +222,11 @@ export function elaborateElement(c, source, target, relation, prop, next, nameTy
221
222
  }
222
223
  }
223
224
  if (!issuedElaboration &&
224
- ((targetProp !== undefined && targetProp.declarations.length !== 0) ||
225
- (target.symbol !== undefined && target.symbol.declarations.length !== 0))) {
226
- const targetNode = targetProp !== undefined && targetProp.declarations.length !== 0
227
- ? targetProp.declarations[0]
228
- : target.symbol.declarations[0];
225
+ ((targetProp !== undefined && declarationCount(targetProp) !== 0) ||
226
+ (target.symbol !== undefined && declarationCount(target.symbol) !== 0))) {
227
+ const targetNode = targetProp !== undefined && declarationCount(targetProp) !== 0
228
+ ? targetProp.declaration
229
+ : target.symbol.declaration;
229
230
  if (propertyName === '' || (nameType.flags & 16384 /* TypeFlags.UniqueESSymbol */) !== 0)
230
231
  propertyName = typeToString(c, nameType);
231
232
  if (!c.host.isSourceFileDefaultLibrary(getSourceFileOfNode(targetNode)))
@@ -279,8 +280,8 @@ function elaborateArrowFunction(c, node, source, target, relation, diagnosticOut
279
280
  if (diagnostics.length === 0)
280
281
  return false;
281
282
  const diagnostic = diagnostics[0];
282
- if (target.symbol !== undefined && target.symbol.declarations.length !== 0)
283
- diagnostic.addRelatedInfo(createDiagnosticForNode(target.symbol.declarations[0], 1517 /* Diagnostics.The_expected_type_comes_from_the_return_type_of_this_signature */, []));
283
+ if (target.symbol !== undefined && declarationCount(target.symbol) !== 0)
284
+ diagnostic.addRelatedInfo(createDiagnosticForNode(target.symbol.declaration, 1517 /* Diagnostics.The_expected_type_comes_from_the_return_type_of_this_signature */, []));
284
285
  if ((getFunctionFlags(node) & 2 /* FunctionFlags.Async */) === 0 &&
285
286
  getTypeOfPropertyOfType(c, sourceReturn, 'then') === undefined &&
286
287
  checkTypeRelatedTo(c, createPromiseType(c, sourceReturn), targetReturn, relation, undefined, undefined, undefined))
@@ -2,12 +2,12 @@ import { type EntityName, type FileReference, type Identifier, type ImportDeclar
2
2
  import type { Checker } from './checker.js';
3
3
  import type { CompilerOptions, ModuleKind } from './options.js';
4
4
  import type { EmitContext } from './printer/emit-context.js';
5
- import { type Symbol, SymbolFlags } from './symbol.js';
6
5
  import { DeclarationEmitResolver, NodeBuilderFlags, type SymbolAccessibilityResult, type SymbolTracker } from './transformers/declarations-resolver.js';
7
6
  import type { SyntacticDeclarationEmitResolver } from './transformers/declarations-syntactic.js';
8
7
  import { SyntacticEmitResolver } from './transformers/emit-resolver.js';
9
8
  import type { Evaluation, ReferenceResolver } from './transformers/reference-resolver.js';
10
9
  import { TypeReferenceSerializationKind } from './transformers/type-serialization.js';
10
+ import { type Symbol, SymbolFlags } from './symbol.js';
11
11
  export declare class CheckerDeclarationEmitResolver extends DeclarationEmitResolver {
12
12
  readonly checker: Checker;
13
13
  /** Answers the queries that don't need types. */
@@ -25,6 +25,7 @@ import { isTypeIdenticalTo } from './relations.js';
25
25
  import { beginDeclarationEmitVisibility, isDeclarationVisible, isSymbolAccessible, markDeclarationVisible, } from './symbol-accessibility.js';
26
26
  import { DeclarationEmitResolver, } from './transformers/declarations-resolver.js';
27
27
  import { SyntacticEmitResolver } from './transformers/emit-resolver.js';
28
+ import { declarationCount, getDeclarations } from './symbol.js';
28
29
  const declarationEmitInternalFlags = 8 /* NodeBuilderInternalFlags.AllowUnresolvedNames */;
29
30
  const aliasMeaning = 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */;
30
31
  export class CheckerDeclarationEmitResolver extends DeclarationEmitResolver {
@@ -105,7 +106,7 @@ export class CheckerDeclarationEmitResolver extends DeclarationEmitResolver {
105
106
  while (exportSymbol !== undefined && !visited.has(exportSymbol)) {
106
107
  visited.add(exportSymbol);
107
108
  let next = undefined;
108
- for (const declaration of exportSymbol.declarations) {
109
+ for (const declaration of getDeclarations(exportSymbol)) {
109
110
  markDeclarationVisible(c, declaration);
110
111
  if (declaration instanceof ImportEqualsDeclaration &&
111
112
  declaration.moduleReference.kind !== 284 /* SyntaxKind.ExternalModuleReference */) {
@@ -144,7 +145,7 @@ export class CheckerDeclarationEmitResolver extends DeclarationEmitResolver {
144
145
  const merged = getMergedSymbol(c, s);
145
146
  if (merged === s)
146
147
  continue;
147
- for (const d of merged.declarations)
148
+ for (const d of getDeclarations(merged))
148
149
  if (getSourceFileOfNode(d) === importTarget)
149
150
  return true;
150
151
  }
@@ -430,8 +431,8 @@ export function getTypeReferenceSerializationKind(c, typeName, location) {
430
431
  let isTypeOnly = false;
431
432
  if (typeName.kind === 167 /* SyntaxKind.QualifiedName */) {
432
433
  const root = resolveEntityName(c, getFirstIdentifier(typeName), 111551 /* SymbolFlags.Value */, true, true, location);
433
- if (root !== undefined && root.declarations.length > 0)
434
- isTypeOnly = root.declarations.every(isTypeOnlyImportOrExportDeclaration);
434
+ if (root !== undefined && declarationCount(root) > 0)
435
+ isTypeOnly = getDeclarations(root).every(isTypeOnlyImportOrExportDeclaration);
435
436
  }
436
437
  const valueSymbol = resolveEntityName(c, typeName, 111551 /* SymbolFlags.Value */, true, true, location);
437
438
  let resolvedValue = valueSymbol;
@@ -20,9 +20,10 @@ import { Diagnostic, messageCategory } from './diagnostics.js';
20
20
  import { ModuleKind, ScriptTarget, getEmitModuleKind } from './options.js';
21
21
  import { fileExtensionIsOneOf, isExternalModuleNameRelative } from './path.js';
22
22
  import { SourceFileMetadata, getEmitModuleFormatOfFile, getImpliedNodeFormatForEmit } from './program-utilities.js';
23
- import { Scanner, ScannerErrorReporter, computeLineOfPosition, skipTrivia, tokenToString } from './scanner.js';
23
+ import { Scanner, ScannerErrorReporter, skipTrivia, tokenToString } from './scanner.js';
24
24
  import { typeToString } from './type-printer.js';
25
25
  import { findMismatchedAugmentsTag } from './checker-jsdoc.js';
26
+ import { getDeclarations } from './symbol.js';
26
27
  /** Runs the grammar checks of every node of `file`. */
27
28
  export function checkGrammarSourceFile(c, file) {
28
29
  const g = new GrammarChecker(c, file);
@@ -821,7 +822,7 @@ function getFirstAccessorOfPair(c, node) {
821
822
  if (symbol === undefined)
822
823
  return node;
823
824
  const otherKind = node.kind === 178 /* SyntaxKind.GetAccessor */ ? 179 /* SyntaxKind.SetAccessor */ : 178 /* SyntaxKind.GetAccessor */;
824
- for (const declaration of symbol.declarations)
825
+ for (const declaration of getDeclarations(symbol))
825
826
  if (declaration.kind === otherKind && declaration.pos < node.pos)
826
827
  return declaration;
827
828
  return node;
@@ -969,10 +970,23 @@ function checkGrammarArrowFunction(g, node) {
969
970
  const arrowToken = arrow.equalsGreaterThanToken;
970
971
  if (arrowToken === undefined)
971
972
  return false;
972
- const lineStarts = g.file.lineStarts();
973
- return (computeLineOfPosition(lineStarts, arrowToken.pos) !== computeLineOfPosition(lineStarts, arrowToken.end) &&
973
+ return (hasLineBreak(g.file.text, arrowToken.pos, arrowToken.end) &&
974
974
  grammarErrorOnNode(g, arrowToken, 156 /* Diagnostics.Line_terminator_not_permitted_before_arrow */));
975
975
  }
976
+ /**
977
+ * Whether a line starts in `(pos, end]`, so that `pos` and `end` are on different lines: after an
978
+ * LF, LS or PS, or a CR that no LF follows (`computeLineStarts`), without the file's line starts.
979
+ */
980
+ function hasLineBreak(text, pos, end) {
981
+ for (let i = pos; i < end; i++) {
982
+ const c = text.charCodeAt(i);
983
+ if (c === 0x0a || c === 0x2028 || c === 0x2029)
984
+ return true;
985
+ if (c === 0x0d && text.charCodeAt(i + 1) !== 0x0a)
986
+ return true;
987
+ }
988
+ return false;
989
+ }
976
990
  function checkGrammarForGenerator(g, node) {
977
991
  const asteriskToken = getAsteriskToken(node);
978
992
  if (asteriskToken === undefined)
@@ -1,7 +1,7 @@
1
1
  import { type Node } from './ast.js';
2
- import { type Symbol } from './symbol.js';
3
2
  import { type Checker } from './checker.js';
4
3
  import { type Type } from './checker-types.js';
4
+ import { type Symbol } from './symbol.js';
5
5
  /** Checks a class's merged declarations, members, base class, implemented types and index signatures. */
6
6
  export declare function checkClassHeritage(c: Checker, node: Node): void;
7
7
  /**
@@ -24,6 +24,7 @@ import { checkTypeAssignableTo, checkTypeRelatedTo, compareProperties, isTypeAss
24
24
  import { symbolToString, typeToString } from './type-printer.js';
25
25
  import { checkFunctionOrConstructorSymbol } from './checker-overloads.js';
26
26
  import { isPropertyInitializedInConstructor } from './checker-classes.js';
27
+ import { declarationCount, getDeclarations, } from './symbol.js';
27
28
  // ---- Classes
28
29
  /** Checks a class's merged declarations, members, base class, implemented types and index signatures. */
29
30
  export function checkClassHeritage(c, node) {
@@ -349,7 +350,7 @@ function isImplementedByOtherBaseType(c, t, baseType, base) {
349
350
  /** With `useDefineForClassFields`, a redeclared property without an initializer resets the base value. */
350
351
  function checkPropertyOverwritesBase(c, t, baseType, base, derived, baseDeclarationFlags, derivedDeclarationFlags) {
351
352
  let uninitialized;
352
- for (const d of derived.declarations) {
353
+ for (const d of getDeclarations(derived)) {
353
354
  if (d.kind === 173 /* SyntaxKind.PropertyDeclaration */ && getInitializer(d) === undefined) {
354
355
  uninitialized = d;
355
356
  break;
@@ -360,7 +361,7 @@ function checkPropertyOverwritesBase(c, t, baseType, base, derived, baseDeclarat
360
361
  (baseDeclarationFlags & 64 /* ModifierFlags.Abstract */) !== 0 ||
361
362
  (derivedDeclarationFlags & 64 /* ModifierFlags.Abstract */) !== 0)
362
363
  return;
363
- for (const d of derived.declarations)
364
+ for (const d of getDeclarations(derived))
364
365
  if ((d.flags & 8388608 /* NodeFlags.Ambient */) !== 0)
365
366
  return;
366
367
  const constructor = findConstructorDeclaration(getClassLikeDeclarationOfSymbol(t.symbol));
@@ -404,12 +405,12 @@ function reportMissingAbstractMembers(c, node, missing) {
404
405
  function arePropertiesAbstractOrInterface(base, baseDeclarationFlags) {
405
406
  // Synthetic (intersection) properties need any declaration to qualify; others need all.
406
407
  if ((base.checkFlags & 6 /* CheckFlags.Synthetic */) !== 0) {
407
- for (const d of base.declarations)
408
+ for (const d of getDeclarations(base))
408
409
  if (isPropertyAbstractOrInterface(d, baseDeclarationFlags))
409
410
  return true;
410
411
  return false;
411
412
  }
412
- for (const d of base.declarations)
413
+ for (const d of getDeclarations(base))
413
414
  if (!isPropertyAbstractOrInterface(d, baseDeclarationFlags))
414
415
  return false;
415
416
  return true;
@@ -485,13 +486,13 @@ function checkMemberForOverrideModifier(c, node, staticType, baseStaticType, bas
485
486
  return;
486
487
  }
487
488
  if (baseProp === undefined ||
488
- baseProp.declarations.length === 0 ||
489
+ declarationCount(baseProp) === 0 ||
489
490
  memberHasOverrideModifier ||
490
491
  c.compilerOptions.noImplicitOverride !== true ||
491
492
  (node.flags & 8388608 /* NodeFlags.Ambient */) !== 0)
492
493
  return;
493
494
  let baseHasAbstract = false;
494
- for (const d of baseProp.declarations) {
495
+ for (const d of getDeclarations(baseProp)) {
495
496
  if (hasSyntacticModifier(d, 64 /* ModifierFlags.Abstract */)) {
496
497
  baseHasAbstract = true;
497
498
  break;
@@ -590,14 +591,14 @@ function checkInheritedPropertiesAreIdentical(c, t, typeNode) {
590
591
  // ---- Type parameters of merged declarations
591
592
  /** Reports class and interface declarations of one symbol whose type parameters differ. */
592
593
  export function checkTypeParameterListsIdentical(c, symbol) {
593
- if (symbol.declarations.length === 1)
594
+ if (declarationCount(symbol) === 1)
594
595
  return;
595
596
  const links = c.symbolLinks(symbol);
596
597
  if (links.typeParametersChecked)
597
598
  return;
598
599
  links.typeParametersChecked = true;
599
600
  const declarations = [];
600
- for (const d of symbol.declarations)
601
+ for (const d of getDeclarations(symbol))
601
602
  if (d.kind === 264 /* SyntaxKind.ClassDeclaration */ || d.kind === 265 /* SyntaxKind.InterfaceDeclaration */)
602
603
  declarations.push(d);
603
604
  if (declarations.length <= 1)
@@ -618,7 +619,7 @@ export function checkTypeParameterListsIdentical(c, symbol) {
618
619
  }
619
620
  /** Reports the declarations of an `infer` type parameter declared more than once with different constraints. */
620
621
  export function checkInferTypeParameterDeclarations(c, symbol) {
621
- if (symbol.declarations.length <= 1)
622
+ if (declarationCount(symbol) <= 1)
622
623
  return;
623
624
  const links = c.symbolLinks(symbol);
624
625
  if (links.typeParametersChecked)
@@ -626,7 +627,7 @@ export function checkInferTypeParameterDeclarations(c, symbol) {
626
627
  links.typeParametersChecked = true;
627
628
  const declarations = [];
628
629
  const typeParameterLists = [];
629
- for (const d of symbol.declarations) {
630
+ for (const d of getDeclarations(symbol)) {
630
631
  if (d.kind === 169 /* SyntaxKind.TypeParameter */) {
631
632
  declarations.push(d);
632
633
  typeParameterLists.push([d]);
@@ -711,7 +712,7 @@ export function checkObjectTypeForDuplicateDeclarations(c, node, checkPrivateNam
711
712
  }
712
713
  }
713
714
  function checkPropertyOrAccessor(c, node, names, symbol, kind, isStaticMember) {
714
- if (symbol.declarations.length <= 1)
715
+ if (declarationCount(symbol) <= 1)
715
716
  return;
716
717
  const state = names.get(symbol.name) ?? 0 /* MemberKind.None */;
717
718
  if (state === 0 /* MemberKind.None */)
@@ -865,12 +866,12 @@ function checkTypeForDuplicateIndexSignatures(c, node) {
865
866
  if (symbol === undefined)
866
867
  return;
867
868
  const indexSymbol = getIndexSymbol(c, symbol);
868
- if (indexSymbol === undefined || indexSymbol.declarations.length <= 1)
869
+ if (indexSymbol === undefined || declarationCount(indexSymbol) <= 1)
869
870
  return;
870
871
  // Late-bound index signatures may duplicate each other and explicit ones.
871
872
  const keyTypes = [];
872
873
  const declarationsByKey = [];
873
- for (const declaration of indexSymbol.declarations) {
874
+ for (const declaration of getDeclarations(indexSymbol)) {
874
875
  if (declaration.kind !== 182 /* SyntaxKind.IndexSignature */)
875
876
  continue;
876
877
  const parameters = getParameters(declaration).nodes;
@@ -1,8 +1,8 @@
1
1
  import { type Node } from './ast.js';
2
- import { type Symbol } from './symbol.js';
3
2
  import type { Checker } from './checker.js';
4
3
  import { type ConditionalRoot, type IndexType, type MappedType, type ReverseMappedType, type Signature, type TemplateLiteralType, type Type, TypeMapper } from './checker-types.js';
5
4
  import { type TypeComparer } from './relations.js';
5
+ import { type Symbol } from './symbol.js';
6
6
  export declare const enum InferenceFlags {
7
7
  None = 0,
8
8
  /** Infer `silentNeverType` for no inferences (otherwise `unknown`). */
@@ -2,7 +2,6 @@
2
2
  // types of type parameters.
3
3
  import { sideOf, signatureSideOf } from './side-state.js';
4
4
  import { hasSyntacticModifier } from './binder-utilities.js';
5
- import { getSymbolId } from './symbol.js';
6
5
  import { ArrayToSingleTypeMapper, MergedTypeMapper, TupleElementInfo, TypeMapper, newTypeMapper, SimpleTypeMapper, emptyTypes, } from './checker-types.js';
7
6
  import { createAnonymousType, createArrayType, createArrayTypeEx, createTupleType, createTupleTypeEx, filterType, getBaseTypeOfLiteralType, getBigIntLiteralType, getElementTypes, getEndElementCount, getIntersectionType, getNumberLiteralType, getRegularTypeOfLiteralType, getStringLiteralType, getTemplateLiteralType, getTypeArguments, getTypeReferenceArity, getUnionType, getUnionTypeEx, getWidenedLiteralType, isArrayOrTupleType, isErrorType, isArrayType, isGenericTupleType, isLiteralType, isMutableArrayOrTuple, isReadonlyArrayType, isTupleType, mapType, newIndexInfo, newObjectType, setStructuredTypeMembers, someType, tupleTargetOf, typesOf, } from './checker-type-factory.js';
8
7
  import { getDeclaredTypeOfClassOrInterface, getDeclaredTypeOfSymbol, fillMissingTypeArguments, getConstraintOfTypeParameter, getDefaultFromTypeParameter, getMinTypeArgumentCount, getDeclaredTypeOfTypeParameter, } from './checker-declared-types.js';
@@ -17,6 +16,7 @@ import { getTypeFromTypeNode } from './checker-type-nodes.js';
17
16
  import { getMergedSymbol, getSymbolOfDeclaration } from './checker-symbols.js';
18
17
  import { parsePseudoBigInt } from './pseudo-bigint.js';
19
18
  import { getContextualTypeForInference } from './checker-contextual.js';
19
+ import { copyDeclarations, declarationCount, getDeclarations, getSymbolId, } from './symbol.js';
20
20
  // Shared empty candidate lists: an InferenceInfo gets its own on its first candidate, as tsgo's nil
21
21
  // slices do. Never changed.
22
22
  const noCandidates = [];
@@ -179,7 +179,7 @@ function hasTypeParameterDefault(tp) {
179
179
  const symbol = tp.symbol;
180
180
  if (symbol === undefined)
181
181
  return false;
182
- for (const d of symbol.declarations)
182
+ for (const d of getDeclarations(symbol))
183
183
  if (d.kind === 169 /* SyntaxKind.TypeParameter */ && d.defaultType !== undefined)
184
184
  return true;
185
185
  return false;
@@ -991,9 +991,9 @@ function isTopLevelClassStaticSide(t) {
991
991
  (symbol.flags &
992
992
  (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 2048 /* SymbolFlags.TypeLiteral */ | 4096 /* SymbolFlags.ObjectLiteral */)) !==
993
993
  0 ||
994
- symbol.declarations.length === 0)
994
+ declarationCount(symbol) === 0)
995
995
  return false;
996
- for (const d of symbol.declarations) {
996
+ for (const d of getDeclarations(symbol)) {
997
997
  if (d.kind !== 264 /* SyntaxKind.ClassDeclaration */ &&
998
998
  d.kind !== 265 /* SyntaxKind.InterfaceDeclaration */ &&
999
999
  d.kind !== 268 /* SyntaxKind.ModuleDeclaration */)
@@ -1031,7 +1031,7 @@ function createEmptyObjectTypeFromStringLiteral(c, t) {
1031
1031
  const literalProp = c.newSymbol(4 /* SymbolFlags.Property */, name);
1032
1032
  c.symbolTypes.set(getSymbolId(literalProp), c.anyType);
1033
1033
  if (u.symbol !== undefined) {
1034
- literalProp.declarations = u.symbol.declarations;
1034
+ copyDeclarations(literalProp, u.symbol);
1035
1035
  literalProp.valueDeclaration = u.symbol.valueDeclaration;
1036
1036
  }
1037
1037
  members.set(name, literalProp);
@@ -1101,7 +1101,7 @@ function typesDefinitelyUnrelated(c, source, target) {
1101
1101
  function hasUnmatchedProperty(c, source, target, matchDiscriminantProperties) {
1102
1102
  const t = getReducedApparentType(c, target);
1103
1103
  if ((t.flags & 402653184 /* TypeFlags.UnionOrIntersection */) === 0 ||
1104
- sideOf(c, t).resolvedProperties !== undefined)
1104
+ sideOf(c, t).membersOf?.resolvedProperties !== undefined)
1105
1105
  return getUnmatchedProperty(c, source, target, false, matchDiscriminantProperties) !== undefined;
1106
1106
  const containingType = t;
1107
1107
  const isUnion = (t.flags & 134217728 /* TypeFlags.Union */) !== 0;
@@ -1146,7 +1146,7 @@ export function isConstTypeVariable(c, t, depth) {
1146
1146
  if ((t.flags & 524288 /* TypeFlags.TypeParameter */) !== 0) {
1147
1147
  if (t.symbol === undefined)
1148
1148
  return false;
1149
- for (const d of t.symbol.declarations)
1149
+ for (const d of getDeclarations(t.symbol))
1150
1150
  if (hasSyntacticModifier(d, 4096 /* ModifierFlags.Const */))
1151
1151
  return true;
1152
1152
  return false;
@@ -1616,7 +1616,7 @@ export function resolveReverseMappedTypeMembers(c, t) {
1616
1616
  }
1617
1617
  const checkFlags = 8192 /* CheckFlags.ReverseMapped */ | (readonlyMask && isReadonlySymbol(c, prop) ? 8 /* CheckFlags.Readonly */ : 0);
1618
1618
  const inferredProp = c.newSymbolWithCheckFlags(4 /* SymbolFlags.Property */ | (prop.flags & optionalMask), prop.name, checkFlags);
1619
- inferredProp.declarations = prop.declarations;
1619
+ copyDeclarations(inferredProp, prop);
1620
1620
  const links = c.symbolLinks(inferredProp);
1621
1621
  const id = inferredProp.id;
1622
1622
  c.symbolNameTypes.set(id, c.symbolNameTypes.get(getSymbolId(prop)));
@@ -2014,7 +2014,7 @@ export function getInferredTypeParameterConstraint(c, t, omitTypeReferences = fa
2014
2014
  const inferences = [];
2015
2015
  const symbol = t.symbol;
2016
2016
  if (symbol !== undefined)
2017
- for (const declaration of symbol.declarations) {
2017
+ for (const declaration of getDeclarations(symbol)) {
2018
2018
  if (declaration.parent === undefined || declaration.parent.kind !== 196 /* SyntaxKind.InferType */)
2019
2019
  continue;
2020
2020
  let child = declaration.parent;
@@ -1,7 +1,7 @@
1
1
  import { BinaryExpression, type Node } from './ast.js';
2
- import { type Symbol } from './symbol.js';
3
2
  import type { Checker } from './checker.js';
4
3
  import { type Type } from './checker-types.js';
4
+ import { type Symbol } from './symbol.js';
5
5
  /** The type of the CommonJS `module` symbol or its `exports` property. */
6
6
  export declare function getTypeOfModuleExportsSymbol(c: Checker, symbol: Symbol): Type;
7
7
  /** The type of a symbol declared by JavaScript assignments or `Object.defineProperty` calls. */
@@ -18,6 +18,7 @@ import { getFlowTypeOfReference, isMatchingReference } from './checker-narrowing
18
18
  import { isEmptyArrayLiteralType } from './relations.js';
19
19
  import { getTypeOfSymbol, getWidenedType, reportImplicitAny } from './checker-symbol-types.js';
20
20
  import { getFlowTypeInConstructor, getFlowTypeOfProperty, getTypeOfPropertyInBaseClass, isAutoTypedProperty, } from './checker-classes.js';
21
+ import { declarationCount, getDeclarations } from './symbol.js';
21
22
  /** The type of the CommonJS `module` symbol or its `exports` property. */
22
23
  export function getTypeOfModuleExportsSymbol(c, symbol) {
23
24
  if (symbol.name === 'exports') {
@@ -39,7 +40,7 @@ export function getWidenedTypeForAssignmentDeclaration(c, symbol) {
39
40
  t = getTypeOfPropertyInBaseClass(c, symbol);
40
41
  if (t === undefined) {
41
42
  const types = [];
42
- const declarations = symbol.declarations;
43
+ const declarations = getDeclarations(symbol);
43
44
  for (let i = 0; i < declarations.length; i++) {
44
45
  const declaration = declarations[i];
45
46
  const declaredType = declaration instanceof BinaryExpression ? declaration.type : undefined;
@@ -170,7 +171,7 @@ function getThisAssignmentKind(c, symbol) {
170
171
  return (links.thisAssignmentKind - 1);
171
172
  let allThis = true;
172
173
  let typeAnnotation;
173
- for (const declaration of symbol.declarations) {
174
+ for (const declaration of getDeclarations(symbol)) {
174
175
  if (!(declaration instanceof BinaryExpression)) {
175
176
  allThis = false;
176
177
  break;
@@ -210,7 +211,7 @@ export function isConstructorDeclaredThisProperty(c, symbol) {
210
211
  return getThisAssignmentKind(c, symbol) === 2 /* ThisAssignmentKind.Constructor */;
211
212
  }
212
213
  function getDeclaringConstructor(symbol) {
213
- for (const declaration of symbol.declarations) {
214
+ for (const declaration of getDeclarations(symbol)) {
214
215
  const container = getThisContainer(declaration, false, false);
215
216
  if (container.kind === 177 /* SyntaxKind.Constructor */)
216
217
  return container;
@@ -437,5 +438,5 @@ export function isUndefinedAssignmentToCommonJSExport(c, left, rightType) {
437
438
  if (getAssignmentDeclarationKind(assignment) !== 2 /* JSDeclarationKind.ExportsProperty */)
438
439
  return false;
439
440
  const symbol = c.resolvedSymbols.get(left.id);
440
- return symbol !== undefined && symbol.declarations.length > 1 && (rightType.flags & 4 /* TypeFlags.Undefined */) !== 0;
441
+ return symbol !== undefined && declarationCount(symbol) > 1 && (rightType.flags & 4 /* TypeFlags.Undefined */) !== 0;
441
442
  }
@@ -1,11 +1,11 @@
1
1
  import { type JsxAttributes, type Node, type SourceFile } from './ast.js';
2
2
  import { Diagnostic } from './diagnostics.js';
3
- import { type Symbol } from './symbol.js';
4
3
  import { type Checker } from './checker.js';
5
4
  import { CheckMode, type Signature, type Type } from './checker-types.js';
6
5
  import { type Relation } from './relations.js';
7
6
  import { ContextFlags } from './checker-contextual.js';
8
7
  import { type InferenceContext } from './checker-inference.js';
8
+ import { type Symbol } from './symbol.js';
9
9
  declare const enum JsxFlags {
10
10
  None = 0,
11
11
  /** An element from a named property of `JSX.IntrinsicElements`. */
@@ -6,7 +6,6 @@ import { Diagnostic, chainDiagnostic } from './diagnostics.js';
6
6
  import { JsxEmit } from './options.js';
7
7
  import { parseIsolatedEntityName } from './parser.js';
8
8
  import { skipTrivia } from './scanner.js';
9
- import { getSymbolId } from './symbol.js';
10
9
  import { createDiagnosticForNode } from './checker.js';
11
10
  import { newTypeMapper, } from './checker-types.js';
12
11
  import { createAnonymousType, createArrayType, createTupleType, createTypeReference, getIntersectionType, getPropagatingFlagsOfTypes, getStringLiteralType, getUnionType, intersectTypes, isErrorType, everyType, isArrayType, mapTypeEx, someType, typesOf, } from './checker-type-factory.js';
@@ -38,6 +37,7 @@ import { getIndexedAccessType } from './checker-type-operators.js';
38
37
  import { filterType, isTupleType } from './checker-type-factory.js';
39
38
  import { createTypeFromGenericGlobalType } from './checker-type-factory.js';
40
39
  import { isTypeAssignableTo } from './relations.js';
40
+ import { copyDeclarations, declarationCount, getSymbolId, } from './symbol.js';
41
41
  // Names in the `JSX` namespace.
42
42
  const jsxNamespaceName = 'JSX';
43
43
  const jsxIntrinsicElementsName = 'IntrinsicElements';
@@ -384,8 +384,8 @@ function getNameFromJsxElementAttributesContainer(c, containerName, ns) {
384
384
  return '';
385
385
  if (props.length === 1)
386
386
  return props[0].name;
387
- if (sym.declarations.length !== 0)
388
- c.error(sym.declarations[0], 752 /* Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property */, containerName);
387
+ if (declarationCount(sym) !== 0)
388
+ c.error(sym.declaration, 752 /* Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property */, containerName);
389
389
  }
390
390
  }
391
391
  return "\uFFFEmissing" /* InternalSymbolName.Missing */;
@@ -733,7 +733,7 @@ export function createJsxAttributesTypeFromAttributesProperty(c, openingLikeElem
733
733
  const exprType = checkJsxAttribute(c, attributeDecl, checkMode);
734
734
  objectFlags |= exprType.objectFlags & 458752 /* ObjectFlags.PropagatingFlags */;
735
735
  const attributeSymbol = c.newSymbol(4 /* SymbolFlags.Property */ | member.flags, member.name);
736
- attributeSymbol.declarations = member.declarations;
736
+ copyDeclarations(attributeSymbol, member);
737
737
  attributeSymbol.parent = member.parent;
738
738
  if (member.valueDeclaration !== undefined)
739
739
  attributeSymbol.valueDeclaration = member.valueDeclaration;
@@ -1,4 +1,4 @@
1
- import { getSymbolId } from './symbol.js';
1
+ import { copyDeclarations, getSymbolId } from './symbol.js';
2
2
  import { cachedTypeKey } from './checker-types.js';
3
3
  import { createAnonymousType } from './checker-type-factory.js';
4
4
  import { getPropertiesOfObjectType, resolveStructuredTypeMembers } from './checker-members.js';
@@ -29,7 +29,7 @@ export function getRegularTypeOfObjectLiteral(c, t) {
29
29
  }
30
30
  function createSymbolWithTypeLocal(c, source, t) {
31
31
  const symbol = c.newSymbolWithCheckFlags(source.flags, source.name, source.checkFlags & 8 /* CheckFlags.Readonly */);
32
- symbol.declarations = source.declarations;
32
+ copyDeclarations(symbol, source);
33
33
  symbol.parent = source.parent;
34
34
  symbol.valueDeclaration = source.valueDeclaration;
35
35
  const id = getSymbolId(symbol);