typescript 5.5.0-dev.20240328 → 5.5.0-dev.20240330

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.
package/lib/typescript.js CHANGED
@@ -2328,7 +2328,7 @@ module.exports = __toCommonJS(typescript_exports);
2328
2328
 
2329
2329
  // src/compiler/corePublic.ts
2330
2330
  var versionMajorMinor = "5.5";
2331
- var version = `${versionMajorMinor}.0-dev.20240328`;
2331
+ var version = `${versionMajorMinor}.0-dev.20240330`;
2332
2332
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2333
2333
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2334
2334
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -47433,13 +47433,21 @@ function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, im
47433
47433
  }
47434
47434
  const nearestTargetPackageJson = getNearestAncestorDirectoryWithPackageJson(host, getDirectoryPath(modulePath));
47435
47435
  const nearestSourcePackageJson = getNearestAncestorDirectoryWithPackageJson(host, sourceDirectory);
47436
- if (nearestSourcePackageJson !== nearestTargetPackageJson) {
47436
+ const ignoreCase = !hostUsesCaseSensitiveFileNames(host);
47437
+ if (!packageJsonPathsAreEqual(nearestTargetPackageJson, nearestSourcePackageJson, ignoreCase)) {
47437
47438
  return maybeNonRelative;
47438
47439
  }
47439
47440
  return relativePath;
47440
47441
  }
47441
47442
  return isPathRelativeToParent(maybeNonRelative) || countPathComponents(relativePath) < countPathComponents(maybeNonRelative) ? relativePath : maybeNonRelative;
47442
47443
  }
47444
+ function packageJsonPathsAreEqual(a, b, ignoreCase) {
47445
+ if (a === b)
47446
+ return true;
47447
+ if (a === void 0 || b === void 0)
47448
+ return false;
47449
+ return comparePaths(a, b, ignoreCase) === 0 /* EqualTo */;
47450
+ }
47443
47451
  function countPathComponents(path) {
47444
47452
  let count = 0;
47445
47453
  for (let i = startsWith(path, "./") ? 2 : 0; i < path.length; i++) {
@@ -52723,17 +52731,8 @@ function createTypeChecker(host) {
52723
52731
  typeToTypeNode: (type, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => typeToTypeNodeHelper(type, context)),
52724
52732
  typePredicateToTypePredicateNode: (typePredicate, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => typePredicateToTypePredicateNodeHelper(typePredicate, context)),
52725
52733
  expressionOrTypeToTypeNode: (expr, type, addUndefined, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => expressionOrTypeToTypeNode(context, expr, type, addUndefined)),
52726
- serializeTypeForDeclaration: (type, symbol, addUndefined, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => serializeTypeForDeclaration(
52727
- context,
52728
- type,
52729
- symbol,
52730
- enclosingDeclaration,
52731
- /*includePrivateSymbol*/
52732
- void 0,
52733
- /*bundled*/
52734
- void 0,
52735
- addUndefined
52736
- )),
52734
+ serializeTypeForDeclaration: (type, symbol, addUndefined, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, addUndefined)),
52735
+ serializeReturnTypeForSignature: (signature, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => serializeReturnTypeForSignature(context, signature)),
52737
52736
  indexInfoToIndexSignatureDeclaration: (indexInfo, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => indexInfoToIndexSignatureDeclarationHelper(
52738
52737
  indexInfo,
52739
52738
  context,
@@ -52752,7 +52751,7 @@ function createTypeChecker(host) {
52752
52751
  symbolToTypeParameterDeclarations: (symbol, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => typeParametersToTypeParameterDeclarations(symbol, context)),
52753
52752
  symbolToParameterDeclaration: (symbol, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => symbolToParameterDeclaration(symbol, context)),
52754
52753
  typeParameterToDeclaration: (parameter, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => typeParameterToDeclaration(parameter, context)),
52755
- symbolTableToDeclarationStatements: (symbolTable, enclosingDeclaration, flags, tracker, bundled) => withContext(enclosingDeclaration, flags, tracker, (context) => symbolTableToDeclarationStatements(symbolTable, context, bundled)),
52754
+ symbolTableToDeclarationStatements: (symbolTable, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => symbolTableToDeclarationStatements(symbolTable, context)),
52756
52755
  symbolToNode: (symbol, meaning, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => symbolToNode(symbol, context, meaning))
52757
52756
  };
52758
52757
  function expressionOrTypeToTypeNode(context, expr, type, addUndefined) {
@@ -52770,12 +52769,12 @@ function createTypeChecker(host) {
52770
52769
  }
52771
52770
  return typeToTypeNodeHelper(type, context);
52772
52771
  }
52773
- function tryReuseExistingTypeNode(context, typeNode, type, host2, addUndefined, includePrivateSymbol, bundled) {
52772
+ function tryReuseExistingTypeNode(context, typeNode, type, host2, addUndefined) {
52774
52773
  const originalType = type;
52775
52774
  if (addUndefined) {
52776
52775
  type = getOptionalType(type);
52777
52776
  }
52778
- const clone2 = tryReuseExistingNonParameterTypeNode(context, typeNode, type, host2, includePrivateSymbol, bundled);
52777
+ const clone2 = tryReuseExistingNonParameterTypeNode(context, typeNode, type, host2);
52779
52778
  if (clone2) {
52780
52779
  if (addUndefined && !someType(getTypeFromTypeNode(typeNode), (t) => !!(t.flags & 32768 /* Undefined */))) {
52781
52780
  return factory.createUnionTypeNode([clone2, factory.createKeywordTypeNode(157 /* UndefinedKeyword */)]);
@@ -52783,16 +52782,16 @@ function createTypeChecker(host) {
52783
52782
  return clone2;
52784
52783
  }
52785
52784
  if (addUndefined && originalType !== type) {
52786
- const cloneMissingUndefined = tryReuseExistingNonParameterTypeNode(context, typeNode, originalType, host2, includePrivateSymbol, bundled);
52785
+ const cloneMissingUndefined = tryReuseExistingNonParameterTypeNode(context, typeNode, originalType, host2);
52787
52786
  if (cloneMissingUndefined) {
52788
52787
  return factory.createUnionTypeNode([cloneMissingUndefined, factory.createKeywordTypeNode(157 /* UndefinedKeyword */)]);
52789
52788
  }
52790
52789
  }
52791
52790
  return void 0;
52792
52791
  }
52793
- function tryReuseExistingNonParameterTypeNode(context, existing, type, host2 = context.enclosingDeclaration, includePrivateSymbol, bundled, annotationType) {
52792
+ function tryReuseExistingNonParameterTypeNode(context, existing, type, host2 = context.enclosingDeclaration, annotationType) {
52794
52793
  if (typeNodeIsEquivalentToType(existing, host2, type, annotationType) && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) {
52795
- const result = tryReuseExistingTypeNodeHelper(context, existing, includePrivateSymbol, bundled);
52794
+ const result = tryReuseExistingTypeNodeHelper(context, existing);
52796
52795
  if (result) {
52797
52796
  return result;
52798
52797
  }
@@ -52827,7 +52826,8 @@ function createTypeChecker(host) {
52827
52826
  symbolDepth: void 0,
52828
52827
  inferTypeParameters: void 0,
52829
52828
  approximateLength: 0,
52830
- trackedSymbols: void 0
52829
+ trackedSymbols: void 0,
52830
+ bundled: !!compilerOptions.outFile && !!enclosingDeclaration && isExternalOrCommonJsModule(getSourceFileOfNode(enclosingDeclaration))
52831
52831
  };
52832
52832
  context.tracker = new SymbolTrackerImpl(context, tracker, moduleResolverHost);
52833
52833
  const resultingNode = cb(context);
@@ -53818,9 +53818,8 @@ function createTypeChecker(host) {
53818
53818
  }
53819
53819
  function signatureToSignatureDeclarationHelper(signature, kind, context, options) {
53820
53820
  var _a;
53821
- const suppressAny = context.flags & 256 /* SuppressAnyReturnType */;
53822
- if (suppressAny)
53823
- context.flags &= ~256 /* SuppressAnyReturnType */;
53821
+ const flags = context.flags;
53822
+ context.flags &= ~256 /* SuppressAnyReturnType */;
53824
53823
  context.approximateLength += 3;
53825
53824
  let typeParameters;
53826
53825
  let typeArguments;
@@ -53896,27 +53895,17 @@ function createTypeChecker(host) {
53896
53895
  );
53897
53896
  }
53898
53897
  }
53899
- const parameters = (some(expandedParams, (p) => p !== expandedParams[expandedParams.length - 1] && !!(getCheckFlags(p) & 32768 /* RestParameter */)) ? signature.parameters : expandedParams).map((parameter) => symbolToParameterDeclaration(parameter, context, kind === 176 /* Constructor */, options == null ? void 0 : options.privateSymbolVisitor, options == null ? void 0 : options.bundledImports));
53898
+ const parameters = (some(expandedParams, (p) => p !== expandedParams[expandedParams.length - 1] && !!(getCheckFlags(p) & 32768 /* RestParameter */)) ? signature.parameters : expandedParams).map((parameter) => symbolToParameterDeclaration(parameter, context, kind === 176 /* Constructor */));
53900
53899
  const thisParameter = context.flags & 33554432 /* OmitThisParameter */ ? void 0 : tryGetThisParameterDeclaration(signature, context);
53901
53900
  if (thisParameter) {
53902
53901
  parameters.unshift(thisParameter);
53903
53902
  }
53904
- let returnTypeNode;
53905
- const typePredicate = getTypePredicateOfSignature(signature);
53906
- if (typePredicate) {
53907
- returnTypeNode = typePredicateToTypePredicateNodeHelper(typePredicate, context);
53908
- } else {
53909
- const returnType = getReturnTypeOfSignature(signature);
53910
- if (returnType && !(suppressAny && isTypeAny(returnType))) {
53911
- returnTypeNode = serializeReturnTypeForSignature(context, returnType, signature, options == null ? void 0 : options.privateSymbolVisitor, options == null ? void 0 : options.bundledImports);
53912
- } else if (!suppressAny) {
53913
- returnTypeNode = factory.createKeywordTypeNode(133 /* AnyKeyword */);
53914
- }
53915
- }
53903
+ context.flags = flags;
53904
+ const returnTypeNode = serializeReturnTypeForSignature(context, signature);
53916
53905
  let modifiers = options == null ? void 0 : options.modifiers;
53917
53906
  if (kind === 185 /* ConstructorType */ && signature.flags & 4 /* Abstract */) {
53918
- const flags = modifiersToFlags(modifiers);
53919
- modifiers = factory.createModifiersFromModifierFlags(flags | 64 /* Abstract */);
53907
+ const flags2 = modifiersToFlags(modifiers);
53908
+ modifiers = factory.createModifiersFromModifierFlags(flags2 | 64 /* Abstract */);
53920
53909
  }
53921
53910
  const node = kind === 179 /* CallSignature */ ? factory.createCallSignature(typeParameters, parameters, returnTypeNode) : kind === 180 /* ConstructSignature */ ? factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : kind === 173 /* MethodSignature */ ? factory.createMethodSignature(modifiers, (options == null ? void 0 : options.name) ?? factory.createIdentifier(""), options == null ? void 0 : options.questionToken, typeParameters, parameters, returnTypeNode) : kind === 174 /* MethodDeclaration */ ? factory.createMethodDeclaration(
53922
53911
  modifiers,
@@ -54045,11 +54034,11 @@ function createTypeChecker(host) {
54045
54034
  return getDeclarationOfKind(parameterSymbol, 341 /* JSDocParameterTag */);
54046
54035
  }
54047
54036
  }
54048
- function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags, privateSymbolVisitor, bundledImports) {
54037
+ function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) {
54049
54038
  const parameterDeclaration = getEffectiveParameterDeclaration(parameterSymbol);
54050
54039
  const parameterType = getTypeOfSymbol(parameterSymbol);
54051
54040
  const addUndefined = parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration);
54052
- const parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration, privateSymbolVisitor, bundledImports, addUndefined);
54041
+ const parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration, addUndefined);
54053
54042
  const modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && canHaveModifiers(parameterDeclaration) ? map(getModifiers(parameterDeclaration), factory.cloneNode) : void 0;
54054
54043
  const isRest = parameterDeclaration && isRestParameter(parameterDeclaration) || getCheckFlags(parameterSymbol) & 32768 /* RestParameter */;
54055
54044
  const dotDotDotToken = isRest ? factory.createToken(26 /* DotDotDotToken */) : void 0;
@@ -54618,7 +54607,7 @@ function createTypeChecker(host) {
54618
54607
  return initial;
54619
54608
  }
54620
54609
  function getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration) {
54621
- return symbol.declarations && find(symbol.declarations, (s) => !!getEffectiveTypeAnnotationNode(s) && (!enclosingDeclaration || !!findAncestor(s, (n) => n === enclosingDeclaration)));
54610
+ return symbol.declarations && find(symbol.declarations, (s) => !!getNonlocalEffectiveTypeAnnotationNode(s) && (!enclosingDeclaration || !!findAncestor(s, (n) => n === enclosingDeclaration)));
54622
54611
  }
54623
54612
  function existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type) {
54624
54613
  return !(getObjectFlags(type) & 4 /* Reference */) || !isTypeReferenceNode(existing) || length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters);
@@ -54629,13 +54618,13 @@ function createTypeChecker(host) {
54629
54618
  }
54630
54619
  return enclosingDeclaration;
54631
54620
  }
54632
- function serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled, addUndefined) {
54621
+ function serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, addUndefined) {
54633
54622
  var _a;
54634
54623
  if (!isErrorType(type) && enclosingDeclaration) {
54635
54624
  const declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol, getEnclosingDeclarationIgnoringFakeScope(enclosingDeclaration));
54636
54625
  if (declWithExistingAnnotation && !isFunctionLikeDeclaration(declWithExistingAnnotation) && !isGetAccessorDeclaration(declWithExistingAnnotation)) {
54637
- const existing = getEffectiveTypeAnnotationNode(declWithExistingAnnotation);
54638
- const result2 = tryReuseExistingTypeNode(context, existing, type, declWithExistingAnnotation, addUndefined, includePrivateSymbol, bundled);
54626
+ const existing = getNonlocalEffectiveTypeAnnotationNode(declWithExistingAnnotation);
54627
+ const result2 = tryReuseExistingTypeNode(context, existing, type, declWithExistingAnnotation, addUndefined);
54639
54628
  if (result2) {
54640
54629
  return result2;
54641
54630
  }
@@ -54655,27 +54644,48 @@ function createTypeChecker(host) {
54655
54644
  if (typeFromTypeNode === type) {
54656
54645
  return true;
54657
54646
  }
54658
- if (annotatedDeclaration && (isParameter(annotatedDeclaration) || isPropertyDeclaration(annotatedDeclaration)) && annotatedDeclaration.questionToken) {
54647
+ if (annotatedDeclaration && (isParameter(annotatedDeclaration) || isPropertySignature(annotatedDeclaration) || isPropertyDeclaration(annotatedDeclaration)) && annotatedDeclaration.questionToken) {
54659
54648
  return getTypeWithFacts(type, 524288 /* NEUndefined */) === typeFromTypeNode;
54660
54649
  }
54661
54650
  return false;
54662
54651
  }
54663
- function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) {
54652
+ function serializeReturnTypeForSignature(context, signature) {
54653
+ const suppressAny = context.flags & 256 /* SuppressAnyReturnType */;
54654
+ const flags = context.flags;
54655
+ if (suppressAny)
54656
+ context.flags &= ~256 /* SuppressAnyReturnType */;
54657
+ let returnTypeNode;
54658
+ const returnType = getReturnTypeOfSignature(signature);
54659
+ if (returnType && !(suppressAny && isTypeAny(returnType))) {
54660
+ returnTypeNode = serializeReturnTypeForSignatureWorker(context, signature);
54661
+ } else if (!suppressAny) {
54662
+ returnTypeNode = factory.createKeywordTypeNode(133 /* AnyKeyword */);
54663
+ }
54664
+ context.flags = flags;
54665
+ return returnTypeNode;
54666
+ }
54667
+ function serializeReturnTypeForSignatureWorker(context, signature) {
54668
+ const typePredicate = getTypePredicateOfSignature(signature);
54669
+ const type = getReturnTypeOfSignature(signature);
54664
54670
  if (!isErrorType(type) && context.enclosingDeclaration) {
54665
- const annotation = signature.declaration && getEffectiveReturnTypeNode(signature.declaration);
54671
+ const annotation = signature.declaration && getNonlocalEffectiveReturnTypeAnnotationNode(signature.declaration);
54666
54672
  const enclosingDeclarationIgnoringFakeScope = getEnclosingDeclarationIgnoringFakeScope(context.enclosingDeclaration);
54667
54673
  if (!!findAncestor(annotation, (n) => n === enclosingDeclarationIgnoringFakeScope) && annotation) {
54668
54674
  const annotated = getTypeFromTypeNode(annotation);
54669
54675
  const thisInstantiated = annotated.flags & 262144 /* TypeParameter */ && annotated.isThisType ? instantiateType(annotated, signature.mapper) : annotated;
54670
- const result = tryReuseExistingNonParameterTypeNode(context, annotation, type, signature.declaration, includePrivateSymbol, bundled, thisInstantiated);
54676
+ const result = tryReuseExistingNonParameterTypeNode(context, annotation, type, signature.declaration, thisInstantiated);
54671
54677
  if (result) {
54672
54678
  return result;
54673
54679
  }
54674
54680
  }
54675
54681
  }
54676
- return typeToTypeNodeHelper(type, context);
54682
+ if (typePredicate) {
54683
+ return typePredicateToTypePredicateNodeHelper(typePredicate, context);
54684
+ }
54685
+ const expr = signature.declaration && getPossibleTypeNodeReuseExpression(signature.declaration);
54686
+ return expressionOrTypeToTypeNode(context, expr, type);
54677
54687
  }
54678
- function trackExistingEntityName(node, context, includePrivateSymbol) {
54688
+ function trackExistingEntityName(node, context) {
54679
54689
  let introducesError = false;
54680
54690
  const leftmost = getFirstIdentifier(node);
54681
54691
  if (isInJSFile(node) && (isExportsIdentifier(leftmost) || isModuleExportsAccessExpression(leftmost.parent) || isQualifiedName(leftmost.parent) && isModuleIdentifier(leftmost.parent.left) && isExportsIdentifier(leftmost.parent.right))) {
@@ -54704,7 +54714,6 @@ function createTypeChecker(host) {
54704
54714
  }
54705
54715
  } else {
54706
54716
  context.tracker.trackSymbol(sym, context.enclosingDeclaration, meaning);
54707
- includePrivateSymbol == null ? void 0 : includePrivateSymbol(sym);
54708
54717
  }
54709
54718
  if (isIdentifier(node)) {
54710
54719
  const type = getDeclaredTypeOfSymbol(sym);
@@ -54715,7 +54724,7 @@ function createTypeChecker(host) {
54715
54724
  }
54716
54725
  return { introducesError, node };
54717
54726
  }
54718
- function tryReuseExistingTypeNodeHelper(context, existing, includePrivateSymbol, bundled) {
54727
+ function tryReuseExistingTypeNodeHelper(context, existing) {
54719
54728
  if (cancellationToken && cancellationToken.throwIfCancellationRequested) {
54720
54729
  cancellationToken.throwIfCancellationRequested();
54721
54730
  }
@@ -54838,33 +54847,27 @@ function createTypeChecker(host) {
54838
54847
  node.isTypeOf
54839
54848
  );
54840
54849
  }
54841
- if (isParameter(node)) {
54842
- if (!node.type && !node.initializer) {
54843
- return factory.updateParameterDeclaration(
54844
- node,
54845
- /*modifiers*/
54846
- void 0,
54847
- node.dotDotDotToken,
54848
- visitEachChild(
54849
- node.name,
54850
- visitExistingNodeTreeSymbols,
54851
- /*context*/
54852
- void 0
54853
- ),
54854
- node.questionToken,
54855
- factory.createKeywordTypeNode(133 /* AnyKeyword */),
54856
- /*initializer*/
54857
- void 0
54858
- );
54859
- }
54850
+ if (isNamedDeclaration(node) && node.name.kind === 167 /* ComputedPropertyName */ && !isLateBindableName(node.name)) {
54851
+ return void 0;
54860
54852
  }
54861
- if (isPropertySignature(node)) {
54862
- if (!node.type && !node.initializer) {
54863
- return factory.updatePropertySignature(node, node.modifiers, node.name, node.questionToken, factory.createKeywordTypeNode(133 /* AnyKeyword */));
54853
+ if (isFunctionLike(node) && !node.type || isPropertyDeclaration(node) && !node.type && !node.initializer || isPropertySignature(node) && !node.type && !node.initializer || isParameter(node) && !node.type && !node.initializer) {
54854
+ let visited = visitEachChild(
54855
+ node,
54856
+ visitExistingNodeTreeSymbols,
54857
+ /*context*/
54858
+ void 0
54859
+ );
54860
+ if (visited === node) {
54861
+ visited = setTextRange(factory.cloneNode(node), node);
54862
+ }
54863
+ visited.type = factory.createKeywordTypeNode(133 /* AnyKeyword */);
54864
+ if (isParameter(node)) {
54865
+ visited.modifiers = void 0;
54864
54866
  }
54867
+ return visited;
54865
54868
  }
54866
54869
  if (isEntityName(node) || isEntityNameExpression(node)) {
54867
- const { introducesError, node: result } = trackExistingEntityName(node, context, includePrivateSymbol);
54870
+ const { introducesError, node: result } = trackExistingEntityName(node, context);
54868
54871
  hadError = hadError || introducesError;
54869
54872
  if (result !== node) {
54870
54873
  return result;
@@ -54895,7 +54898,7 @@ function createTypeChecker(host) {
54895
54898
  return p.name && isIdentifier(p.name) && p.name.escapedText === "this" ? "this" : getEffectiveDotDotDotForParameter(p) ? `args` : `arg${index}`;
54896
54899
  }
54897
54900
  function rewriteModuleSpecifier(parent2, lit) {
54898
- if (bundled) {
54901
+ if (context.bundled) {
54899
54902
  if (context.tracker && context.tracker.moduleResolverHost) {
54900
54903
  const targetFile = getExternalModuleFileFromDeclaration(parent2);
54901
54904
  if (targetFile) {
@@ -54914,7 +54917,7 @@ function createTypeChecker(host) {
54914
54917
  }
54915
54918
  }
54916
54919
  }
54917
- function symbolTableToDeclarationStatements(symbolTable, context, bundled) {
54920
+ function symbolTableToDeclarationStatements(symbolTable, context) {
54918
54921
  var _a;
54919
54922
  const serializePropertySymbolForClass = makeSerializePropertySymbol(
54920
54923
  factory.createPropertyDeclaration,
@@ -54973,7 +54976,7 @@ function createTypeChecker(host) {
54973
54976
  const baseName = unescapeLeadingUnderscores(name);
54974
54977
  void getInternalSymbolName(symbol, baseName);
54975
54978
  });
54976
- let addingDeclare = !bundled;
54979
+ let addingDeclare = !context.bundled;
54977
54980
  const exportEquals = symbolTable.get("export=" /* ExportEquals */);
54978
54981
  if (exportEquals && symbolTable.size > 1 && exportEquals.flags & (2097152 /* Alias */ | 1536 /* Module */)) {
54979
54982
  symbolTable = createSymbolTable();
@@ -55254,7 +55257,7 @@ function createTypeChecker(host) {
55254
55257
  name,
55255
55258
  /*exclamationToken*/
55256
55259
  void 0,
55257
- serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled)
55260
+ serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration)
55258
55261
  )
55259
55262
  ], flags)
55260
55263
  ),
@@ -55396,9 +55399,7 @@ function createTypeChecker(host) {
55396
55399
  jsdocAliasDecl.typeExpression.type,
55397
55400
  aliasType,
55398
55401
  /*host*/
55399
- void 0,
55400
- includePrivateSymbol,
55401
- bundled
55402
+ void 0
55402
55403
  ) || typeToTypeNodeHelper(aliasType, context);
55403
55404
  addResult(
55404
55405
  setSyntheticLeadingComments(
@@ -55528,7 +55529,7 @@ function createTypeChecker(host) {
55528
55529
  function serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags) {
55529
55530
  const signatures = getSignaturesOfType(type, 0 /* Call */);
55530
55531
  for (const sig of signatures) {
55531
- const decl = signatureToSignatureDeclarationHelper(sig, 262 /* FunctionDeclaration */, context, { name: factory.createIdentifier(localName), privateSymbolVisitor: includePrivateSymbol, bundledImports: bundled });
55532
+ const decl = signatureToSignatureDeclarationHelper(sig, 262 /* FunctionDeclaration */, context, { name: factory.createIdentifier(localName) });
55532
55533
  addResult(setTextRange(decl, getSignatureTextRangeLocation(sig)), modifierFlags);
55533
55534
  }
55534
55535
  if (!(symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && !!symbol.exports && !!symbol.exports.size)) {
@@ -55622,7 +55623,7 @@ function createTypeChecker(host) {
55622
55623
  );
55623
55624
  }
55624
55625
  let introducesError;
55625
- ({ introducesError, node: expr } = trackExistingEntityName(expr, context, includePrivateSymbol));
55626
+ ({ introducesError, node: expr } = trackExistingEntityName(expr, context));
55626
55627
  if (introducesError) {
55627
55628
  return cleanup(
55628
55629
  /*result*/
@@ -55632,15 +55633,7 @@ function createTypeChecker(host) {
55632
55633
  }
55633
55634
  return cleanup(factory.createExpressionWithTypeArguments(
55634
55635
  expr,
55635
- map(e.typeArguments, (a) => tryReuseExistingNonParameterTypeNode(
55636
- context,
55637
- a,
55638
- getTypeFromTypeNode(a),
55639
- /*host*/
55640
- void 0,
55641
- includePrivateSymbol,
55642
- bundled
55643
- ) || typeToTypeNodeHelper(getTypeFromTypeNode(a), context))
55636
+ map(e.typeArguments, (a) => tryReuseExistingNonParameterTypeNode(context, a, getTypeFromTypeNode(a)) || typeToTypeNodeHelper(getTypeFromTypeNode(a), context))
55644
55637
  ));
55645
55638
  function cleanup(result2) {
55646
55639
  context.enclosingDeclaration = oldEnclosing;
@@ -55865,7 +55858,7 @@ function createTypeChecker(host) {
55865
55858
  break;
55866
55859
  case 273 /* ImportClause */: {
55867
55860
  const generatedSpecifier = getSpecifierForModuleSymbol(target.parent || target, context);
55868
- const specifier2 = bundled ? factory.createStringLiteral(generatedSpecifier) : node.parent.moduleSpecifier;
55861
+ const specifier2 = context.bundled ? factory.createStringLiteral(generatedSpecifier) : node.parent.moduleSpecifier;
55869
55862
  const attributes = isImportDeclaration(node.parent) ? node.parent.attributes : void 0;
55870
55863
  const isTypeOnly = isJSDocImportTag(node.parent);
55871
55864
  addResult(
@@ -55887,7 +55880,7 @@ function createTypeChecker(host) {
55887
55880
  }
55888
55881
  case 274 /* NamespaceImport */: {
55889
55882
  const generatedSpecifier = getSpecifierForModuleSymbol(target.parent || target, context);
55890
- const specifier2 = bundled ? factory.createStringLiteral(generatedSpecifier) : node.parent.parent.moduleSpecifier;
55883
+ const specifier2 = context.bundled ? factory.createStringLiteral(generatedSpecifier) : node.parent.parent.moduleSpecifier;
55891
55884
  const isTypeOnly = isJSDocImportTag(node.parent.parent);
55892
55885
  addResult(
55893
55886
  factory.createImportDeclaration(
@@ -55921,7 +55914,7 @@ function createTypeChecker(host) {
55921
55914
  break;
55922
55915
  case 276 /* ImportSpecifier */: {
55923
55916
  const generatedSpecifier = getSpecifierForModuleSymbol(target.parent || target, context);
55924
- const specifier2 = bundled ? factory.createStringLiteral(generatedSpecifier) : node.parent.parent.parent.moduleSpecifier;
55917
+ const specifier2 = context.bundled ? factory.createStringLiteral(generatedSpecifier) : node.parent.parent.parent.moduleSpecifier;
55925
55918
  const isTypeOnly = isJSDocImportTag(node.parent.parent.parent);
55926
55919
  addResult(
55927
55920
  factory.createImportDeclaration(
@@ -56075,7 +56068,7 @@ function createTypeChecker(host) {
56075
56068
  varName,
56076
56069
  /*exclamationToken*/
56077
56070
  void 0,
56078
- serializeTypeForDeclaration(context, typeToSerialize, symbol, enclosingDeclaration, includePrivateSymbol, bundled)
56071
+ serializeTypeForDeclaration(context, typeToSerialize, symbol, enclosingDeclaration)
56079
56072
  )
56080
56073
  ], flags)
56081
56074
  );
@@ -56159,7 +56152,7 @@ function createTypeChecker(host) {
56159
56152
  paramSymbol ? parameterToParameterDeclarationName(paramSymbol, getEffectiveParameterDeclaration(paramSymbol), context) : "value",
56160
56153
  /*questionToken*/
56161
56154
  void 0,
56162
- isPrivate ? void 0 : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled)
56155
+ isPrivate ? void 0 : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration)
56163
56156
  )],
56164
56157
  /*body*/
56165
56158
  void 0
@@ -56174,7 +56167,7 @@ function createTypeChecker(host) {
56174
56167
  factory.createModifiersFromModifierFlags(flag),
56175
56168
  name,
56176
56169
  [],
56177
- isPrivate2 ? void 0 : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled),
56170
+ isPrivate2 ? void 0 : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration),
56178
56171
  /*body*/
56179
56172
  void 0
56180
56173
  ),
@@ -56188,7 +56181,7 @@ function createTypeChecker(host) {
56188
56181
  factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 8 /* Readonly */ : 0) | flag),
56189
56182
  name,
56190
56183
  p.flags & 16777216 /* Optional */ ? factory.createToken(58 /* QuestionToken */) : void 0,
56191
- isPrivate ? void 0 : serializeTypeForDeclaration(context, getWriteTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled),
56184
+ isPrivate ? void 0 : serializeTypeForDeclaration(context, getWriteTypeOfSymbol(p), p, enclosingDeclaration),
56192
56185
  // TODO: https://github.com/microsoft/TypeScript/pull/32372#discussion_r328386357
56193
56186
  // interface members can't have initializers, however class members _can_
56194
56187
  /*initializer*/
@@ -87932,9 +87925,23 @@ function createTypeChecker(host) {
87932
87925
  function isDeclarationWithPossibleInnerTypeNodeReuse(declaration) {
87933
87926
  return isFunctionLike(declaration) || isExportAssignment(declaration) || isVariableLike(declaration);
87934
87927
  }
87928
+ function getAllAccessorDeclarationsForDeclaration(accessor) {
87929
+ accessor = getParseTreeNode(accessor, isGetOrSetAccessorDeclaration);
87930
+ const otherKind = accessor.kind === 178 /* SetAccessor */ ? 177 /* GetAccessor */ : 178 /* SetAccessor */;
87931
+ const otherAccessor = getDeclarationOfKind(getSymbolOfDeclaration(accessor), otherKind);
87932
+ const firstAccessor = otherAccessor && otherAccessor.pos < accessor.pos ? otherAccessor : accessor;
87933
+ const secondAccessor = otherAccessor && otherAccessor.pos < accessor.pos ? accessor : otherAccessor;
87934
+ const setAccessor = accessor.kind === 178 /* SetAccessor */ ? accessor : otherAccessor;
87935
+ const getAccessor = accessor.kind === 177 /* GetAccessor */ ? accessor : otherAccessor;
87936
+ return {
87937
+ firstAccessor,
87938
+ secondAccessor,
87939
+ setAccessor,
87940
+ getAccessor
87941
+ };
87942
+ }
87935
87943
  function getPossibleTypeNodeReuseExpression(declaration) {
87936
- var _a;
87937
- return isFunctionLike(declaration) && !isSetAccessor(declaration) ? getSingleReturnExpression(declaration) : isExportAssignment(declaration) ? declaration.expression : !!declaration.initializer ? declaration.initializer : isParameter(declaration) && isSetAccessor(declaration.parent) ? getSingleReturnExpression(getAllAccessorDeclarations((_a = getSymbolOfDeclaration(declaration.parent)) == null ? void 0 : _a.declarations, declaration.parent).getAccessor) : void 0;
87944
+ return isFunctionLike(declaration) && !isSetAccessor(declaration) ? getSingleReturnExpression(declaration) : isExportAssignment(declaration) ? declaration.expression : !!declaration.initializer ? declaration.initializer : isParameter(declaration) && isSetAccessor(declaration.parent) ? getSingleReturnExpression(getAllAccessorDeclarationsForDeclaration(declaration.parent).getAccessor) : void 0;
87938
87945
  }
87939
87946
  function getSingleReturnExpression(declaration) {
87940
87947
  let candidateExpr;
@@ -87960,20 +87967,7 @@ function createTypeChecker(host) {
87960
87967
  if (!signatureDeclaration) {
87961
87968
  return factory.createToken(133 /* AnyKeyword */);
87962
87969
  }
87963
- const signature = getSignatureFromDeclaration(signatureDeclaration);
87964
- const typePredicate = getTypePredicateOfSignature(signature);
87965
- if (typePredicate) {
87966
- return nodeBuilder.typePredicateToTypePredicateNode(typePredicate, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker);
87967
- }
87968
- return nodeBuilder.expressionOrTypeToTypeNode(
87969
- getPossibleTypeNodeReuseExpression(signatureDeclaration),
87970
- getReturnTypeOfSignature(signature),
87971
- /*addUndefined*/
87972
- void 0,
87973
- enclosingDeclaration,
87974
- flags | 1024 /* MultilineObjectLiterals */,
87975
- tracker
87976
- );
87970
+ return nodeBuilder.serializeReturnTypeForSignature(getSignatureFromDeclaration(signatureDeclaration), enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker);
87977
87971
  }
87978
87972
  function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) {
87979
87973
  const expr = getParseTreeNode(exprIn, isExpression);
@@ -88132,6 +88126,35 @@ function createTypeChecker(host) {
88132
88126
  return parseIsolatedEntityName(compilerOptions.jsxFragmentFactory, languageVersion);
88133
88127
  }
88134
88128
  }
88129
+ function getNonlocalEffectiveTypeAnnotationNode(node) {
88130
+ const direct = getEffectiveTypeAnnotationNode(node);
88131
+ if (direct) {
88132
+ return direct;
88133
+ }
88134
+ if (node.kind === 169 /* Parameter */ && node.parent.kind === 178 /* SetAccessor */) {
88135
+ const other = getAllAccessorDeclarationsForDeclaration(node.parent).getAccessor;
88136
+ if (other) {
88137
+ return getEffectiveReturnTypeNode(other);
88138
+ }
88139
+ }
88140
+ return void 0;
88141
+ }
88142
+ function getNonlocalEffectiveReturnTypeAnnotationNode(node) {
88143
+ const direct = getEffectiveReturnTypeNode(node);
88144
+ if (direct) {
88145
+ return direct;
88146
+ }
88147
+ if (node.kind === 177 /* GetAccessor */) {
88148
+ const other = getAllAccessorDeclarationsForDeclaration(node).setAccessor;
88149
+ if (other) {
88150
+ const param = getSetAccessorValueParameter(other);
88151
+ if (param) {
88152
+ return getEffectiveTypeAnnotationNode(param);
88153
+ }
88154
+ }
88155
+ }
88156
+ return void 0;
88157
+ }
88135
88158
  function createResolver() {
88136
88159
  return {
88137
88160
  getReferencedExportContainer,
@@ -88185,34 +88208,19 @@ function createTypeChecker(host) {
88185
88208
  },
88186
88209
  getJsxFactoryEntity,
88187
88210
  getJsxFragmentFactoryEntity,
88188
- getAllAccessorDeclarations(accessor) {
88189
- accessor = getParseTreeNode(accessor, isGetOrSetAccessorDeclaration);
88190
- const otherKind = accessor.kind === 178 /* SetAccessor */ ? 177 /* GetAccessor */ : 178 /* SetAccessor */;
88191
- const otherAccessor = getDeclarationOfKind(getSymbolOfDeclaration(accessor), otherKind);
88192
- const firstAccessor = otherAccessor && otherAccessor.pos < accessor.pos ? otherAccessor : accessor;
88193
- const secondAccessor = otherAccessor && otherAccessor.pos < accessor.pos ? accessor : otherAccessor;
88194
- const setAccessor = accessor.kind === 178 /* SetAccessor */ ? accessor : otherAccessor;
88195
- const getAccessor = accessor.kind === 177 /* GetAccessor */ ? accessor : otherAccessor;
88196
- return {
88197
- firstAccessor,
88198
- secondAccessor,
88199
- setAccessor,
88200
- getAccessor
88201
- };
88202
- },
88203
88211
  isBindingCapturedByNode: (node, decl) => {
88204
88212
  const parseNode = getParseTreeNode(node);
88205
88213
  const parseDecl = getParseTreeNode(decl);
88206
88214
  return !!parseNode && !!parseDecl && (isVariableDeclaration(parseDecl) || isBindingElement(parseDecl)) && isBindingCapturedByNode(parseNode, parseDecl);
88207
88215
  },
88208
- getDeclarationStatementsForSourceFile: (node, flags, tracker, bundled) => {
88216
+ getDeclarationStatementsForSourceFile: (node, flags, tracker) => {
88209
88217
  const n = getParseTreeNode(node);
88210
88218
  Debug.assert(n && n.kind === 307 /* SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile");
88211
88219
  const sym = getSymbolOfDeclaration(node);
88212
88220
  if (!sym) {
88213
- return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled);
88221
+ return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker);
88214
88222
  }
88215
- return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker, bundled);
88223
+ return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker);
88216
88224
  },
88217
88225
  isImportRequiredByAugmentation
88218
88226
  };
@@ -88554,7 +88562,7 @@ function createTypeChecker(host) {
88554
88562
  return grammarErrorOnFirstToken(node, Diagnostics.Decorators_are_not_valid_here);
88555
88563
  }
88556
88564
  } else if (legacyDecorators && (node.kind === 177 /* GetAccessor */ || node.kind === 178 /* SetAccessor */)) {
88557
- const accessors = getAllAccessorDeclarations(node.parent.members, node);
88565
+ const accessors = getAllAccessorDeclarationsForDeclaration(node);
88558
88566
  if (hasDecorators(accessors.firstAccessor) && node === accessors.secondAccessor) {
88559
88567
  return grammarErrorOnFirstToken(node, Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name);
88560
88568
  }
@@ -93932,7 +93940,7 @@ function transformTypeScript(context) {
93932
93940
  if (typeSerializer) {
93933
93941
  let decorators;
93934
93942
  if (shouldAddTypeMetadata(node)) {
93935
- const typeMetadata = emitHelpers().createMetadataHelper("design:type", typeSerializer.serializeTypeOfNode({ currentLexicalScope, currentNameScope: container }, node));
93943
+ const typeMetadata = emitHelpers().createMetadataHelper("design:type", typeSerializer.serializeTypeOfNode({ currentLexicalScope, currentNameScope: container }, node, container));
93936
93944
  decorators = append(decorators, factory2.createDecorator(typeMetadata));
93937
93945
  }
93938
93946
  if (shouldAddParamTypesMetadata(node)) {
@@ -93959,7 +93967,7 @@ function transformTypeScript(context) {
93959
93967
  /*type*/
93960
93968
  void 0,
93961
93969
  factory2.createToken(39 /* EqualsGreaterThanToken */),
93962
- typeSerializer.serializeTypeOfNode({ currentLexicalScope, currentNameScope: container }, node)
93970
+ typeSerializer.serializeTypeOfNode({ currentLexicalScope, currentNameScope: container }, node, container)
93963
93971
  ));
93964
93972
  properties = append(properties, typeProperty);
93965
93973
  }
@@ -97396,7 +97404,7 @@ function createRuntimeTypeSerializer(context) {
97396
97404
  let currentNameScope;
97397
97405
  return {
97398
97406
  serializeTypeNode: (serializerContext, node) => setSerializerContextAnd(serializerContext, serializeTypeNode, node),
97399
- serializeTypeOfNode: (serializerContext, node) => setSerializerContextAnd(serializerContext, serializeTypeOfNode, node),
97407
+ serializeTypeOfNode: (serializerContext, node, container) => setSerializerContextAnd(serializerContext, serializeTypeOfNode, node, container),
97400
97408
  serializeParameterTypesOfNode: (serializerContext, node, container) => setSerializerContextAnd(serializerContext, serializeParameterTypesOfNode, node, container),
97401
97409
  serializeReturnTypeOfNode: (serializerContext, node) => setSerializerContextAnd(serializerContext, serializeReturnTypeOfNode, node)
97402
97410
  };
@@ -97410,18 +97418,18 @@ function createRuntimeTypeSerializer(context) {
97410
97418
  currentNameScope = savedCurrentNameScope;
97411
97419
  return result;
97412
97420
  }
97413
- function getAccessorTypeNode(node) {
97414
- const accessors = resolver.getAllAccessorDeclarations(node);
97421
+ function getAccessorTypeNode(node, container) {
97422
+ const accessors = getAllAccessorDeclarations(container.members, node);
97415
97423
  return accessors.setAccessor && getSetAccessorTypeAnnotationNode(accessors.setAccessor) || accessors.getAccessor && getEffectiveReturnTypeNode(accessors.getAccessor);
97416
97424
  }
97417
- function serializeTypeOfNode(node) {
97425
+ function serializeTypeOfNode(node, container) {
97418
97426
  switch (node.kind) {
97419
97427
  case 172 /* PropertyDeclaration */:
97420
97428
  case 169 /* Parameter */:
97421
97429
  return serializeTypeNode(node.type);
97422
97430
  case 178 /* SetAccessor */:
97423
97431
  case 177 /* GetAccessor */:
97424
- return serializeTypeNode(getAccessorTypeNode(node));
97432
+ return serializeTypeNode(getAccessorTypeNode(node, container));
97425
97433
  case 263 /* ClassDeclaration */:
97426
97434
  case 231 /* ClassExpression */:
97427
97435
  case 174 /* MethodDeclaration */:
@@ -97444,7 +97452,7 @@ function createRuntimeTypeSerializer(context) {
97444
97452
  if (parameter.dotDotDotToken) {
97445
97453
  expressions.push(serializeTypeNode(getRestParameterElementType(parameter.type)));
97446
97454
  } else {
97447
- expressions.push(serializeTypeOfNode(parameter));
97455
+ expressions.push(serializeTypeOfNode(parameter, container));
97448
97456
  }
97449
97457
  }
97450
97458
  }
@@ -113471,13 +113479,13 @@ function transformDeclarations(context) {
113471
113479
  context.addDiagnostic(createDiagnosticForNode(errorNameNode || errorFallbackNode, Diagnostics.The_type_of_this_node_cannot_be_serialized_because_its_property_0_cannot_be_serialized, propertyName));
113472
113480
  }
113473
113481
  }
113474
- function transformDeclarationsForJS(sourceFile, bundled) {
113482
+ function transformDeclarationsForJS(sourceFile) {
113475
113483
  const oldDiag = getSymbolAccessibilityDiagnostic;
113476
113484
  getSymbolAccessibilityDiagnostic = (s) => s.errorNode && canProduceDiagnostics(s.errorNode) ? createGetSymbolAccessibilityDiagnosticForNode(s.errorNode)(s) : {
113477
113485
  diagnosticMessage: s.errorModuleName ? Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit : Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit,
113478
113486
  errorNode: s.errorNode || sourceFile
113479
113487
  };
113480
- const result = resolver.getDeclarationStatementsForSourceFile(sourceFile, declarationEmitNodeBuilderFlags, symbolTracker, bundled);
113488
+ const result = resolver.getDeclarationStatementsForSourceFile(sourceFile, declarationEmitNodeBuilderFlags, symbolTracker);
113481
113489
  getSymbolAccessibilityDiagnostic = oldDiag;
113482
113490
  return result;
113483
113491
  }
@@ -113508,11 +113516,7 @@ function transformDeclarations(context) {
113508
113516
  if (isExternalOrCommonJsModule(sourceFile) || isJsonSourceFile(sourceFile)) {
113509
113517
  resultHasExternalModuleIndicator = false;
113510
113518
  needsDeclare = false;
113511
- const statements = isSourceFileJS(sourceFile) ? factory2.createNodeArray(transformDeclarationsForJS(
113512
- sourceFile,
113513
- /*bundled*/
113514
- true
113515
- )) : visitNodes2(sourceFile.statements, visitDeclarationStatements, isStatement);
113519
+ const statements = isSourceFileJS(sourceFile) ? factory2.createNodeArray(transformDeclarationsForJS(sourceFile)) : visitNodes2(sourceFile.statements, visitDeclarationStatements, isStatement);
113516
113520
  const newFile = factory2.updateSourceFile(
113517
113521
  sourceFile,
113518
113522
  [factory2.createModuleDeclaration(
@@ -113834,7 +113838,7 @@ function transformDeclarations(context) {
113834
113838
  if (!isPrivate) {
113835
113839
  const valueParameter = getSetAccessorValueParameter(input);
113836
113840
  if (valueParameter) {
113837
- const accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input));
113841
+ const accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, getAllAccessorDeclarations(isObjectLiteralExpression(input.parent) ? input.parent.properties : input.parent.members, input));
113838
113842
  newValueParameter = ensureParameter(
113839
113843
  valueParameter,
113840
113844
  /*modifierMask*/
@@ -114120,7 +114124,7 @@ function transformDeclarations(context) {
114120
114124
  void 0
114121
114125
  );
114122
114126
  }
114123
- const accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input));
114127
+ const accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, getAllAccessorDeclarations(isObjectLiteralExpression(input.parent) ? input.parent.properties : input.parent.members, input));
114124
114128
  return cleanup(factory2.updateGetAccessorDeclaration(
114125
114129
  input,
114126
114130
  ensureModifiers(input),
@@ -115979,7 +115983,6 @@ var notImplementedResolver = {
115979
115983
  isLiteralConstDeclaration: notImplemented,
115980
115984
  getJsxFactoryEntity: notImplemented,
115981
115985
  getJsxFragmentFactoryEntity: notImplemented,
115982
- getAllAccessorDeclarations: notImplemented,
115983
115986
  isBindingCapturedByNode: notImplemented,
115984
115987
  getDeclarationStatementsForSourceFile: notImplemented,
115985
115988
  isImportRequiredByAugmentation: notImplemented
@@ -127005,7 +127008,8 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
127005
127008
  impliedFormatPackageJsons.delete(newFile.resolvedPath);
127006
127009
  });
127007
127010
  impliedFormatPackageJsons.forEach((existing, path) => {
127008
- if (!(newProgram == null ? void 0 : newProgram.getSourceFileByPath(path))) {
127011
+ const newFile = newProgram == null ? void 0 : newProgram.getSourceFileByPath(path);
127012
+ if (!newFile || newFile.resolvedPath !== path) {
127009
127013
  existing.forEach((location) => fileWatchesOfAffectingLocations.get(location).files--);
127010
127014
  impliedFormatPackageJsons.delete(path);
127011
127015
  }
@@ -159803,10 +159807,7 @@ function getContextualType(previousToken, position, sourceFile, checker) {
159803
159807
  return isJsxExpression(parent2) && !isJsxElement(parent2.parent) && !isJsxFragment(parent2.parent) ? checker.getContextualTypeForJsxAttribute(parent2.parent) : void 0;
159804
159808
  default:
159805
159809
  const argInfo = ts_SignatureHelp_exports.getArgumentInfoForCompletions(previousToken, position, sourceFile, checker);
159806
- return argInfo ? (
159807
- // At `,`, treat this as the next argument after the comma.
159808
- checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 28 /* CommaToken */ ? 1 : 0))
159809
- ) : isEqualityOperatorKind(previousToken.kind) && isBinaryExpression(parent2) && isEqualityOperatorKind(parent2.operatorToken.kind) ? (
159810
+ return argInfo ? checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex) : isEqualityOperatorKind(previousToken.kind) && isBinaryExpression(parent2) && isEqualityOperatorKind(parent2.operatorToken.kind) ? (
159810
159811
  // completion at `x ===/**/` should be for the right side
159811
159812
  checker.getTypeAtLocation(parent2.left)
159812
159813
  ) : checker.getContextualType(previousToken, 4 /* Completions */) || checker.getContextualType(previousToken);
@@ -168194,12 +168195,7 @@ function getArgumentOrParameterListInfo(node, position, sourceFile, checker) {
168194
168195
  if (!info)
168195
168196
  return void 0;
168196
168197
  const { list, argumentIndex } = info;
168197
- const argumentCount = getArgumentCount(
168198
- list,
168199
- /*ignoreTrailingComma*/
168200
- isInString(sourceFile, position, node),
168201
- checker
168202
- );
168198
+ const argumentCount = getArgumentCount(checker, list);
168203
168199
  if (argumentIndex !== 0) {
168204
168200
  Debug.assertLessThan(argumentIndex, argumentCount);
168205
168201
  }
@@ -168211,7 +168207,7 @@ function getArgumentOrParameterListAndIndex(node, sourceFile, checker) {
168211
168207
  return { list: getChildListThatStartsWithOpenerToken(node.parent, node, sourceFile), argumentIndex: 0 };
168212
168208
  } else {
168213
168209
  const list = findContainingList(node);
168214
- return list && { list, argumentIndex: getArgumentIndex(list, node, checker) };
168210
+ return list && { list, argumentIndex: getArgumentIndex(checker, list, node) };
168215
168211
  }
168216
168212
  }
168217
168213
  function getImmediatelyContainingArgumentInfo(node, position, sourceFile, checker) {
@@ -168341,24 +168337,6 @@ function chooseBetterSymbol(s) {
168341
168337
  return isFunctionTypeNode(d) ? (_a = tryCast(d.parent, canHaveSymbol)) == null ? void 0 : _a.symbol : void 0;
168342
168338
  }) || s : s;
168343
168339
  }
168344
- function getArgumentIndex(argumentsList, node, checker) {
168345
- const args = argumentsList.getChildren();
168346
- let argumentIndex = 0;
168347
- for (let pos = 0; pos < length(args); pos++) {
168348
- const child = args[pos];
168349
- if (child === node) {
168350
- break;
168351
- }
168352
- if (isSpreadElement(child)) {
168353
- argumentIndex = argumentIndex + getSpreadElementCount(child, checker) + (pos > 0 ? pos : 0);
168354
- } else {
168355
- if (child.kind !== 28 /* CommaToken */) {
168356
- argumentIndex++;
168357
- }
168358
- }
168359
- }
168360
- return argumentIndex;
168361
- }
168362
168340
  function getSpreadElementCount(node, checker) {
168363
168341
  const spreadType = checker.getTypeAtLocation(node.expression);
168364
168342
  if (checker.isTupleType(spreadType)) {
@@ -168371,19 +168349,48 @@ function getSpreadElementCount(node, checker) {
168371
168349
  }
168372
168350
  return 0;
168373
168351
  }
168374
- function getArgumentCount(argumentsList, ignoreTrailingComma, checker) {
168375
- const listChildren = argumentsList.getChildren();
168376
- let argumentCount = 0;
168377
- for (const child of listChildren) {
168352
+ function getArgumentIndex(checker, argumentsList, node) {
168353
+ return getArgumentIndexOrCount(checker, argumentsList, node);
168354
+ }
168355
+ function getArgumentCount(checker, argumentsList) {
168356
+ return getArgumentIndexOrCount(
168357
+ checker,
168358
+ argumentsList,
168359
+ /*node*/
168360
+ void 0
168361
+ );
168362
+ }
168363
+ function getArgumentIndexOrCount(checker, argumentsList, node) {
168364
+ const args = argumentsList.getChildren();
168365
+ let argumentIndex = 0;
168366
+ let skipComma = false;
168367
+ for (const child of args) {
168368
+ if (node && child === node) {
168369
+ if (!skipComma && child.kind === 28 /* CommaToken */) {
168370
+ argumentIndex++;
168371
+ }
168372
+ return argumentIndex;
168373
+ }
168378
168374
  if (isSpreadElement(child)) {
168379
- argumentCount = argumentCount + getSpreadElementCount(child, checker);
168375
+ argumentIndex += getSpreadElementCount(child, checker);
168376
+ skipComma = true;
168377
+ continue;
168378
+ }
168379
+ if (child.kind !== 28 /* CommaToken */) {
168380
+ argumentIndex++;
168381
+ skipComma = true;
168382
+ continue;
168380
168383
  }
168384
+ if (skipComma) {
168385
+ skipComma = false;
168386
+ continue;
168387
+ }
168388
+ argumentIndex++;
168381
168389
  }
168382
- argumentCount = argumentCount + countWhere(listChildren, (arg) => arg.kind !== 28 /* CommaToken */);
168383
- if (!ignoreTrailingComma && listChildren.length > 0 && last(listChildren).kind === 28 /* CommaToken */) {
168384
- argumentCount++;
168390
+ if (node) {
168391
+ return argumentIndex;
168385
168392
  }
168386
- return argumentCount;
168393
+ return args.length && last(args).kind === 28 /* CommaToken */ ? argumentIndex + 1 : argumentIndex;
168387
168394
  }
168388
168395
  function getArgumentIndexForTemplatePiece(spanIndex, node, position, sourceFile) {
168389
168396
  Debug.assert(position >= node.getStart(), "Assumed 'position' could not occur before node.");