tsc-ts 0.0.5 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. package/README.md +1 -1
  2. package/dist/api/compiler/ast.d.ts +67 -27
  3. package/dist/api/compiler/ast.js +156 -55
  4. package/dist/api/compiler/binder-utilities.js +4 -3
  5. package/dist/api/compiler/binder.js +14 -13
  6. package/dist/api/compiler/checker-calls.js +7 -6
  7. package/dist/api/compiler/checker-contextual.js +1 -1
  8. package/dist/api/compiler/checker-declaration-order.js +2 -1
  9. package/dist/api/compiler/checker-declarations.js +14 -14
  10. package/dist/api/compiler/checker-declared-types.d.ts +1 -1
  11. package/dist/api/compiler/checker-declared-types.js +12 -11
  12. package/dist/api/compiler/checker-decorators.js +3 -3
  13. package/dist/api/compiler/checker-deprecation.js +17 -18
  14. package/dist/api/compiler/checker-destructuring.d.ts +1 -1
  15. package/dist/api/compiler/checker-destructuring.js +3 -3
  16. package/dist/api/compiler/checker-elaboration.js +8 -7
  17. package/dist/api/compiler/checker-emit-helpers.d.ts +2 -1
  18. package/dist/api/compiler/checker-emit-helpers.js +5 -4
  19. package/dist/api/compiler/checker-emit-resolver.d.ts +1 -1
  20. package/dist/api/compiler/checker-emit-resolver.js +5 -4
  21. package/dist/api/compiler/checker-grammar.js +23 -9
  22. package/dist/api/compiler/checker-heritage.d.ts +1 -1
  23. package/dist/api/compiler/checker-heritage.js +14 -13
  24. package/dist/api/compiler/checker-inference.d.ts +21 -11
  25. package/dist/api/compiler/checker-inference.js +57 -34
  26. package/dist/api/compiler/checker-javascript.d.ts +1 -1
  27. package/dist/api/compiler/checker-javascript.js +5 -4
  28. package/dist/api/compiler/checker-jsx.d.ts +1 -1
  29. package/dist/api/compiler/checker-jsx.js +4 -4
  30. package/dist/api/compiler/checker-literals.js +2 -2
  31. package/dist/api/compiler/checker-members.d.ts +32 -3
  32. package/dist/api/compiler/checker-members.js +240 -53
  33. package/dist/api/compiler/checker-modules.d.ts +15 -1
  34. package/dist/api/compiler/checker-modules.js +86 -14
  35. package/dist/api/compiler/checker-object-literals.d.ts +1 -1
  36. package/dist/api/compiler/checker-object-literals.js +11 -7
  37. package/dist/api/compiler/checker-overloads.d.ts +1 -1
  38. package/dist/api/compiler/checker-overloads.js +4 -3
  39. package/dist/api/compiler/checker-property-access.d.ts +1 -1
  40. package/dist/api/compiler/checker-property-access.js +2 -2
  41. package/dist/api/compiler/checker-services.js +2 -2
  42. package/dist/api/compiler/checker-signatures.d.ts +1 -1
  43. package/dist/api/compiler/checker-signatures.js +9 -8
  44. package/dist/api/compiler/checker-symbol-types.d.ts +2 -18
  45. package/dist/api/compiler/checker-symbol-types.js +22 -952
  46. package/dist/api/compiler/checker-symbols.d.ts +2 -2
  47. package/dist/api/compiler/checker-symbols.js +29 -27
  48. package/dist/api/compiler/checker-type-factory.d.ts +2 -2
  49. package/dist/api/compiler/checker-type-factory.js +57 -16
  50. package/dist/api/compiler/checker-type-nodes.d.ts +1 -1
  51. package/dist/api/compiler/checker-type-nodes.js +2 -2
  52. package/dist/api/compiler/checker-type-operators.d.ts +1 -1
  53. package/dist/api/compiler/checker-type-operators.js +5 -5
  54. package/dist/api/compiler/checker-types.d.ts +73 -7
  55. package/dist/api/compiler/checker-types.js +220 -43
  56. package/dist/api/compiler/checker-unused.d.ts +1 -1
  57. package/dist/api/compiler/checker-unused.js +3 -3
  58. package/dist/api/compiler/checker.d.ts +45 -8
  59. package/dist/api/compiler/checker.js +46 -9
  60. package/dist/api/compiler/diagnostics.d.ts +2 -8
  61. package/dist/api/compiler/diagnostics.js +13 -45
  62. package/dist/api/compiler/file-include.d.ts +35 -8
  63. package/dist/api/compiler/file-include.js +81 -18
  64. package/dist/api/compiler/file-loader.d.ts +33 -4
  65. package/dist/api/compiler/file-loader.js +90 -24
  66. package/dist/api/compiler/instantiation.d.ts +1 -1
  67. package/dist/api/compiler/instantiation.js +86 -50
  68. package/dist/api/compiler/link-tables.d.ts +69 -0
  69. package/dist/api/compiler/link-tables.js +236 -0
  70. package/dist/api/compiler/name-resolver.js +3 -3
  71. package/dist/api/compiler/node-builder-names.d.ts +1 -1
  72. package/dist/api/compiler/node-builder-names.js +12 -12
  73. package/dist/api/compiler/node-builder-pseudo.d.ts +1 -1
  74. package/dist/api/compiler/node-builder-pseudo.js +2 -1
  75. package/dist/api/compiler/node-builder.d.ts +1 -1
  76. package/dist/api/compiler/node-builder.js +16 -16
  77. package/dist/api/compiler/parallel-parse.d.ts +2 -0
  78. package/dist/api/compiler/parallel-parse.js +7 -1
  79. package/dist/api/compiler/parser.d.ts +33 -16
  80. package/dist/api/compiler/parser.js +127 -98
  81. package/dist/api/compiler/printer/emit-context.d.ts +5 -2
  82. package/dist/api/compiler/printer/emit-context.js +19 -13
  83. package/dist/api/compiler/printer/factory-base.js +8 -8
  84. package/dist/api/compiler/printer/factory.js +4 -4
  85. package/dist/api/compiler/printer/printer.js +6 -6
  86. package/dist/api/compiler/program-checker.d.ts +5 -0
  87. package/dist/api/compiler/program-checker.js +14 -1
  88. package/dist/api/compiler/program.js +9 -1
  89. package/dist/api/compiler/relations.d.ts +1 -1
  90. package/dist/api/compiler/relations.js +18 -13
  91. package/dist/api/compiler/reparser.js +13 -5
  92. package/dist/api/compiler/symbol-accessibility.d.ts +1 -1
  93. package/dist/api/compiler/symbol-accessibility.js +123 -26
  94. package/dist/api/compiler/symbol.d.ts +45 -3
  95. package/dist/api/compiler/symbol.js +121 -10
  96. package/dist/api/compiler/transformers/alias-references.d.ts +1 -1
  97. package/dist/api/compiler/transformers/alias-references.js +2 -1
  98. package/dist/api/compiler/transformers/class-fields.js +3 -3
  99. package/dist/api/compiler/transformers/commonjs-module.js +3 -3
  100. package/dist/api/compiler/transformers/declarations-diagnostics.js +2 -1
  101. package/dist/api/compiler/transformers/declarations-pseudo.js +6 -4
  102. package/dist/api/compiler/transformers/declarations-syntactic.d.ts +1 -1
  103. package/dist/api/compiler/transformers/declarations-syntactic.js +9 -9
  104. package/dist/api/compiler/transformers/declarations-tracker.d.ts +1 -1
  105. package/dist/api/compiler/transformers/declarations-tracker.js +3 -2
  106. package/dist/api/compiler/transformers/declarations.js +6 -5
  107. package/dist/api/compiler/transformers/module.js +2 -2
  108. package/dist/api/compiler/transformers/optional-chain.js +3 -3
  109. package/dist/api/compiler/transformers/reference-resolver.d.ts +2 -1
  110. package/dist/api/compiler/transformers/reference-resolver.js +26 -24
  111. package/dist/api/compiler/transformers/subtree-facts.d.ts +1 -0
  112. package/dist/api/compiler/transformers/subtree-facts.js +9 -7
  113. package/dist/api/compiler/transformers/syntax-facts.d.ts +1 -0
  114. package/dist/api/compiler/transformers/syntax-facts.js +9 -5
  115. package/dist/api/compiler/transformers/tagged-template.js +2 -2
  116. package/dist/api/compiler/transformers/type-eraser.js +2 -2
  117. package/dist/api/compiler/transformers/type-serialization.js +12 -12
  118. package/dist/api/compiler/transformers/visitor-base.js +3 -3
  119. package/dist/api/compiler/tsconfig.js +2 -2
  120. package/package.json +9 -9
  121. package/src/compiler/ast.ts +211 -78
  122. package/src/compiler/binder-utilities.ts +4 -3
  123. package/src/compiler/binder.ts +26 -16
  124. package/src/compiler/checker-calls.ts +8 -6
  125. package/src/compiler/checker-contextual.ts +1 -1
  126. package/src/compiler/checker-declaration-order.ts +2 -2
  127. package/src/compiler/checker-declarations.ts +21 -14
  128. package/src/compiler/checker-declared-types.ts +12 -12
  129. package/src/compiler/checker-decorators.ts +3 -3
  130. package/src/compiler/checker-deprecation.ts +17 -21
  131. package/src/compiler/checker-destructuring.ts +3 -3
  132. package/src/compiler/checker-elaboration.ts +8 -8
  133. package/src/compiler/checker-emit-helpers.ts +5 -4
  134. package/src/compiler/checker-emit-resolver.ts +5 -5
  135. package/src/compiler/checker-grammar.ts +22 -8
  136. package/src/compiler/checker-heritage.ts +21 -14
  137. package/src/compiler/checker-inference.ts +66 -34
  138. package/src/compiler/checker-javascript.ts +5 -5
  139. package/src/compiler/checker-jsx.ts +12 -8
  140. package/src/compiler/checker-literals.ts +2 -2
  141. package/src/compiler/checker-members.ts +255 -47
  142. package/src/compiler/checker-modules.ts +115 -14
  143. package/src/compiler/checker-object-literals.ts +22 -6
  144. package/src/compiler/checker-overloads.ts +6 -6
  145. package/src/compiler/checker-property-access.ts +2 -2
  146. package/src/compiler/checker-services.ts +2 -2
  147. package/src/compiler/checker-signatures.ts +9 -9
  148. package/src/compiler/checker-symbol-types.ts +20 -940
  149. package/src/compiler/checker-symbols.ts +42 -35
  150. package/src/compiler/checker-type-factory.ts +53 -16
  151. package/src/compiler/checker-type-nodes.ts +2 -2
  152. package/src/compiler/checker-type-operators.ts +13 -5
  153. package/src/compiler/checker-types.ts +223 -43
  154. package/src/compiler/checker-unused.ts +3 -3
  155. package/src/compiler/checker.ts +50 -9
  156. package/src/compiler/decoder.ts +5 -4
  157. package/src/compiler/diagnostics.ts +14 -48
  158. package/src/compiler/encoder.ts +10 -5
  159. package/src/compiler/file-include.ts +85 -17
  160. package/src/compiler/file-loader.ts +104 -35
  161. package/src/compiler/incremental.ts +39 -5
  162. package/src/compiler/instantiation.ts +99 -55
  163. package/src/compiler/link-tables.ts +245 -0
  164. package/src/compiler/name-resolver.ts +3 -3
  165. package/src/compiler/node-builder-names.ts +21 -19
  166. package/src/compiler/node-builder-pseudo.ts +2 -2
  167. package/src/compiler/node-builder.ts +24 -16
  168. package/src/compiler/parallel-check.ts +11 -8
  169. package/src/compiler/parallel-parse.ts +8 -1
  170. package/src/compiler/parse-thread.ts +0 -4
  171. package/src/compiler/parser.ts +173 -93
  172. package/src/compiler/printer/emit-context.ts +20 -15
  173. package/src/compiler/printer/factory-base.ts +14 -7
  174. package/src/compiler/printer/factory.ts +5 -3
  175. package/src/compiler/printer/printer.ts +8 -6
  176. package/src/compiler/program-checker.ts +12 -1
  177. package/src/compiler/program.ts +8 -1
  178. package/src/compiler/relations.ts +20 -12
  179. package/src/compiler/reparser.ts +14 -4
  180. package/src/compiler/symbol-accessibility.ts +120 -25
  181. package/src/compiler/symbol.ts +127 -9
  182. package/src/compiler/transformers/alias-references.ts +2 -2
  183. package/src/compiler/transformers/class-fields.ts +12 -2
  184. package/src/compiler/transformers/commonjs-module.ts +3 -2
  185. package/src/compiler/transformers/declarations-diagnostics.ts +2 -1
  186. package/src/compiler/transformers/declarations-pseudo.ts +9 -5
  187. package/src/compiler/transformers/declarations-syntactic.ts +17 -9
  188. package/src/compiler/transformers/declarations-tracker.ts +3 -3
  189. package/src/compiler/transformers/declarations.ts +7 -7
  190. package/src/compiler/transformers/module.ts +2 -1
  191. package/src/compiler/transformers/optional-chain.ts +5 -2
  192. package/src/compiler/transformers/reference-resolver.ts +37 -25
  193. package/src/compiler/transformers/subtree-facts.ts +15 -6
  194. package/src/compiler/transformers/syntax-facts.ts +10 -5
  195. package/src/compiler/transformers/tagged-template.ts +2 -2
  196. package/src/compiler/transformers/type-eraser.ts +2 -1
  197. package/src/compiler/transformers/type-serialization.ts +12 -12
  198. package/src/compiler/transformers/visitor-base.ts +10 -5
  199. package/src/compiler/tsc-build.ts +17 -13
  200. package/src/compiler/tsc-cli.ts +9 -6
  201. package/src/compiler/tsc-compile.ts +16 -7
  202. package/src/compiler/tsc-watch.ts +94 -26
  203. package/src/compiler/tsconfig.ts +2 -1
@@ -13,9 +13,9 @@ import { ModuleSpecifierHost, ModuleSpecifierPreferences, countPathComponents, g
13
13
  import { ModuleKind, ModuleResolutionKind, getModuleResolutionKind } from './options.js';
14
14
  import { isExternalModuleAugmentation } from './transformers/declarations-syntactic.js';
15
15
  import { isIdentifierText } from './scanner.js';
16
- import { escapeInternalSymbolName, getSymbolId, } from './symbol.js';
17
16
  import { getAccessibleSymbolChain, getAliasForSymbolInContainer, getContainersOfSymbol, getFileSymbolIfFileSymbolExportEqualsContainer, getQualifiedLeftMeaning, getSymbolIfSameReference, hasNonGlobalAugmentationExternalModuleDeclaration, needsQualification, } from './symbol-accessibility.js';
18
17
  import { classifyPropertyName, isNumericLiteralName } from './node-builder.js';
18
+ import { declarationCount, escapeInternalSymbolName, getDeclarations, getSymbolId, } from './symbol.js';
19
19
  // ---- Symbol chains
20
20
  /** The chain of symbols naming `symbol`, reported to the tracker. */
21
21
  export function lookupSymbolChain(b, symbol, meaning, yieldModuleSymbol) {
@@ -207,7 +207,7 @@ function createAccessFromSymbolChain(b, chain, index, stopper, overrideTypeArgum
207
207
  }
208
208
  if (symbolName.length === 0) {
209
209
  let name = undefined;
210
- for (const d of symbol.declarations) {
210
+ for (const d of getDeclarations(symbol)) {
211
211
  name = getNameOfDeclaration(d);
212
212
  if (name !== undefined)
213
213
  break;
@@ -490,13 +490,13 @@ export function getNameOfSymbolAsWritten(b, symbol) {
490
490
  (b.flags & 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */) === 0 &&
491
491
  // Not the first part of an entity name, synthesized, or from another binding context.
492
492
  ((b.flags & 16777216 /* NodeBuilderFlags.InInitialEntityName */) === 0 ||
493
- symbol.declarations.length === 0 ||
493
+ declarationCount(symbol) === 0 ||
494
494
  (b.enclosingDeclaration !== undefined &&
495
- findDefaultBindingContext(symbol.declarations[0]) !== findDefaultBindingContext(b.enclosingDeclaration))))
495
+ findDefaultBindingContext(symbol.declaration) !== findDefaultBindingContext(b.enclosingDeclaration))))
496
496
  return 'default';
497
- if (symbol.declarations.length > 0) {
497
+ if (declarationCount(symbol) > 0) {
498
498
  let name = undefined;
499
- for (const d of symbol.declarations) {
499
+ for (const d of getDeclarations(symbol)) {
500
500
  name = getNameOfDeclaration(d);
501
501
  if (name !== undefined)
502
502
  break;
@@ -512,7 +512,7 @@ export function getNameOfSymbolAsWritten(b, symbol) {
512
512
  }
513
513
  return declarationNameToString(getSourceFileOfNode(name), name);
514
514
  }
515
- const declaration = symbol.declarations[0];
515
+ const declaration = symbol.declaration;
516
516
  const parent = declaration.parent;
517
517
  if (parent !== undefined && parent.kind === 261 /* SyntaxKind.VariableDeclaration */) {
518
518
  const parentName = getName(parent);
@@ -556,7 +556,7 @@ export function getPropertyNameNodeForSymbol(b, symbol) {
556
556
  if (declarationName !== undefined && declarationName.kind === 80 /* SyntaxKind.PrivateIdentifier */)
557
557
  return b.cloneSynthesized(declarationName);
558
558
  }
559
- const declarations = symbol.declarations;
559
+ const declarations = getDeclarations(symbol);
560
560
  let stringNamed = declarations.length !== 0;
561
561
  for (const d of declarations)
562
562
  if (!isStringNamed(b, d)) {
@@ -622,7 +622,7 @@ export function getSpecifierForModuleSymbol(b, symbol, overrideImportMode) {
622
622
  const c = b.c;
623
623
  let file = asSourceFile(getDeclarationOfKind(symbol, 307 /* SyntaxKind.SourceFile */));
624
624
  if (file === undefined)
625
- for (const d of symbol.declarations) {
625
+ for (const d of getDeclarations(symbol)) {
626
626
  const equivalent = getFileSymbolIfFileSymbolExportEqualsContainer(c, d, symbol);
627
627
  if (equivalent !== undefined) {
628
628
  file = asSourceFile(getDeclarationOfKind(equivalent, 307 /* SyntaxKind.SourceFile */));
@@ -684,14 +684,14 @@ function getModuleSpecifierHost(c) {
684
684
  }
685
685
  /** The name of an ambient module declaring `moduleSymbol`, or of the one whose `export =` it is, else `''`. */
686
686
  function tryGetModuleNameFromAmbientModule(c, moduleSymbol) {
687
- for (const d of moduleSymbol.declarations) {
687
+ for (const d of getDeclarations(moduleSymbol)) {
688
688
  const name = isModuleWithStringLiteralName(d) ? getName(d) : undefined;
689
689
  if (name !== undefined && (!isModuleAugmentationExternal(d) || !isExternalModuleNameRelative(getText(name))))
690
690
  return getText(name);
691
691
  }
692
692
  // A namespace exported with `export =` from an ambient module: `import { c } from "m"` names
693
693
  // `ns.c` for `declare module "m" { namespace ns { class c {} } export = ns; }`.
694
- for (const d of moduleSymbol.declarations) {
694
+ for (const d of getDeclarations(moduleSymbol)) {
695
695
  if (d.kind !== 268 /* SyntaxKind.ModuleDeclaration */)
696
696
  continue;
697
697
  let container = d;
@@ -845,7 +845,7 @@ function asSourceFile(node) {
845
845
  function getSourceFileOfModule(symbol) {
846
846
  let d = symbol.valueDeclaration;
847
847
  if (d === undefined)
848
- for (const declaration of symbol.declarations)
848
+ for (const declaration of getDeclarations(symbol))
849
849
  if (!isExternalModuleAugmentation(declaration) && !isGlobalScopeAugmentation(declaration)) {
850
850
  d = declaration;
851
851
  break;
@@ -2,8 +2,8 @@ import { type Node } from './ast.js';
2
2
  import type { Checker } from './checker.js';
3
3
  import { type Type, type TypePredicate } from './checker-types.js';
4
4
  import { type NodeBuilder } from './node-builder.js';
5
- import { type Symbol } from './symbol.js';
6
5
  import { PseudoChecker, type PseudoType } from './transformers/declarations-pseudo.js';
6
+ import { type Symbol } from './symbol.js';
7
7
  /** A pseudochecker for declaration emit with the checker. */
8
8
  export declare function newPseudoChecker(c: Checker): PseudoChecker;
9
9
  export declare function containsNonMissingUndefinedType(c: Checker, t: Type): boolean;
@@ -19,6 +19,7 @@ import { tryReuseExistingNode } from './node-builder-reuse.js';
19
19
  import { compareTypesIdentical } from './relations.js';
20
20
  import { DirectType, InferredType, PseudoChecker, isInConstContext, } from './transformers/declarations-pseudo.js';
21
21
  import { tryGetTextOfPropertyName } from './transformers/declarations-syntactic.js';
22
+ import { declarationCount } from './symbol.js';
22
23
  /** Resolves no names: `undefined` in an expression is the undefined value, as tsgo's pseudochecker assumes. */
23
24
  class NoNames extends NameResolver {
24
25
  resolve(_location, _name, _meaning, _nameNotFoundMessage, _isUse, _excludeGlobals) {
@@ -397,7 +398,7 @@ export function pseudoTypeEquivalentToType(b, t, type_, isOptionalAnnotated, rep
397
398
  // Accessor pairs are two members but one property.
398
399
  let targetDeclCount = 0;
399
400
  for (const prop of targetProps)
400
- targetDeclCount += prop.declarations.length;
401
+ targetDeclCount += declarationCount(prop);
401
402
  if (pt.members.length !== targetDeclCount)
402
403
  return false;
403
404
  for (const e of pt.members) {
@@ -3,10 +3,10 @@ import { type Checker } from './checker.js';
3
3
  import { ElementFlags, type IndexInfo, Signature, type Type, type TypeMapper, type TypePredicate } from './checker-types.js';
4
4
  import { EmitContext } from './printer/emit-context.js';
5
5
  import type { NodeFactory } from './printer/factory.js';
6
- import { type Symbol, SymbolFlags } from './symbol.js';
7
6
  import { SyntaxKind } from './syntax-kind.js';
8
7
  import { NodeBuilderFlags, NodeBuilderInternalFlags, SymbolAccessibilityResult, SymbolTracker } from './transformers/declarations-resolver.js';
9
8
  import { type PseudoChecker } from './transformers/declarations-pseudo.js';
9
+ import { type Symbol, SymbolFlags } from './symbol.js';
10
10
  /** A symbol the builder named, kept with a cached result so it can be tracked again. */
11
11
  export declare class TrackedSymbol {
12
12
  readonly symbol: Symbol;
@@ -30,7 +30,6 @@ import { Printer, PrinterOptions } from './printer/printer.js';
30
30
  import { TextWriter } from './printer/text-writer.js';
31
31
  import { isTypeIdenticalTo } from './relations.js';
32
32
  import { isIdentifierText } from './scanner.js';
33
- import { getSymbolId } from './symbol.js';
34
33
  import { SymbolAccessibilityResult, SymbolTracker, accessible, } from './transformers/declarations-resolver.js';
35
34
  import { getMeaningOfEntityNameReference } from './transformers/declarations-syntactic.js';
36
35
  import { formatUnionTypes, symbolToString } from './type-printer.js';
@@ -39,6 +38,7 @@ import { getPropertyNameNodeForSymbol, symbolToEntityNameNode, symbolToExpressio
39
38
  import { tryReuseExistingNode } from './node-builder-reuse.js';
40
39
  import { containsNonMissingUndefinedType, hasInferredTypeKind, hasQuestionToken, isAccessorKind, pseudoReturnTypeMatchesPredicate, pseudoTypeEquivalentToType, pseudoTypeToNodeWithCheckerFallback, pseudoTypeToType, newPseudoChecker, requiresAddingImplicitUndefinedForDeclaration, } from './node-builder-pseudo.js';
41
40
  import { InferredType, UnionType as PseudoUnionType, couldAlreadyReferToUndefined, undefinedType as pseudoUndefinedType, } from './transformers/declarations-pseudo.js';
41
+ import { declarationCount, getDeclarations, getSymbolId, } from './symbol.js';
42
42
  const defaultMaximumTruncationLength = 160;
43
43
  const noTruncationMaximumTruncationLength = 1_000_000;
44
44
  const maxReverseMappedNestingInspectionDepth = 3;
@@ -389,7 +389,7 @@ export class NodeBuilder {
389
389
  }
390
390
  /** Adds the names bound by a destructured parameter; false if `param` isn't one. */
391
391
  addBindingPatternParameters(param, table) {
392
- for (const d of param.declarations) {
392
+ for (const d of getDeclarations(param)) {
393
393
  if (d.kind !== 170 /* SyntaxKind.Parameter */)
394
394
  continue;
395
395
  const name = asBindingPattern(getName(d));
@@ -1051,7 +1051,7 @@ export class NodeBuilder {
1051
1051
  const c = this.c;
1052
1052
  let isStaticMethodSymbol = false;
1053
1053
  if ((symbol.flags & 8192 /* SymbolFlags.Method */) !== 0)
1054
- for (const d of symbol.declarations)
1054
+ for (const d of getDeclarations(symbol))
1055
1055
  if (isStatic(d) && !hasLateBindableIndexSignature(c, d))
1056
1056
  isStaticMethodSymbol = true;
1057
1057
  let isNonLocalFunctionSymbol = false;
@@ -1060,7 +1060,7 @@ export class NodeBuilder {
1060
1060
  if (symbol.parent !== undefined)
1061
1061
  isNonLocalFunctionSymbol = true;
1062
1062
  else
1063
- for (const d of symbol.declarations) {
1063
+ for (const d of getDeclarations(symbol)) {
1064
1064
  const parent = d.parent;
1065
1065
  if (parent.kind === 307 /* SyntaxKind.SourceFile */ || parent.kind === 269 /* SyntaxKind.ModuleBlock */) {
1066
1066
  isNonLocalFunctionSymbol = true;
@@ -1315,8 +1315,8 @@ export class NodeBuilder {
1315
1315
  const saveEnclosingDeclaration = this.enclosingDeclaration;
1316
1316
  this.enclosingDeclaration = undefined;
1317
1317
  if (isLateBoundName(propertySymbol.name)) {
1318
- if (propertySymbol.declarations.length > 0) {
1319
- const decl = propertySymbol.declarations[0];
1318
+ if (declarationCount(propertySymbol) > 0) {
1319
+ const decl = propertySymbol.declaration;
1320
1320
  if (hasLateBindableName(c, decl)) {
1321
1321
  if (decl instanceof BinaryExpression) {
1322
1322
  const name = getNameOfDeclaration(decl);
@@ -1333,7 +1333,7 @@ export class NodeBuilder {
1333
1333
  }
1334
1334
  this.enclosingDeclaration =
1335
1335
  propertySymbol.valueDeclaration ??
1336
- (propertySymbol.declarations.length > 0 ? propertySymbol.declarations[0] : saveEnclosingDeclaration);
1336
+ (declarationCount(propertySymbol) > 0 ? propertySymbol.declaration : saveEnclosingDeclaration);
1337
1337
  const propertyName = getPropertyNameNodeForSymbol(this, propertySymbol);
1338
1338
  this.enclosingDeclaration = saveEnclosingDeclaration;
1339
1339
  this.approximateLength += symbolName(propertySymbol).length + 1;
@@ -1415,7 +1415,7 @@ export class NodeBuilder {
1415
1415
  this.context.assignCommentRange(node, range);
1416
1416
  }
1417
1417
  isDeclaredInEnclosingFile(symbol) {
1418
- for (const d of symbol.declarations)
1418
+ for (const d of getDeclarations(symbol))
1419
1419
  if (getSourceFileOfNode(d) === this.enclosingFile)
1420
1420
  return true;
1421
1421
  return false;
@@ -1575,8 +1575,8 @@ export class NodeBuilder {
1575
1575
  if (!(result instanceof Identifier))
1576
1576
  return this.identifier('(Missing type parameter)');
1577
1577
  const symbol = typeParameter.symbol;
1578
- if (symbol !== undefined && symbol.declarations.length > 0) {
1579
- const decl = symbol.declarations[0];
1578
+ if (symbol !== undefined && declarationCount(symbol) > 0) {
1579
+ const decl = symbol.declaration;
1580
1580
  if (decl.kind === 169 /* SyntaxKind.TypeParameter */)
1581
1581
  result = this.setTextRange(result, getName(decl));
1582
1582
  }
@@ -1835,7 +1835,7 @@ export class NodeBuilder {
1835
1835
  serializeTypeForDeclaration(declaration, type, symbol, tryReuse) {
1836
1836
  const c = this.c;
1837
1837
  if (declaration === undefined && symbol !== undefined)
1838
- declaration = symbol.valueDeclaration ?? (symbol.declarations.length > 0 ? symbol.declarations[0] : undefined);
1838
+ declaration = symbol.valueDeclaration ?? (declarationCount(symbol) > 0 ? symbol.declaration : undefined);
1839
1839
  if (symbol === undefined && declaration !== undefined)
1840
1840
  symbol = getSymbolOfDeclaration(c, declaration);
1841
1841
  let t = type;
@@ -1905,7 +1905,7 @@ export class NodeBuilder {
1905
1905
  : pseudo.getTypeOfDeclaration(declaration);
1906
1906
  if (pt.kind === 2 /* PseudoTypeKind.NoResult */ && declaration.kind === 227 /* SyntaxKind.BinaryExpression */) {
1907
1907
  // The first annotated assignment declares the type for the rest.
1908
- for (const d of symbol.declarations)
1908
+ for (const d of getDeclarations(symbol))
1909
1909
  if (getType(d) !== undefined) {
1910
1910
  pt = pseudo.getTypeOfDeclaration(d);
1911
1911
  break;
@@ -2123,9 +2123,9 @@ function isClassInstanceSide(c, t) {
2123
2123
  }
2124
2124
  function getTypeAliasForTypeLiteral(c, t) {
2125
2125
  const symbol = t.symbol;
2126
- if (symbol === undefined || (symbol.flags & 2048 /* SymbolFlags.TypeLiteral */) === 0 || symbol.declarations.length === 0)
2126
+ if (symbol === undefined || (symbol.flags & 2048 /* SymbolFlags.TypeLiteral */) === 0 || declarationCount(symbol) === 0)
2127
2127
  return undefined;
2128
- let node = symbol.declarations[0].parent;
2128
+ let node = symbol.declaration.parent;
2129
2129
  while (node !== undefined && node.kind === 197 /* SyntaxKind.ParenthesizedType */)
2130
2130
  node = node.parent;
2131
2131
  if (node !== undefined && node.kind === 266 /* SyntaxKind.TypeAliasDeclaration */)
@@ -2136,7 +2136,7 @@ function getTypeAliasForTypeLiteral(c, t) {
2136
2136
  function getResolvedTypeWithoutAbstractConstructSignatures(c, t, resolved) {
2137
2137
  if (resolved.constructSignatures.length === 0)
2138
2138
  return t;
2139
- const side = sideOf(c, t);
2139
+ const side = membersHolder(c, t);
2140
2140
  if (side.objectTypeWithoutAbstractConstructSignatures !== undefined)
2141
2141
  return side.objectTypeWithoutAbstractConstructSignatures;
2142
2142
  const constructSignatures = resolved.constructSignatures.filter((s) => (s.flags & 8 /* SignatureFlags.Abstract */) === 0);
@@ -2174,7 +2174,7 @@ function getEffectiveConstraint(typeParameter) {
2174
2174
  function getTypeParameterModifiers(tp) {
2175
2175
  let flags = 0 /* ModifierFlags.None */;
2176
2176
  if (tp.symbol !== undefined)
2177
- for (const d of tp.symbol.declarations)
2177
+ for (const d of getDeclarations(tp.symbol))
2178
2178
  flags |= getCombinedModifierFlags(d);
2179
2179
  return flags & (8192 /* ModifierFlags.In */ | 16384 /* ModifierFlags.Out */ | 4096 /* ModifierFlags.Const */);
2180
2180
  }
@@ -45,6 +45,8 @@ export declare class PreparedFile {
45
45
  }
46
46
  /** The version a parse thread computed for `file` (`PreparedFile.version`), or `''`. */
47
47
  export declare function preparedVersion(file: SourceFile): string;
48
+ /** Whether a parse thread prepared `fileName`. */
49
+ export declare function isPrepared(fileName: string): boolean;
48
50
  /** What a parse thread's FileLoader found loading `fileName`, if the thread prepared it. */
49
51
  export declare function preparedLoad(fileName: string): LoadedFile | undefined;
50
52
  /** What a parse thread sends back for a chunk: its bound files and the files they add. */
@@ -73,6 +73,10 @@ export function preparedVersion(file) {
73
73
  const prepared = parallelParse.files.get(file.fileName);
74
74
  return prepared !== undefined && prepared.file === file ? prepared.version : '';
75
75
  }
76
+ /** Whether a parse thread prepared `fileName`. */
77
+ export function isPrepared(fileName) {
78
+ return parallelParse.files.has(fileName);
79
+ }
76
80
  /** What a parse thread's FileLoader found loading `fileName`, if the thread prepared it. */
77
81
  export function preparedLoad(fileName) {
78
82
  if (parallelParse.files.size === 0)
@@ -441,7 +445,9 @@ export class ParseSession {
441
445
  this.onIdle(batch);
442
446
  }
443
447
  post(i, chunk) {
444
- this.workers[i].postMessage(chunk);
448
+ // Published, the chunk reaches the thread by pointer: copying its names into the message took the
449
+ // main thread 25-45 us per chunk, which during config read delays the matching of root files.
450
+ this.workers[i].postMessage(publish(chunk));
445
451
  this.outstanding[i] = this.outstanding[i] + 1;
446
452
  if (chunk.kinds[0] === 2 /* LoadKind.Library */ && largeLibraries.has(chunk.names[0]))
447
453
  this.blocked[i] = true;
@@ -71,6 +71,15 @@ export declare const enum ParseFlags {
71
71
  IgnoreMissingOpenBrace = 16,
72
72
  JSDoc = 32
73
73
  }
74
+ /** How an identifier is used, which decides whether it holds a flow node. */
75
+ export declare const enum IdentifierUse {
76
+ /** An expression or another reference: a `ReferenceIdentifier`. */
77
+ Reference = 0,
78
+ /** A declaration, property, property access or type name, whose flow node nothing reads: an `Identifier`. */
79
+ Name = 1,
80
+ /** An object literal element's name: a name before `:`, `(` or `<`, a reference in a shorthand property. */
81
+ ElementName = 2
82
+ }
74
83
  /** What the scanner saw of the JSDoc comments preceding a token. */
75
84
  export declare const enum JSDocScannerInfo {
76
85
  None = 0,
@@ -135,7 +144,7 @@ export declare class Parser extends ScannerErrorReporter {
135
144
  signatureParameterAllowAmbiguity: boolean;
136
145
  signatureParameterFlags: ParseFlags;
137
146
  /** Parses JSDoc comments and, in JavaScript files, reparses their tags. */
138
- readonly jsdoc: JSDocParser;
147
+ jsdoc: JSDocParser;
139
148
  /**
140
149
  * Returned instead of `undefined` by hot element parsers: a `Node | undefined` result is boxed natively
141
150
  * for every node returned.
@@ -147,9 +156,10 @@ export declare class Parser extends ScannerErrorReporter {
147
156
  /** The scanner copies the code units of only the ranges it is asked to (`Scanner.loadUnits`). */
148
157
  unitsOnDemand?: boolean);
149
158
  /**
150
- * Frees the scanner's copy of the text once the parser is done. The parser and its scanner and
151
- * JSDoc parser refer to each other, so natively they're freed only by a cycle collection, which may
152
- * come much later.
159
+ * Frees the scanner's copy of the text once the parser is done, and drops the references back to
160
+ * this parser from its scanner and JSDoc parser. Natively, the parser is then freed as soon as its
161
+ * caller lets go of it, instead of at a cycle collection, which may come much later (on a parse
162
+ * thread, not before the thread exits).
153
163
  */
154
164
  release(): void;
155
165
  token(): SyntaxKind;
@@ -340,14 +350,21 @@ export declare class Parser extends ScannerErrorReporter {
340
350
  parseLiteralTypeNode(negative: boolean): TypeNode;
341
351
  parseTypeReference(): TypeNode;
342
352
  parseEntityNameOfTypeReference(): EntityName;
343
- parseEntityName(allowReservedWords: boolean, diagnosticMessage: DiagnosticMessage | undefined): EntityName;
353
+ /** An entity name; `use` is for its first identifier, the qualified names' right sides are names. */
354
+ parseEntityName(allowReservedWords: boolean, diagnosticMessage: DiagnosticMessage | undefined, use?: IdentifierUse): EntityName;
344
355
  parseRightSideOfDot(allowIdentifierNames: boolean, allowPrivateIdentifiers: boolean, allowUnicodeEscapeSequenceInIdentifierName: boolean): Node;
345
356
  /** `parseRightSideOfDot` without private identifiers. */
346
357
  parseRightSideOfDotIdentifier(allowIdentifierNames: boolean, allowUnicodeEscapeSequenceInIdentifierName: boolean): Identifier;
347
358
  /** An identifier or keyword after a line break, followed by another on the same line. */
348
359
  isKeywordStartingNextLine(): boolean;
349
- newIdentifier(text: string): Identifier;
350
- createMissingIdentifier(): Identifier;
360
+ /**
361
+ * A new identifier of the class `use` calls for. Callers create it after the identifier's token, so
362
+ * for an element name the current token tells a shorthand property from an assignment or a method.
363
+ */
364
+ newIdentifier(text: string, use?: IdentifierUse): Identifier;
365
+ /** Whether the current token ends an object literal element name that is not a shorthand property. */
366
+ isElementNameEnd(): boolean;
367
+ createMissingIdentifier(use?: IdentifierUse): Identifier;
351
368
  parsePrivateIdentifier(): Node;
352
369
  reScanLessThanToken(): SyntaxKind;
353
370
  reScanGreaterThanToken(): SyntaxKind;
@@ -381,8 +398,8 @@ export declare class Parser extends ScannerErrorReporter {
381
398
  /** Type members are separated by commas or (possibly ASI) semicolons. */
382
399
  parseTypeMemberSemicolon(): boolean;
383
400
  parseAccessorDeclaration(pos: number, jsdoc: JSDocScannerInfo, modifiers: ModifierList | undefined, kind: SyntaxKind, flags: ParseFlags): Node;
384
- parsePropertyName(): Node;
385
- parsePropertyNameWorker(allowComputedPropertyNames: boolean): Node;
401
+ parsePropertyName(use?: IdentifierUse): Node;
402
+ parsePropertyNameWorker(allowComputedPropertyNames: boolean, use?: IdentifierUse): Node;
386
403
  parseComputedPropertyName(): Node;
387
404
  parseFunctionBlockOrSemicolon(flags: ParseFlags, diagnosticMessage: DiagnosticMessage | undefined): Block | undefined;
388
405
  parseFunctionBlock(flags: ParseFlags, diagnosticMessage: DiagnosticMessage | undefined): Block;
@@ -511,15 +528,15 @@ export declare class Parser extends ScannerErrorReporter {
511
528
  parseNewExpressionOrNewDotTarget(): Expression;
512
529
  parseKeywordExpression(): Expression;
513
530
  parseLiteralExpression(intern: boolean): Expression;
514
- parseIdentifierNameErrorOnUnicodeEscapeSequence(): Identifier;
531
+ parseIdentifierNameErrorOnUnicodeEscapeSequence(use?: IdentifierUse): Identifier;
515
532
  parseBindingIdentifier(): Identifier;
516
533
  parseBindingIdentifierWithDiagnostic(privateIdentifierDiagnosticMessage: DiagnosticMessage | undefined): Identifier;
517
- parseIdentifierName(): Identifier;
518
- parseIdentifierNameWithDiagnostic(diagnosticMessage: DiagnosticMessage | undefined): Identifier;
519
- parseIdentifier(): Identifier;
520
- parseIdentifierWithDiagnostic(diagnosticMessage: DiagnosticMessage | undefined, privateIdentifierDiagnosticMessage: DiagnosticMessage | undefined): Identifier;
521
- createIdentifier(isIdentifier: boolean): Identifier;
522
- createIdentifierWithDiagnostic(isIdentifier: boolean, diagnosticMessage: DiagnosticMessage | undefined, privateIdentifierDiagnosticMessage: DiagnosticMessage | undefined): Identifier;
534
+ parseIdentifierName(use?: IdentifierUse): Identifier;
535
+ parseIdentifierNameWithDiagnostic(diagnosticMessage: DiagnosticMessage | undefined, use?: IdentifierUse): Identifier;
536
+ parseIdentifier(use?: IdentifierUse): Identifier;
537
+ parseIdentifierWithDiagnostic(diagnosticMessage: DiagnosticMessage | undefined, privateIdentifierDiagnosticMessage: DiagnosticMessage | undefined, use?: IdentifierUse): Identifier;
538
+ createIdentifier(isIdentifier: boolean, use?: IdentifierUse): Identifier;
539
+ createIdentifierWithDiagnostic(isIdentifier: boolean, diagnosticMessage: DiagnosticMessage | undefined, privateIdentifierDiagnosticMessage: DiagnosticMessage | undefined, use?: IdentifierUse): Identifier;
523
540
  internIdentifier(text: string): string;
524
541
  /** Whether the current token can start a signature member, after any modifiers. */
525
542
  scanTypeMemberStart(): boolean;