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
package/README.md CHANGED
@@ -33,7 +33,7 @@ npx tsc-ts --noEmit src/index.ts
33
33
 
34
34
  `tsc-ts --api` serves the TypeScript API over stdin and stdout, like `tsc --api`.
35
35
 
36
- `--checkers N` checks the program on N threads. Unless `--checkers` or `--singleThreaded` is given, the native executable uses one checker per CPU it may run on (up to 16), and at least tsgo's four; it uses fewer than the CPUs, but never fewer than four, when the estimated peak memory of more checkers would not fit 85% of the machine's memory (`TSC_TS_CHECKERS=fixed` keeps tsgo's four), and checkers beyond the fourth stop taking files, one at a time, when the process's memory reaches that share; it shares one program between its threads and also parses and binds the program's files on them. Files that share costly declarations, such as a large generated schema and the few files importing it, are checked together on one checker. Under Node.js, where every thread builds its own copy of the program, tsc-ts checks on one thread unless `--checkers` is given. `--incremental`, `--watch` and `--build` always check on one thread. The diagnostics are the same as with one checker.
36
+ `--checkers N` checks the program on N threads. Unless `--checkers` or `--singleThreaded` is given, the native executable uses one checker per CPU it may run on (up to 16), and at least tsgo's four; it uses fewer than the CPUs, but never fewer than four, when the estimated peak memory of more checkers would not fit 85% of the machine's memory (`TSC_TS_CHECKERS=fixed` keeps tsgo's four), and checkers beyond the fourth stop taking files, one at a time, when the process's memory reaches that share; it shares one program between its threads and also parses and binds the program's files on them. Unless `--singleThreaded` is given, the program's files are parsed and bound on threads also with `--checkers 1`, as tsgo does. Files that share costly declarations, such as a large generated schema and the few files importing it, are checked together on one checker. Under Node.js, where every thread builds its own copy of the program, tsc-ts checks on one thread unless `--checkers` is given. `--incremental`, `--watch` and `--build` always check on one thread. The diagnostics are the same as with one checker.
37
37
 
38
38
  The native executable never frees syntax trees, types, signatures or symbols: it keeps them until it exits, which saves the cost of tracking them during a build. A one-shot build is unaffected, but a long-running process grows with each rebuild or project update. Native `--watch` (also with `--build`) runs in a child process, and when a change arrives while that process holds more than 2.5 times the memory it held after its first build, a new process replaces it and builds the change, reporting what the old process would have. `TSC_TS_WATCH_MEMORY` sets that limit in megabytes, and `TSC_TS_WATCH_MEMORY=0` turns the replacement off. A `--api` process grows with each project update; restart it to reclaim the memory.
39
39
 
@@ -243,13 +243,22 @@ export declare class Token extends Node {
243
243
  }
244
244
  export declare class Identifier extends Node {
245
245
  text: string;
246
- flowNode: FlowNode | undefined;
247
246
  constructor(text: string);
248
247
  forEachChild(_v: NodeVisitor): boolean;
249
248
  setParentOfChildren(): void;
250
249
  deepClone(): Node;
251
250
  copy(): Identifier;
252
251
  }
252
+ /**
253
+ * An identifier that can be read as a reference, such as an expression or a shorthand property
254
+ * name, and so holds the binder's flow node. The parser creates a plain `Identifier` for names
255
+ * whose flow node nothing reads: declaration names, property names and property access names.
256
+ */
257
+ export declare class ReferenceIdentifier extends Identifier {
258
+ flowNode: FlowNode | undefined;
259
+ constructor(text: string);
260
+ copy(): Identifier;
261
+ }
253
262
  export declare class PrivateIdentifier extends Node {
254
263
  text: string;
255
264
  constructor(text: string);
@@ -2270,12 +2279,6 @@ export declare class SourceFile extends Node {
2270
2279
  patternAmbientModules: PatternAmbientModule[];
2271
2280
  /** UMD exports from `export as namespace N`. */
2272
2281
  globalExports: SymbolTable | undefined;
2273
- /**
2274
- * By name, the first property of the unions of the file's object literals that leave the name
2275
- * missing (checker-symbol-types.ts `scanSiblingProperties`), where a parse thread scanned the file
2276
- * and could resolve the enums the scan needed.
2277
- */
2278
- siblingProperties: Map<string, Node> | undefined;
2279
2282
  constructor(fileName: string, path: string, text: string, externalModuleIndicatorOptions: ExternalModuleIndicatorOptions, statements: NodeList, endOfFileToken: Token);
2280
2283
  forEachChild(v: NodeVisitor): boolean;
2281
2284
  setParentOfChildren(): void;
@@ -2287,8 +2290,6 @@ export declare class SourceFile extends Node {
2287
2290
  * never writes to the file (UTF-8 offsets are computed on first use, `DiagnosticFile.computeCaches`).
2288
2291
  */
2289
2292
  computeCaches(): void;
2290
- /** Like `computeCaches`, from the UTF-16 code units of the text (at least `text.length` of them). */
2291
- computeCachesFromUnits(units: Uint16Array): void;
2292
2293
  /** The file as diagnostics see it. */
2293
2294
  diagnosticFile(): DiagnosticFile;
2294
2295
  isJS(): boolean;
@@ -222,12 +222,9 @@ export class Token extends Node {
222
222
  }
223
223
  export class Identifier extends Node {
224
224
  text;
225
- // Set by the binder.
226
- flowNode;
227
225
  constructor(text) {
228
226
  super(79 /* SyntaxKind.Identifier */);
229
227
  this.text = text;
230
- this.flowNode = undefined;
231
228
  }
232
229
  forEachChild(_v) {
233
230
  return false;
@@ -244,6 +241,26 @@ export class Identifier extends Node {
244
241
  return node;
245
242
  }
246
243
  }
244
+ /**
245
+ * An identifier that can be read as a reference, such as an expression or a shorthand property
246
+ * name, and so holds the binder's flow node. The parser creates a plain `Identifier` for names
247
+ * whose flow node nothing reads: declaration names, property names and property access names.
248
+ */
249
+ export class ReferenceIdentifier extends Identifier {
250
+ // Set by the binder.
251
+ flowNode;
252
+ constructor(text) {
253
+ super(text);
254
+ this.flowNode = undefined;
255
+ }
256
+ copy() {
257
+ const node = new ReferenceIdentifier(this.text);
258
+ node.flags = this.flags;
259
+ node.pos = this.pos;
260
+ node.end = this.end;
261
+ return node;
262
+ }
263
+ }
247
264
  export class PrivateIdentifier extends Node {
248
265
  text;
249
266
  constructor(text) {
@@ -6567,12 +6584,6 @@ export class SourceFile extends Node {
6567
6584
  patternAmbientModules;
6568
6585
  /** UMD exports from `export as namespace N`. */
6569
6586
  globalExports;
6570
- /**
6571
- * By name, the first property of the unions of the file's object literals that leave the name
6572
- * missing (checker-symbol-types.ts `scanSiblingProperties`), where a parse thread scanned the file
6573
- * and could resolve the enums the scan needed.
6574
- */
6575
- siblingProperties;
6576
6587
  constructor(fileName, path, text, externalModuleIndicatorOptions, statements, endOfFileToken) {
6577
6588
  super(307 /* SyntaxKind.SourceFile */);
6578
6589
  this.fileName = fileName;
@@ -6617,7 +6628,6 @@ export class SourceFile extends Node {
6617
6628
  this.symbolCount = 0;
6618
6629
  this.patternAmbientModules = [];
6619
6630
  this.globalExports = undefined;
6620
- this.siblingProperties = undefined;
6621
6631
  }
6622
6632
  forEachChild(v) {
6623
6633
  return v.visitList(this.statements) || v.visitNode(this.endOfFileToken);
@@ -6640,10 +6650,6 @@ export class SourceFile extends Node {
6640
6650
  computeCaches() {
6641
6651
  this.diagnosticFile().computeCaches();
6642
6652
  }
6643
- /** Like `computeCaches`, from the UTF-16 code units of the text (at least `text.length` of them). */
6644
- computeCachesFromUnits(units) {
6645
- this.diagnosticFile().computeCachesFromUnits(units);
6646
- }
6647
6653
  /** The file as diagnostics see it. */
6648
6654
  diagnosticFile() {
6649
6655
  let file = this.diagnosticFileCache;
@@ -10503,7 +10509,7 @@ export function setNextContainer(node, value) {
10503
10509
  export function getFlowNode(node) {
10504
10510
  switch (node.kind) {
10505
10511
  case 79 /* SyntaxKind.Identifier */:
10506
- if (node instanceof Identifier) {
10512
+ if (node instanceof ReferenceIdentifier) {
10507
10513
  const holder = node;
10508
10514
  return holder.flowNode;
10509
10515
  }
@@ -10774,7 +10780,7 @@ export function getFlowNode(node) {
10774
10780
  export function setFlowNode(node, value) {
10775
10781
  switch (node.kind) {
10776
10782
  case 79 /* SyntaxKind.Identifier */:
10777
- if (node instanceof Identifier) {
10783
+ if (node instanceof ReferenceIdentifier) {
10778
10784
  const target = node;
10779
10785
  target.flowNode = value;
10780
10786
  }
@@ -7,6 +7,7 @@ import { BinaryExpression, CallExpression, ElementAccessExpression, ExpressionSt
7
7
  import { getJSDoc } from './parser.js';
8
8
  import { isAssignmentOperator, isLeftHandSideExpression, isStringLiteralLike, nodeIsMissing } from './ast-utilities.js';
9
9
  import { Scanner, computeLineOfPosition, skipTrivia } from './scanner.js';
10
+ import { getDeclarations } from './symbol.js';
10
11
  // Modifiers and flags
11
12
  export function getModifierFlags(node) {
12
13
  const modifiers = getModifiers(node);
@@ -861,7 +862,7 @@ export function moduleExportNameIsDefault(node) {
861
862
  return getText(node) === "default" /* InternalSymbolName.Default */;
862
863
  }
863
864
  export function getDeclarationOfKind(symbol, kind) {
864
- for (const declaration of symbol.declarations)
865
+ for (const declaration of getDeclarations(symbol))
865
866
  if (declaration.kind === kind)
866
867
  return declaration;
867
868
  return undefined;
@@ -3,14 +3,14 @@
3
3
  //
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
- import { BinaryExpression, CallExpression, ConditionalTypeNode, ElementAccessExpression, ExportAssignment, FunctionExpression, KeywordExpression, ModuleDeclaration, NodeVisitor, PatternAmbientModule, PrefixUnaryExpression, PropertyAccessExpression, TypeAliasDeclaration, VariableDeclaration, getArguments, getBody, getElements, getExpression, getInitializer, getLabel, getLocals, getModifiers, getName, getParameters, getPostfixToken, getProperties, getStatements, getSymbol, getText, isDeclarationNode, isLocalsContainer, setEndFlowNode, setFlowNode, setLocalSymbol, setLocals, setNextContainer, setReturnFlowNode, setSymbol, } from './ast.js';
6
+ import { BinaryExpression, CallExpression, ConditionalTypeNode, ElementAccessExpression, ExportAssignment, FunctionExpression, KeywordExpression, ModuleDeclaration, NodeVisitor, PatternAmbientModule, PrefixUnaryExpression, PropertyAccessExpression, ReferenceIdentifier, TypeAliasDeclaration, VariableDeclaration, getArguments, getBody, getElements, getExpression, getInitializer, getLabel, getLocals, getModifiers, getName, getParameters, getPostfixToken, getProperties, getStatements, getSymbol, getText, isDeclarationNode, isLocalsContainer, setEndFlowNode, setFlowNode, setLocalSymbol, setLocals, setNextContainer, setReturnFlowNode, setSymbol, } from './ast.js';
7
7
  import { isAmbientModule, isAssignmentOperator, isFunctionLike, isGlobalScopeAugmentation, isInJSFile, isLeftHandSideExpression, isRequireCall, isStringLiteralLike, nodeIsMissing, nodeIsPresent, } from './ast-utilities.js';
8
8
  import { declarationNameToString, expressionIsAlias, getAssignmentDeclarationKind, getCombinedModifierFlags, getContainingClass, getElementOrPropertyAccessName, getErrorRangeForNode, getImmediatelyInvokedFunctionExpression, getModuleInstanceState, StatementsByName, getNameOfDeclaration, getRangeOfTokenAtPosition, getSourceTextOfNode, hasDynamicName, hasSyntacticModifier, isAssignmentTarget, isAsyncFunction, isAutoAccessorPropertyDeclaration, isBlockOrCatchScoped, isBooleanLiteral, isDeclarationStatementKind, isDestructuringAssignment, isDottedName, isEntityNameExpression, isEnumConst, isExpandoInitializer, isExpressionOfOptionalChainRoot, isExternalModule, isExternalOrCommonJSModule, isIdentifierName, isImplicitlyExportedJSDocDeclaration, isInTopLevelContext, isJsonSourceFile, isLogicalExpression, isLogicalOrCoalescingAssignmentExpression, isLogicalOrCoalescingAssignmentOperator, isLogicalOrCoalescingBinaryOperator, isModuleAugmentationExternal, isNullishCoalesce, isObjectLiteralMethod, isObjectLiteralOrClassExpressionMethodOrAccessor, isOptionalChain, isOptionalChainRoot, isOutermostOptionalChain, isParameterPropertyDeclaration, isPartOfParameterDeclaration, isPartOfTypeQuery, isPotentiallyExecutableNode, isPrologueDirective, isPropertyNameLiteral, isPushOrUnshiftIdentifier, isSignedNumericLiteral, isStatic, isStringOrNumericLiteralLike, isVariableDeclarationInitializedToRequire, moduleExportNameIsDefault, nodeText, skipParentheses, } from './binder-utilities.js';
9
9
  import { Diagnostic } from './diagnostics.js';
10
10
  import { FlowNode, FlowReduceLabel, FlowSwitchClause } from './flow.js';
11
11
  import { removeFileExtension } from './path.js';
12
12
  import { getIdentifierToken, tokenToString } from './scanner.js';
13
- import { Symbol, addDeclaration, getExports, getMembers, getSymbolId, internalSymbolNamePrefix, } from './symbol.js';
13
+ import { addDeclaration, copyDeclarations, declarationCount, getDeclarations, getExports, getMembers, getSymbolId, internalSymbolNamePrefix, Symbol, } from './symbol.js';
14
14
  export function getContainerFlags(node) {
15
15
  switch (node.kind) {
16
16
  case 232 /* SyntaxKind.ClassExpression */:
@@ -306,7 +306,7 @@ class Binder extends NodeVisitor {
306
306
  messageNeedsName = false;
307
307
  }
308
308
  let multipleDefaultExports = false;
309
- if (symbol.declarations.length !== 0) {
309
+ if (declarationCount(symbol) !== 0) {
310
310
  // A default export (by modifier, or `export default` assignment) after another one.
311
311
  if (isDefaultExport || (node instanceof ExportAssignment && !node.isExportEquals)) {
312
312
  message = 686 /* Diagnostics.A_module_cannot_have_multiple_default_exports */;
@@ -325,7 +325,7 @@ class Binder extends NodeVisitor {
325
325
  'export type { ' + node.name.text + ' }',
326
326
  ]));
327
327
  }
328
- const declarations = symbol.declarations;
328
+ const declarations = getDeclarations(symbol);
329
329
  for (let index = 0; index < declarations.length; index++) {
330
330
  const declaration = declarations[index];
331
331
  const decl = getNameOfDeclaration(declaration) ?? declaration;
@@ -498,7 +498,7 @@ class Binder extends NodeVisitor {
498
498
  addDeclarationToSymbol(symbol, node, symbolFlags) {
499
499
  symbol.flags |= symbolFlags;
500
500
  setSymbol(node, symbol);
501
- if (symbol.declarations.indexOf(node) < 0)
501
+ if (getDeclarations(symbol).indexOf(node) < 0)
502
502
  addDeclaration(symbol, node);
503
503
  // A const-enum-only namespace merged with a class, function or regular enum isn't one anymore.
504
504
  if ((symbol.flags & 268435456 /* SymbolFlags.ConstEnumOnlyModule */) !== 0 &&
@@ -553,7 +553,8 @@ class Binder extends NodeVisitor {
553
553
  // the container's locals; anonymous declarations like type literals go in no table.
554
554
  switch (node.kind) {
555
555
  case 79 /* SyntaxKind.Identifier */:
556
- node.flowNode = this.currentFlowValue();
556
+ if (node instanceof ReferenceIdentifier)
557
+ node.flowNode = this.currentFlowValue();
557
558
  this.checkContextualIdentifier(node);
558
559
  break;
559
560
  case 109 /* SyntaxKind.ThisKeyword */:
@@ -906,7 +907,7 @@ class Binder extends NodeVisitor {
906
907
  symbol.valueDeclaration = this.file;
907
908
  if (name === 'module') {
908
909
  const exportsProperty = this.newSymbol(134217728 /* SymbolFlags.ModuleExports */ | 4 /* SymbolFlags.Property */, 'exports');
909
- exportsProperty.declarations = symbol.declarations;
910
+ copyDeclarations(exportsProperty, symbol);
910
911
  exportsProperty.valueDeclaration = this.file;
911
912
  exportsProperty.parent = symbol;
912
913
  getMembers(symbol).set('exports', exportsProperty);
@@ -1806,7 +1807,7 @@ class Binder extends NodeVisitor {
1806
1807
  const exports = getExports(symbol);
1807
1808
  const existing = exports.get('prototype');
1808
1809
  if (existing !== undefined)
1809
- this.errorOnNode(existing.declarations[0], 478 /* Diagnostics.Duplicate_identifier_0 */, ['prototype']);
1810
+ this.errorOnNode(existing.declaration, 478 /* Diagnostics.Duplicate_identifier_0 */, ['prototype']);
1810
1811
  exports.set('prototype', prototypeSymbol);
1811
1812
  prototypeSymbol.parent = symbol;
1812
1813
  }
@@ -38,6 +38,7 @@ import { getGlobalValueSymbol, getSymbolOfDeclaration, resolveName } from './che
38
38
  import { checkImportCallExpression } from './checker-modules.js';
39
39
  import { checkApplicableSignatureForJsxCallLikeElement, getAttributesOf, getEffectiveJsxArguments, inferJsxTypeArguments, isJsxOpeningLikeElement, resolveJsxOpeningLikeElement, } from './checker-jsx.js';
40
40
  import { isCommonJSRequire, resolveExternalModuleTypeByLiteral } from './checker-javascript.js';
41
+ import { declarationCount, getDeclarations } from './symbol.js';
41
42
  /** The type of an optional chain's expression with the chain's `undefined` removed. */
42
43
  export function getOptionalExpressionType(c, exprType, expression) {
43
44
  if (isExpressionOfOptionalChainRoot(expression))
@@ -1246,10 +1247,10 @@ function reportCallResolutionErrors(c, s, signatures, headMessage) {
1246
1247
  /** Notes when the call would have resolved to the implementation signature of the overloads. */
1247
1248
  function addImplementationSuccessElaboration(c, s, failed, diagnostic) {
1248
1249
  const symbol = failed.declaration !== undefined ? getSymbol(failed.declaration) : undefined;
1249
- if (symbol === undefined || symbol.declarations.length <= 1)
1250
+ if (symbol === undefined || declarationCount(symbol) <= 1)
1250
1251
  return;
1251
1252
  let implementation;
1252
- for (const d of symbol.declarations) {
1253
+ for (const d of getDeclarations(symbol)) {
1253
1254
  if (isFunctionLikeDeclarationKind(d.kind) && nodeIsPresent(getBody(d))) {
1254
1255
  implementation = d;
1255
1256
  break;
@@ -12,6 +12,7 @@ import { getExportSymbolOfValueSymbolIfExported } from './checker-symbols.js';
12
12
  import { getBaseTypes, getDeclaredTypeOfSymbol } from './checker-declared-types.js';
13
13
  import { getPropertyOfType } from './checker-members.js';
14
14
  import { getFunctionFlags } from './checker-utilities.js';
15
+ import { getDeclarations } from './symbol.js';
15
16
  /** Reports a block-scoped variable, class or enum resolved at `errorLocation` before its declaration. */
16
17
  export function checkResolvedBlockScopedVariable(c, resolved, errorLocation) {
17
18
  const result = getExportSymbolOfValueSymbolIfExported(c, resolved);
@@ -22,7 +23,7 @@ export function checkResolvedBlockScopedVariable(c, resolved, errorLocation) {
22
23
  (result.flags & 32 /* SymbolFlags.Class */) !== 0)
23
24
  return;
24
25
  let declaration;
25
- for (const d of result.declarations) {
26
+ for (const d of getDeclarations(result)) {
26
27
  if (isBlockOrCatchScoped(d) || isClassLike(d) || d.kind === 267 /* SyntaxKind.EnumDeclaration */) {
27
28
  declaration = d;
28
29
  break;
@@ -11,7 +11,6 @@ import { getPropertyNameFromType, isBindingPattern, isTypeUsableAsPropertyName }
11
11
  import { checkPropertyAccessibility } from './checker-property-access.js';
12
12
  import { declarationNameToString, getNameOfDeclaration, getSourceFileOfNode, getAssignmentDeclarationKind, getCombinedModifierFlags, getCombinedNodeFlags, isPartOfParameterDeclaration, getRootDeclaration, getDeclarationOfKind, getModifierFlags, getModuleInstanceState, getRangeOfTokenAtPosition, hasSyntacticModifier, isEntityNameExpression, isEnumConst, isExternalModule, isModuleAugmentationExternal, isVariableDeclarationInitializedToRequire, isClassLike, } from './binder-utilities.js';
13
13
  import { Diagnostic } from './diagnostics.js';
14
- import { getSymbolId } from './symbol.js';
15
14
  import { createDiagnosticForNode } from './checker.js';
16
15
  import { getLiteralTypeFromPropertyName, intrinsicTypeKind } from './checker-type-operators.js';
17
16
  import { SimpleTypeMapper, } from './checker-types.js';
@@ -36,6 +35,7 @@ import { checkFunctionOrMethodSymbols } from './checker-overloads.js';
36
35
  import { checkJSDocFullSignature } from './checker-jsdoc.js';
37
36
  import { checkAliasSymbol } from './checker-modules.js';
38
37
  import { checkDecorators } from './checker-decorators.js';
38
+ import { declarationCount, getDeclarations, getSymbolId, } from './symbol.js';
39
39
  // ---- Variables and parameters
40
40
  export function checkVariableStatement(c, node) {
41
41
  checkVariableDeclarationList(c, node.declarationList);
@@ -126,8 +126,8 @@ export function checkVariableLikeDeclaration(c, node) {
126
126
  checkTypeAssignableToAndOptionallyElaborate(c, initType, t, node, initializer);
127
127
  checkUsingDeclarationInitializer(c, node, initializer, initType);
128
128
  }
129
- if (name !== undefined && symbol.declarations.length > 1) {
130
- for (const d of symbol.declarations) {
129
+ if (name !== undefined && declarationCount(symbol) > 1) {
130
+ for (const d of getDeclarations(symbol)) {
131
131
  if (d !== node && isVariableLike(d) && !areDeclarationFlagsIdentical(d, node)) {
132
132
  reportNonIdenticalModifiers(c, name);
133
133
  break;
@@ -552,15 +552,15 @@ export function checkEnumDeclaration(c, node) {
552
552
  if (links.enumChecked)
553
553
  return;
554
554
  links.enumChecked = true;
555
- if (symbol.declarations.length > 1) {
555
+ if (declarationCount(symbol) > 1) {
556
556
  const enumIsConst = isEnumConst(node);
557
- for (const d of symbol.declarations)
557
+ for (const d of getDeclarations(symbol))
558
558
  if (d.kind === 267 /* SyntaxKind.EnumDeclaration */ && isEnumConst(d) !== enumIsConst)
559
559
  c.error(getNameOfDeclaration(d), 637 /* Diagnostics.Enum_declarations_must_all_be_const_or_non_const */);
560
560
  }
561
561
  // Only one declaration of a merged enum may continue automatic numbering from zero.
562
562
  let seenEnumMissingInitialInitializer = false;
563
- for (const d of symbol.declarations) {
563
+ for (const d of getDeclarations(symbol)) {
564
564
  if (d.kind !== 267 /* SyntaxKind.EnumDeclaration */)
565
565
  continue;
566
566
  const members = d.members.nodes;
@@ -606,7 +606,7 @@ export function checkModuleDeclaration(c, node) {
606
606
  // Namespaces of global scripts can merge across files, which a transpiler of one file cannot see.
607
607
  if (c.isolatedModules && getSourceFileOfNode(node).externalModuleIndicator === undefined)
608
608
  c.error(module.name, 229 /* 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 */, c.compilerOptions.verbatimModuleSyntax === true ? 'verbatimModuleSyntax' : 'isolatedModules');
609
- if (symbol.declarations.length > 1) {
609
+ if (declarationCount(symbol) > 1) {
610
610
  const classOrFunction = getFirstNonAmbientClassOrFunctionDeclaration(symbol);
611
611
  if (classOrFunction !== undefined) {
612
612
  if (getSourceFileOfNode(node) !== getSourceFileOfNode(classOrFunction))
@@ -648,7 +648,7 @@ export function isInstantiatedModule(node, preserveConstEnums) {
648
648
  return (state === 2 /* ModuleInstanceState.Instantiated */ || (preserveConstEnums && state === 3 /* ModuleInstanceState.ConstEnumOnly */));
649
649
  }
650
650
  function getFirstNonAmbientClassOrFunctionDeclaration(symbol) {
651
- for (const d of symbol.declarations)
651
+ for (const d of getDeclarations(symbol))
652
652
  if ((d.kind === 264 /* SyntaxKind.ClassDeclaration */ ||
653
653
  (d.kind === 263 /* SyntaxKind.FunctionDeclaration */ && nodeIsPresent(getBody(d)))) &&
654
654
  (d.flags & 8388608 /* NodeFlags.Ambient */) === 0)
@@ -719,7 +719,7 @@ export function checkExternalModuleExports(c, node) {
719
719
  if (id === "\uFFFEexport" /* InternalSymbolName.ExportStar */ || (symbol.flags & (1920 /* SymbolFlags.Namespace */ | 384 /* SymbolFlags.Enum */)) !== 0)
720
720
  continue;
721
721
  let count = 0;
722
- for (const d of symbol.declarations)
722
+ for (const d of getDeclarations(symbol))
723
723
  if (isNotOverload(d) && !isAccessorDeclaration(d) && d.kind !== 265 /* SyntaxKind.InterfaceDeclaration */)
724
724
  count++;
725
725
  // A type alias may merge with one value.
@@ -728,12 +728,12 @@ export function checkExternalModuleExports(c, node) {
728
728
  if (count <= 1)
729
729
  continue;
730
730
  let allExportsProperties = true;
731
- for (const d of symbol.declarations)
731
+ for (const d of getDeclarations(symbol))
732
732
  if (getAssignmentDeclarationKind(d) !== 2 /* JSDeclarationKind.ExportsProperty */)
733
733
  allExportsProperties = false;
734
734
  if (allExportsProperties)
735
735
  continue;
736
- for (const d of symbol.declarations)
736
+ for (const d of getDeclarations(symbol))
737
737
  if (isNotOverload(d))
738
738
  c.error(d, 501 /* Diagnostics.Cannot_redeclare_exported_variable_0 */, id);
739
739
  }
@@ -780,7 +780,7 @@ export function checkExportsOnMergedDeclarations(c, node) {
780
780
  let exported = 0 /* DeclarationSpaces.None */;
781
781
  let nonExported = 0 /* DeclarationSpaces.None */;
782
782
  let defaultExported = 0 /* DeclarationSpaces.None */;
783
- for (const d of symbol.declarations) {
783
+ for (const d of getDeclarations(symbol)) {
784
784
  const spaces = getDeclarationSpaces(c, d);
785
785
  const flags = getEffectiveDeclarationFlags(d, 32 /* ModifierFlags.Export */ | 2048 /* ModifierFlags.Default */);
786
786
  if ((flags & 32 /* ModifierFlags.Export */) !== 0) {
@@ -797,7 +797,7 @@ export function checkExportsOnMergedDeclarations(c, node) {
797
797
  const commonForDefaultAndNonDefault = defaultExported & nonDefaultExported;
798
798
  if (commonForExportsAndLocals === 0 && commonForDefaultAndNonDefault === 0)
799
799
  return;
800
- for (const d of symbol.declarations) {
800
+ for (const d of getDeclarations(symbol)) {
801
801
  const spaces = getDeclarationSpaces(c, d);
802
802
  const name = getNameOfDeclaration(d);
803
803
  const text = declarationNameToString(getSourceFileOfNode(d), name);
@@ -847,7 +847,7 @@ function getAliasDeclarationSpaces(c, node) {
847
847
  if (symbol === undefined)
848
848
  return 0 /* DeclarationSpaces.None */;
849
849
  let result = 0 /* DeclarationSpaces.None */;
850
- for (const d of resolveAlias(c, symbol).declarations)
850
+ for (const d of getDeclarations(resolveAlias(c, symbol)))
851
851
  result |= getDeclarationSpaces(c, d);
852
852
  return result;
853
853
  }
@@ -1,10 +1,10 @@
1
1
  import { type Node } from './ast.js';
2
2
  import { getSourceFileOfNode } from './binder-utilities.js';
3
- import { type Symbol } from './symbol.js';
4
3
  import { SyntaxKind } from './syntax-kind.js';
5
4
  import { type Checker } from './checker.js';
6
5
  import { InterfaceType, type LiteralType, type Signature, type Type, TypeParameter } from './checker-types.js';
7
6
  import { getFirstIdentifier, getMergedSymbol, getParentOfSymbol } from './checker-symbols.js';
7
+ import { type Symbol } from './symbol.js';
8
8
  export { getParentOfSymbol };
9
9
  export declare function getDeclaredTypeOfSymbol(c: Checker, symbol: Symbol): Type;
10
10
  export declare function tryGetDeclaredTypeOfSymbol(c: Checker, symbol: Symbol): Type | undefined;
@@ -20,6 +20,7 @@ import { getIndexedAccessType, isGenericMappedType } from './checker-type-operat
20
20
  import { getSignatureInstantiation } from './checker-signatures.js';
21
21
  import { evaluateEnumMember } from './checker-evaluator.js';
22
22
  import { checkTypeAssignableTo, isTypeIdenticalTo } from './relations.js';
23
+ import { getDeclarations } from './symbol.js';
23
24
  export { getParentOfSymbol };
24
25
  export function getDeclaredTypeOfSymbol(c, symbol) {
25
26
  return tryGetDeclaredTypeOfSymbol(c, symbol) ?? c.errorType;
@@ -82,7 +83,7 @@ export function getDeclaredTypeOfClassOrInterface(c, symbol) {
82
83
  return links.declaredType;
83
84
  }
84
85
  function isThislessInterface(c, symbol) {
85
- for (const declaration of symbol.declarations) {
86
+ for (const declaration of getDeclarations(symbol)) {
86
87
  if (declaration.kind !== 265 /* SyntaxKind.InterfaceDeclaration */)
87
88
  continue;
88
89
  if ((declaration.flags & 128 /* NodeFlags.ContainsThis */) !== 0)
@@ -127,7 +128,7 @@ export function getExtendsHeritageClauseElement(node) {
127
128
  return elements.length !== 0 ? elements[0] : undefined;
128
129
  }
129
130
  export function getClassLikeDeclarationOfSymbol(symbol) {
130
- for (const d of symbol.declarations)
131
+ for (const d of getDeclarations(symbol))
131
132
  if (d.kind === 264 /* SyntaxKind.ClassDeclaration */ || d.kind === 232 /* SyntaxKind.ClassExpression */)
132
133
  return d;
133
134
  return undefined;
@@ -136,7 +137,7 @@ function getOuterTypeParametersOfClassOrInterface(c, symbol) {
136
137
  let declaration = symbol.valueDeclaration;
137
138
  if ((symbol.flags & (32 /* SymbolFlags.Class */ | 16 /* SymbolFlags.Function */)) === 0) {
138
139
  declaration = undefined;
139
- for (const d of symbol.declarations) {
140
+ for (const d of getDeclarations(symbol)) {
140
141
  if (d.kind === 265 /* SyntaxKind.InterfaceDeclaration */) {
141
142
  declaration = d;
142
143
  break;
@@ -227,7 +228,7 @@ export function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(c, symbol) {
227
228
  return appendLocalTypeParameters(c, [], symbol);
228
229
  }
229
230
  function appendLocalTypeParameters(c, types, symbol) {
230
- for (const node of symbol.declarations) {
231
+ for (const node of getDeclarations(symbol)) {
231
232
  if (node.kind === 265 /* SyntaxKind.InterfaceDeclaration */ ||
232
233
  node.kind === 264 /* SyntaxKind.ClassDeclaration */ ||
233
234
  node.kind === 232 /* SyntaxKind.ClassExpression */ ||
@@ -259,7 +260,7 @@ export function getDeclaredTypeOfTypeAlias(c, symbol) {
259
260
  if (!pushTypeResolution(c, symbol, 2 /* TypeSystemPropertyName.DeclaredType */))
260
261
  return c.errorType;
261
262
  let declaration;
262
- for (const d of symbol.declarations)
263
+ for (const d of getDeclarations(symbol))
263
264
  if (d.kind === 266 /* SyntaxKind.TypeAliasDeclaration */ || d.kind === 345 /* SyntaxKind.JSTypeAliasDeclaration */) {
264
265
  declaration = d;
265
266
  break;
@@ -292,7 +293,7 @@ export function getDeclaredTypeOfEnum(c, symbol) {
292
293
  if (links.declaredType !== undefined)
293
294
  return links.declaredType;
294
295
  const memberTypes = [];
295
- for (const declaration of symbol.declarations) {
296
+ for (const declaration of getDeclarations(symbol)) {
296
297
  if (declaration.kind !== 267 /* SyntaxKind.EnumDeclaration */)
297
298
  continue;
298
299
  for (const member of declaration.members.nodes) {
@@ -454,7 +455,7 @@ export function getBaseTypes(c, t) {
454
455
  resolveBaseTypesOfInterface(c, t);
455
456
  }
456
457
  if (!popTypeResolution(c))
457
- for (const declaration of t.symbol.declarations)
458
+ for (const declaration of getDeclarations(t.symbol))
458
459
  if (declaration.kind === 264 /* SyntaxKind.ClassDeclaration */ || declaration.kind === 265 /* SyntaxKind.InterfaceDeclaration */)
459
460
  reportCircularBaseType(c, declaration, t);
460
461
  // Circular defaults may leave members partially resolved; reset them.
@@ -528,7 +529,7 @@ function isInJS(node) {
528
529
  return (node.flags & 65536 /* NodeFlags.JavaScriptFile */) !== 0;
529
530
  }
530
531
  function resolveBaseTypesOfInterface(c, t) {
531
- for (const declaration of t.symbol.declarations) {
532
+ for (const declaration of getDeclarations(t.symbol)) {
532
533
  if (declaration.kind !== 265 /* SyntaxKind.InterfaceDeclaration */)
533
534
  continue;
534
535
  for (const node of getExtendsHeritageClauseElements(declaration)) {
@@ -666,7 +667,7 @@ export function hasNonCircularBaseConstraint(c, t) {
666
667
  }
667
668
  export function getConstraintDeclaration(t) {
668
669
  if (t.symbol !== undefined)
669
- for (const d of t.symbol.declarations)
670
+ for (const d of getDeclarations(t.symbol))
670
671
  if (d.kind === 169 /* SyntaxKind.TypeParameter */) {
671
672
  const constraint = d.constraint;
672
673
  if (constraint !== undefined)
@@ -723,7 +724,7 @@ export function getResolvedTypeParameterDefault(c, t) {
723
724
  side.resolvedDefaultType = c.resolvingDefaultType;
724
725
  let defaultType = c.noConstraintType;
725
726
  if (t.symbol !== undefined)
726
- for (const d of t.symbol.declarations)
727
+ for (const d of getDeclarations(t.symbol))
727
728
  if (d.kind === 169 /* SyntaxKind.TypeParameter */) {
728
729
  const node = d.defaultType;
729
730
  if (node !== undefined) {
@@ -753,7 +754,7 @@ export function getMinTypeArgumentCount(c, typeParameters) {
753
754
  function hasTypeParameterDefault(t) {
754
755
  if (t.symbol === undefined)
755
756
  return false;
756
- for (const d of t.symbol.declarations)
757
+ for (const d of getDeclarations(t.symbol))
757
758
  if (d.kind === 169 /* SyntaxKind.TypeParameter */ && d.defaultType !== undefined)
758
759
  return true;
759
760
  return false;
@@ -5,7 +5,6 @@ import { checkDeprecatedSignature } from './checker-deprecation.js';
5
5
  import { FunctionTypeNode, KeywordTypeNode, NodeList, getBody, getDotDotDotToken, getModifiers, getName, getParameters, getText, getType, getInitializer, getMembers, } from './ast.js';
6
6
  import { canHaveDecorators } from './ast-utilities.js';
7
7
  import { getDeclarationOfKind, getSourceFileOfNode, getSourceTextOfNode, hasStaticModifier, hasSyntacticModifier, isClassLike, isStatic, isPrivateIdentifierClassElementDeclaration, isAutoAccessorPropertyDeclaration, } from './binder-utilities.js';
8
- import { getSymbolId } from './symbol.js';
9
8
  import { createDiagnosticForNode } from './checker.js';
10
9
  import { ModuleKind, getEmitModuleKind, ScriptTarget, getUseDefineForClassFields } from './options.js';
11
10
  import { getFirstConstructorWithBody, getRestParameterElementType, classElementOrClassElementParameterIsDecorated, classOrConstructorParameterIsDecorated, } from './transformers/decorator-utilities.js';
@@ -20,6 +19,7 @@ import { getOrCreateTypeFromSignature, getParameterCount, getReturnTypeOfSignatu
20
19
  import { checkTypeAssignableTo } from './relations.js';
21
20
  import { getResolvedSignature } from './checker-calls.js';
22
21
  import { getGlobalClassAccessorDecoratorContextType, getGlobalClassAccessorDecoratorResultType, getGlobalClassAccessorDecoratorTargetType, getGlobalClassDecoratorContextType, getGlobalClassFieldDecoratorContextType, getGlobalClassGetterDecoratorContextType, getGlobalClassMethodDecoratorContextType, getGlobalClassSetterDecoratorContextType, getGlobalTypedPropertyDescriptorType, } from './checker-globals.js';
22
+ import { getDeclarations, getSymbolId } from './symbol.js';
23
23
  // ---- Checks
24
24
  /** Resolves the decorators of `node` as calls and checks their return types. */
25
25
  export function checkDecorators(c, node) {
@@ -160,10 +160,10 @@ function checkMetadataTypeImport(c, typeNode) {
160
160
  const rootSymbol = resolveName(c, rootName, getText(rootName), meaning, undefined, true, false);
161
161
  if (rootSymbol === undefined || (rootSymbol.flags & 2097152 /* SymbolFlags.Alias */) === 0 || symbolIsValue(c, rootSymbol))
162
162
  return;
163
- if (rootSymbol.declarations.some(isTypeOnlyImportOrExportDeclaration))
163
+ if (getDeclarations(rootSymbol).some(isTypeOnlyImportOrExportDeclaration))
164
164
  return;
165
165
  const diagnostic = c.error(typeName, 221 /* Diagnostics.A_type_referenced_in_a_decorated_signature_must_be_imported_with_import_type_or_a_namespace_import_when_isolatedModules_and_emitDecoratorMetadata_are_enabled */);
166
- const aliasDeclaration = rootSymbol.declarations.find(isAliasSymbolDeclaration);
166
+ const aliasDeclaration = getDeclarations(rootSymbol).find(isAliasSymbolDeclaration);
167
167
  if (aliasDeclaration !== undefined)
168
168
  diagnostic.addRelatedInfo(createDiagnosticForNode(aliasDeclaration, 305 /* Diagnostics.X_0_was_imported_here */, [getText(rootName)]));
169
169
  }