typescript 5.5.0-dev.20240317 → 5.5.0-dev.20240319

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
@@ -159,6 +159,7 @@ __export(typescript_exports, {
159
159
  SignatureCheckMode: () => SignatureCheckMode,
160
160
  SignatureFlags: () => SignatureFlags,
161
161
  SignatureHelp: () => ts_SignatureHelp_exports,
162
+ SignatureInfo: () => SignatureInfo,
162
163
  SignatureKind: () => SignatureKind,
163
164
  SmartSelectionRange: () => ts_SmartSelectionRange_exports,
164
165
  SnippetKind: () => SnippetKind,
@@ -2325,7 +2326,7 @@ module.exports = __toCommonJS(typescript_exports);
2325
2326
 
2326
2327
  // src/compiler/corePublic.ts
2327
2328
  var versionMajorMinor = "5.5";
2328
- var version = `${versionMajorMinor}.0-dev.20240317`;
2329
+ var version = `${versionMajorMinor}.0-dev.20240319`;
2329
2330
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2330
2331
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2331
2332
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -38176,6 +38177,7 @@ var libEntries = [
38176
38177
  ["esnext.weakref", "lib.es2021.weakref.d.ts"],
38177
38178
  ["esnext.decorators", "lib.esnext.decorators.d.ts"],
38178
38179
  ["esnext.object", "lib.esnext.object.d.ts"],
38180
+ ["esnext.regexp", "lib.esnext.regexp.d.ts"],
38179
38181
  ["decorators", "lib.decorators.d.ts"],
38180
38182
  ["decorators.legacy", "lib.decorators.legacy.d.ts"]
38181
38183
  ];
@@ -52508,6 +52510,18 @@ function createTypeChecker(host) {
52508
52510
  return {
52509
52511
  typeToTypeNode: (type, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => typeToTypeNodeHelper(type, context)),
52510
52512
  typePredicateToTypePredicateNode: (typePredicate, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => typePredicateToTypePredicateNodeHelper(typePredicate, context)),
52513
+ expressionOrTypeToTypeNode: (expr, type, addUndefined, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => expressionOrTypeToTypeNode(context, expr, type, addUndefined)),
52514
+ serializeTypeForDeclaration: (type, symbol, addUndefined, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => serializeTypeForDeclaration(
52515
+ context,
52516
+ type,
52517
+ symbol,
52518
+ enclosingDeclaration,
52519
+ /*includePrivateSymbol*/
52520
+ void 0,
52521
+ /*bundled*/
52522
+ void 0,
52523
+ addUndefined
52524
+ )),
52511
52525
  indexInfoToIndexSignatureDeclaration: (indexInfo, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => indexInfoToIndexSignatureDeclarationHelper(
52512
52526
  indexInfo,
52513
52527
  context,
@@ -52529,6 +52543,50 @@ function createTypeChecker(host) {
52529
52543
  symbolTableToDeclarationStatements: (symbolTable, enclosingDeclaration, flags, tracker, bundled) => withContext(enclosingDeclaration, flags, tracker, (context) => symbolTableToDeclarationStatements(symbolTable, context, bundled)),
52530
52544
  symbolToNode: (symbol, meaning, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => symbolToNode(symbol, context, meaning))
52531
52545
  };
52546
+ function expressionOrTypeToTypeNode(context, expr, type, addUndefined) {
52547
+ if (expr) {
52548
+ const typeNode = isAssertionExpression(expr) ? expr.type : isJSDocTypeAssertion(expr) ? getJSDocTypeAssertionType(expr) : void 0;
52549
+ if (typeNode && !isConstTypeReference(typeNode)) {
52550
+ const result = tryReuseExistingTypeNode(context, typeNode, type, expr.parent, addUndefined);
52551
+ if (result) {
52552
+ return result;
52553
+ }
52554
+ }
52555
+ }
52556
+ if (addUndefined) {
52557
+ type = getOptionalType(type);
52558
+ }
52559
+ return typeToTypeNodeHelper(type, context);
52560
+ }
52561
+ function tryReuseExistingTypeNode(context, typeNode, type, host2, addUndefined, includePrivateSymbol, bundled) {
52562
+ const originalType = type;
52563
+ if (addUndefined) {
52564
+ type = getOptionalType(type);
52565
+ }
52566
+ const clone2 = tryReuseExistingNonParameterTypeNode(context, typeNode, type, host2, includePrivateSymbol, bundled);
52567
+ if (clone2) {
52568
+ if (addUndefined && !someType(getTypeFromTypeNode(typeNode), (t) => !!(t.flags & 32768 /* Undefined */))) {
52569
+ return factory.createUnionTypeNode([clone2, factory.createKeywordTypeNode(157 /* UndefinedKeyword */)]);
52570
+ }
52571
+ return clone2;
52572
+ }
52573
+ if (addUndefined && originalType !== type) {
52574
+ const cloneMissingUndefined = tryReuseExistingNonParameterTypeNode(context, typeNode, originalType, host2, includePrivateSymbol, bundled);
52575
+ if (cloneMissingUndefined) {
52576
+ return factory.createUnionTypeNode([cloneMissingUndefined, factory.createKeywordTypeNode(157 /* UndefinedKeyword */)]);
52577
+ }
52578
+ }
52579
+ return void 0;
52580
+ }
52581
+ function tryReuseExistingNonParameterTypeNode(context, existing, type, host2 = context.enclosingDeclaration, includePrivateSymbol, bundled, annotationType) {
52582
+ if (typeNodeIsEquivalentToType(existing, host2, type, annotationType) && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) {
52583
+ const result = tryReuseExistingTypeNodeHelper(context, existing, includePrivateSymbol, bundled);
52584
+ if (result) {
52585
+ return result;
52586
+ }
52587
+ }
52588
+ return void 0;
52589
+ }
52532
52590
  function symbolToNode(symbol, context, meaning) {
52533
52591
  if (context.flags & 1073741824 /* WriteComputedProps */) {
52534
52592
  if (symbol.valueDeclaration) {
@@ -52970,8 +53028,8 @@ function createTypeChecker(host) {
52970
53028
  if (isInstantiationExpressionType) {
52971
53029
  const instantiationExpressionType = type2;
52972
53030
  const existing = instantiationExpressionType.node;
52973
- if (isTypeQueryNode(existing) && getTypeFromTypeNode(existing) === type2) {
52974
- const typeNode = serializeExistingTypeNode(context, existing);
53031
+ if (isTypeQueryNode(existing)) {
53032
+ const typeNode = tryReuseExistingNonParameterTypeNode(context, existing, type2);
52975
53033
  if (typeNode) {
52976
53034
  return typeNode;
52977
53035
  }
@@ -53777,11 +53835,9 @@ function createTypeChecker(host) {
53777
53835
  }
53778
53836
  function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags, privateSymbolVisitor, bundledImports) {
53779
53837
  const parameterDeclaration = getEffectiveParameterDeclaration(parameterSymbol);
53780
- let parameterType = getTypeOfSymbol(parameterSymbol);
53781
- if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) {
53782
- parameterType = getOptionalType(parameterType);
53783
- }
53784
- const parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration, privateSymbolVisitor, bundledImports);
53838
+ const parameterType = getTypeOfSymbol(parameterSymbol);
53839
+ const addUndefined = parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration);
53840
+ const parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration, privateSymbolVisitor, bundledImports, addUndefined);
53785
53841
  const modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && canHaveModifiers(parameterDeclaration) ? map(getModifiers(parameterDeclaration), factory.cloneNode) : void 0;
53786
53842
  const isRest = parameterDeclaration && isRestParameter(parameterDeclaration) || getCheckFlags(parameterSymbol) & 32768 /* RestParameter */;
53787
53843
  const dotDotDotToken = isRest ? factory.createToken(26 /* DotDotDotToken */) : void 0;
@@ -54371,16 +54427,15 @@ function createTypeChecker(host) {
54371
54427
  }
54372
54428
  return enclosingDeclaration;
54373
54429
  }
54374
- function serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled) {
54430
+ function serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled, addUndefined) {
54431
+ var _a;
54375
54432
  if (!isErrorType(type) && enclosingDeclaration) {
54376
54433
  const declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol, getEnclosingDeclarationIgnoringFakeScope(enclosingDeclaration));
54377
54434
  if (declWithExistingAnnotation && !isFunctionLikeDeclaration(declWithExistingAnnotation) && !isGetAccessorDeclaration(declWithExistingAnnotation)) {
54378
54435
  const existing = getEffectiveTypeAnnotationNode(declWithExistingAnnotation);
54379
- if (typeNodeIsEquivalentToType(existing, declWithExistingAnnotation, type) && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) {
54380
- const result2 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled);
54381
- if (result2) {
54382
- return result2;
54383
- }
54436
+ const result2 = tryReuseExistingTypeNode(context, existing, type, declWithExistingAnnotation, addUndefined, includePrivateSymbol, bundled);
54437
+ if (result2) {
54438
+ return result2;
54384
54439
  }
54385
54440
  }
54386
54441
  }
@@ -54388,16 +54443,17 @@ function createTypeChecker(host) {
54388
54443
  if (type.flags & 8192 /* UniqueESSymbol */ && type.symbol === symbol && (!context.enclosingDeclaration || some(symbol.declarations, (d) => getSourceFileOfNode(d) === getSourceFileOfNode(context.enclosingDeclaration)))) {
54389
54444
  context.flags |= 1048576 /* AllowUniqueESSymbolType */;
54390
54445
  }
54391
- const result = typeToTypeNodeHelper(type, context);
54446
+ const decl = symbol.valueDeclaration ?? ((_a = symbol.declarations) == null ? void 0 : _a[0]);
54447
+ const expr = decl && isDeclarationWithPossibleInnerTypeNodeReuse(decl) ? getPossibleTypeNodeReuseExpression(decl) : void 0;
54448
+ const result = expressionOrTypeToTypeNode(context, expr, type, addUndefined);
54392
54449
  context.flags = oldFlags;
54393
54450
  return result;
54394
54451
  }
54395
- function typeNodeIsEquivalentToType(typeNode, annotatedDeclaration, type) {
54396
- const typeFromTypeNode = getTypeFromTypeNode(typeNode);
54452
+ function typeNodeIsEquivalentToType(typeNode, annotatedDeclaration, type, typeFromTypeNode = getTypeFromTypeNode(typeNode)) {
54397
54453
  if (typeFromTypeNode === type) {
54398
54454
  return true;
54399
54455
  }
54400
- if (isParameter(annotatedDeclaration) && annotatedDeclaration.questionToken) {
54456
+ if (annotatedDeclaration && (isParameter(annotatedDeclaration) || isPropertyDeclaration(annotatedDeclaration)) && annotatedDeclaration.questionToken) {
54401
54457
  return getTypeWithFacts(type, 524288 /* NEUndefined */) === typeFromTypeNode;
54402
54458
  }
54403
54459
  return false;
@@ -54409,11 +54465,9 @@ function createTypeChecker(host) {
54409
54465
  if (!!findAncestor(annotation, (n) => n === enclosingDeclarationIgnoringFakeScope) && annotation) {
54410
54466
  const annotated = getTypeFromTypeNode(annotation);
54411
54467
  const thisInstantiated = annotated.flags & 262144 /* TypeParameter */ && annotated.isThisType ? instantiateType(annotated, signature.mapper) : annotated;
54412
- if (thisInstantiated === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) {
54413
- const result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled);
54414
- if (result) {
54415
- return result;
54416
- }
54468
+ const result = tryReuseExistingNonParameterTypeNode(context, annotation, type, signature.declaration, includePrivateSymbol, bundled, thisInstantiated);
54469
+ if (result) {
54470
+ return result;
54417
54471
  }
54418
54472
  }
54419
54473
  }
@@ -54442,7 +54496,9 @@ function createTypeChecker(host) {
54442
54496
  /*shouldComputeAliasesToMakeVisible*/
54443
54497
  false
54444
54498
  ).accessibility !== 0 /* Accessible */) {
54445
- introducesError = true;
54499
+ if (!isDeclarationName(node)) {
54500
+ introducesError = true;
54501
+ }
54446
54502
  } else {
54447
54503
  context.tracker.trackSymbol(sym, context.enclosingDeclaration, -1 /* All */);
54448
54504
  includePrivateSymbol == null ? void 0 : includePrivateSymbol(sym);
@@ -54456,7 +54512,7 @@ function createTypeChecker(host) {
54456
54512
  }
54457
54513
  return { introducesError, node };
54458
54514
  }
54459
- function serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled) {
54515
+ function tryReuseExistingTypeNodeHelper(context, existing, includePrivateSymbol, bundled) {
54460
54516
  if (cancellationToken && cancellationToken.throwIfCancellationRequested) {
54461
54517
  cancellationToken.throwIfCancellationRequested();
54462
54518
  }
@@ -54580,6 +54636,31 @@ function createTypeChecker(host) {
54580
54636
  node.isTypeOf
54581
54637
  );
54582
54638
  }
54639
+ if (isParameter(node)) {
54640
+ if (!node.type && !node.initializer) {
54641
+ return factory.updateParameterDeclaration(
54642
+ node,
54643
+ /*modifiers*/
54644
+ void 0,
54645
+ node.dotDotDotToken,
54646
+ visitEachChild(
54647
+ node.name,
54648
+ visitExistingNodeTreeSymbols,
54649
+ /*context*/
54650
+ void 0
54651
+ ),
54652
+ node.questionToken,
54653
+ factory.createKeywordTypeNode(133 /* AnyKeyword */),
54654
+ /*initializer*/
54655
+ void 0
54656
+ );
54657
+ }
54658
+ }
54659
+ if (isPropertySignature(node)) {
54660
+ if (!node.type && !node.initializer) {
54661
+ return factory.updatePropertySignature(node, node.modifiers, node.name, node.questionToken, factory.createKeywordTypeNode(133 /* AnyKeyword */));
54662
+ }
54663
+ }
54583
54664
  if (isEntityName(node) || isEntityNameExpression(node)) {
54584
54665
  const { introducesError, node: result } = trackExistingEntityName(node, context, includePrivateSymbol);
54585
54666
  hadError = hadError || introducesError;
@@ -54587,7 +54668,7 @@ function createTypeChecker(host) {
54587
54668
  return result;
54588
54669
  }
54589
54670
  }
54590
- if (file && isTupleTypeNode(node) && getLineAndCharacterOfPosition(file, node.pos).line === getLineAndCharacterOfPosition(file, node.end).line) {
54671
+ if (file && isTupleTypeNode(node) && !nodeIsSynthesized(node) && getLineAndCharacterOfPosition(file, node.pos).line === getLineAndCharacterOfPosition(file, node.end).line) {
54591
54672
  setEmitFlags(node, 1 /* SingleLine */);
54592
54673
  }
54593
54674
  return visitEachChild(
@@ -55111,7 +55192,15 @@ function createTypeChecker(host) {
55111
55192
  context.flags |= 8388608 /* InTypeAlias */;
55112
55193
  const oldEnclosingDecl = context.enclosingDeclaration;
55113
55194
  context.enclosingDeclaration = jsdocAliasDecl;
55114
- const typeNode = jsdocAliasDecl && jsdocAliasDecl.typeExpression && isJSDocTypeExpression(jsdocAliasDecl.typeExpression) && serializeExistingTypeNode(context, jsdocAliasDecl.typeExpression.type, includePrivateSymbol, bundled) || typeToTypeNodeHelper(aliasType, context);
55195
+ const typeNode = jsdocAliasDecl && jsdocAliasDecl.typeExpression && isJSDocTypeExpression(jsdocAliasDecl.typeExpression) && tryReuseExistingNonParameterTypeNode(
55196
+ context,
55197
+ jsdocAliasDecl.typeExpression.type,
55198
+ aliasType,
55199
+ /*host*/
55200
+ void 0,
55201
+ includePrivateSymbol,
55202
+ bundled
55203
+ ) || typeToTypeNodeHelper(aliasType, context);
55115
55204
  addResult(
55116
55205
  setSyntheticLeadingComments(
55117
55206
  factory.createTypeAliasDeclaration(
@@ -55344,7 +55433,15 @@ function createTypeChecker(host) {
55344
55433
  }
55345
55434
  return cleanup(factory.createExpressionWithTypeArguments(
55346
55435
  expr,
55347
- map(e.typeArguments, (a) => serializeExistingTypeNode(context, a, includePrivateSymbol, bundled) || typeToTypeNodeHelper(getTypeFromTypeNode(a), context))
55436
+ map(e.typeArguments, (a) => tryReuseExistingNonParameterTypeNode(
55437
+ context,
55438
+ a,
55439
+ getTypeFromTypeNode(a),
55440
+ /*host*/
55441
+ void 0,
55442
+ includePrivateSymbol,
55443
+ bundled
55444
+ ) || typeToTypeNodeHelper(getTypeFromTypeNode(a), context))
55348
55445
  ));
55349
55446
  function cleanup(result2) {
55350
55447
  context.enclosingDeclaration = oldEnclosing;
@@ -55803,8 +55900,10 @@ function createTypeChecker(host) {
55803
55900
  }
55804
55901
  }
55805
55902
  function isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, hostSymbol) {
55903
+ var _a2;
55806
55904
  const ctxSrc = getSourceFileOfNode(context.enclosingDeclaration);
55807
- return getObjectFlags(typeToSerialize) & (16 /* Anonymous */ | 32 /* Mapped */) && !length(getIndexInfosOfType(typeToSerialize)) && !isClassInstanceSide(typeToSerialize) && // While a class instance is potentially representable as a NS, prefer printing a reference to the instance type and serializing the class
55905
+ return getObjectFlags(typeToSerialize) & (16 /* Anonymous */ | 32 /* Mapped */) && !some((_a2 = typeToSerialize.symbol) == null ? void 0 : _a2.declarations, isTypeNode) && // If the type comes straight from a type node, we shouldn't try to break it up
55906
+ !length(getIndexInfosOfType(typeToSerialize)) && !isClassInstanceSide(typeToSerialize) && // While a class instance is potentially representable as a NS, prefer printing a reference to the instance type and serializing the class
55808
55907
  !!(length(filter(getPropertiesOfType(typeToSerialize), isNamespaceMember)) || length(getSignaturesOfType(typeToSerialize, 0 /* Call */))) && !length(getSignaturesOfType(typeToSerialize, 1 /* Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK
55809
55908
  !getDeclarationWithTypeAnnotation(hostSymbol, enclosingDeclaration) && !(typeToSerialize.symbol && some(typeToSerialize.symbol.declarations, (d) => getSourceFileOfNode(d) !== ctxSrc)) && !some(getPropertiesOfType(typeToSerialize), (p) => isLateBoundName(p.escapedName)) && !some(getPropertiesOfType(typeToSerialize), (p) => some(p.declarations, (d) => getSourceFileOfNode(d) !== ctxSrc)) && every(getPropertiesOfType(typeToSerialize), (p) => {
55810
55909
  if (!isIdentifierText(symbolName(p), languageVersion)) {
@@ -59678,13 +59777,16 @@ function createTypeChecker(host) {
59678
59777
  const constraint = getConstraintTypeFromMappedType(type);
59679
59778
  if (constraint.flags & 4194304 /* Index */) {
59680
59779
  const baseConstraint = getBaseConstraintOfType(constraint.type);
59681
- if (baseConstraint && everyType(baseConstraint, isArrayOrTupleType)) {
59780
+ if (baseConstraint && everyType(baseConstraint, (t) => isArrayOrTupleType(t) || isArrayOrTupleOrIntersection(t))) {
59682
59781
  return instantiateType(target, prependTypeMapping(typeVariable, baseConstraint, type.mapper));
59683
59782
  }
59684
59783
  }
59685
59784
  }
59686
59785
  return type;
59687
59786
  }
59787
+ function isArrayOrTupleOrIntersection(type) {
59788
+ return !!(type.flags & 2097152 /* Intersection */) && every(type.types, isArrayOrTupleType);
59789
+ }
59688
59790
  function isMappedTypeGenericIndexedAccess(type) {
59689
59791
  let objectType;
59690
59792
  return !!(type.flags & 8388608 /* IndexedAccess */ && getObjectFlags(objectType = type.objectType) & 32 /* Mapped */ && !isGenericMappedType(objectType) && isGenericIndexType(type.indexType) && !(getMappedTypeModifiers(objectType) & 8 /* ExcludeOptional */) && !objectType.declaration.nameType);
@@ -64076,29 +64178,28 @@ function createTypeChecker(host) {
64076
64178
  if (typeVariable) {
64077
64179
  const mappedTypeVariable = instantiateType(typeVariable, mapper);
64078
64180
  if (typeVariable !== mappedTypeVariable) {
64079
- return mapTypeWithAlias(
64080
- getReducedType(mappedTypeVariable),
64081
- (t) => {
64082
- if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) {
64083
- if (!type.declaration.nameType) {
64084
- let constraint;
64085
- if (isArrayType(t) || t.flags & 1 /* Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* ImmediateBaseConstraint */) < 0 && (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, isArrayOrTupleType)) {
64086
- return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
64087
- }
64088
- if (isTupleType(t)) {
64089
- return instantiateMappedTupleType(t, type, typeVariable, mapper);
64090
- }
64091
- }
64092
- return instantiateAnonymousType(type, prependTypeMapping(typeVariable, t, mapper));
64093
- }
64094
- return t;
64095
- },
64096
- aliasSymbol,
64097
- aliasTypeArguments
64098
- );
64181
+ return mapTypeWithAlias(getReducedType(mappedTypeVariable), instantiateConstituent, aliasSymbol, aliasTypeArguments);
64099
64182
  }
64100
64183
  }
64101
64184
  return instantiateType(getConstraintTypeFromMappedType(type), mapper) === wildcardType ? wildcardType : instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments);
64185
+ function instantiateConstituent(t) {
64186
+ if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) {
64187
+ if (!type.declaration.nameType) {
64188
+ let constraint;
64189
+ if (isArrayType(t) || t.flags & 1 /* Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* ImmediateBaseConstraint */) < 0 && (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, isArrayOrTupleType)) {
64190
+ return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
64191
+ }
64192
+ if (isTupleType(t)) {
64193
+ return instantiateMappedTupleType(t, type, typeVariable, mapper);
64194
+ }
64195
+ if (isArrayOrTupleOrIntersection(t)) {
64196
+ return getIntersectionType(map(t.types, instantiateConstituent));
64197
+ }
64198
+ }
64199
+ return instantiateAnonymousType(type, prependTypeMapping(typeVariable, t, mapper));
64200
+ }
64201
+ return t;
64202
+ }
64102
64203
  }
64103
64204
  function getModifiedReadonlyState(state, modifiers) {
64104
64205
  return modifiers & 1 /* IncludeReadonly */ ? true : modifiers & 2 /* ExcludeReadonly */ ? false : state;
@@ -69001,7 +69102,9 @@ function createTypeChecker(host) {
69001
69102
  return false;
69002
69103
  }
69003
69104
  function inferTypesFromTemplateLiteralType(source, target) {
69004
- return source.flags & 128 /* StringLiteral */ ? inferFromLiteralPartsToTemplateLiteral([source.value], emptyArray, target) : source.flags & 134217728 /* TemplateLiteral */ ? arraysEqual(source.texts, target.texts) ? map(source.types, getStringLikeTypeForType) : inferFromLiteralPartsToTemplateLiteral(source.texts, source.types, target) : void 0;
69105
+ return source.flags & 128 /* StringLiteral */ ? inferFromLiteralPartsToTemplateLiteral([source.value], emptyArray, target) : source.flags & 134217728 /* TemplateLiteral */ ? arraysEqual(source.texts, target.texts) ? map(source.types, (s, i) => {
69106
+ return isTypeAssignableTo(getBaseConstraintOrType(s), getBaseConstraintOrType(target.types[i])) ? s : getStringLikeTypeForType(s);
69107
+ }) : inferFromLiteralPartsToTemplateLiteral(source.texts, source.types, target) : void 0;
69005
69108
  }
69006
69109
  function isTypeMatchedByTemplateLiteralType(source, target) {
69007
69110
  const inferences = inferTypesFromTemplateLiteralType(source, target);
@@ -87634,14 +87737,34 @@ function createTypeChecker(host) {
87634
87737
  return factory.createToken(133 /* AnyKeyword */);
87635
87738
  }
87636
87739
  const symbol = getSymbolOfDeclaration(declaration);
87637
- let type = symbol && !(symbol.flags & (2048 /* TypeLiteral */ | 131072 /* Signature */)) ? getWidenedLiteralType(getTypeOfSymbol(symbol)) : errorType;
87638
- if (type.flags & 8192 /* UniqueESSymbol */ && type.symbol === symbol) {
87639
- flags |= 1048576 /* AllowUniqueESSymbolType */;
87640
- }
87641
- if (addUndefined) {
87642
- type = getOptionalType(type);
87740
+ const type = symbol && !(symbol.flags & (2048 /* TypeLiteral */ | 131072 /* Signature */)) ? getWidenedLiteralType(getTypeOfSymbol(symbol)) : errorType;
87741
+ return nodeBuilder.serializeTypeForDeclaration(type, symbol, addUndefined, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker);
87742
+ }
87743
+ function isDeclarationWithPossibleInnerTypeNodeReuse(declaration) {
87744
+ return isFunctionLike(declaration) || isExportAssignment(declaration) || isVariableLike(declaration);
87745
+ }
87746
+ function getPossibleTypeNodeReuseExpression(declaration) {
87747
+ var _a;
87748
+ 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;
87749
+ }
87750
+ function getSingleReturnExpression(declaration) {
87751
+ let candidateExpr;
87752
+ if (declaration && !nodeIsMissing(declaration.body)) {
87753
+ const body = declaration.body;
87754
+ if (body && isBlock(body)) {
87755
+ forEachReturnStatement(body, (s) => {
87756
+ if (!candidateExpr) {
87757
+ candidateExpr = s.expression;
87758
+ } else {
87759
+ candidateExpr = void 0;
87760
+ return true;
87761
+ }
87762
+ });
87763
+ } else {
87764
+ candidateExpr = body;
87765
+ }
87643
87766
  }
87644
- return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker);
87767
+ return candidateExpr;
87645
87768
  }
87646
87769
  function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) {
87647
87770
  const signatureDeclaration = getParseTreeNode(signatureDeclarationIn, isFunctionLike);
@@ -87653,7 +87776,15 @@ function createTypeChecker(host) {
87653
87776
  if (typePredicate) {
87654
87777
  return nodeBuilder.typePredicateToTypePredicateNode(typePredicate, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker);
87655
87778
  }
87656
- return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker);
87779
+ return nodeBuilder.expressionOrTypeToTypeNode(
87780
+ getPossibleTypeNodeReuseExpression(signatureDeclaration),
87781
+ getReturnTypeOfSignature(signature),
87782
+ /*addUndefined*/
87783
+ void 0,
87784
+ enclosingDeclaration,
87785
+ flags | 1024 /* MultilineObjectLiterals */,
87786
+ tracker
87787
+ );
87657
87788
  }
87658
87789
  function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) {
87659
87790
  const expr = getParseTreeNode(exprIn, isExpression);
@@ -87661,7 +87792,15 @@ function createTypeChecker(host) {
87661
87792
  return factory.createToken(133 /* AnyKeyword */);
87662
87793
  }
87663
87794
  const type = getWidenedType(getRegularTypeOfExpression(expr));
87664
- return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker);
87795
+ return nodeBuilder.expressionOrTypeToTypeNode(
87796
+ expr,
87797
+ type,
87798
+ /*addUndefined*/
87799
+ void 0,
87800
+ enclosingDeclaration,
87801
+ flags | 1024 /* MultilineObjectLiterals */,
87802
+ tracker
87803
+ );
87665
87804
  }
87666
87805
  function hasGlobalName(name) {
87667
87806
  return globals.has(escapeLeadingUnderscores(name));
@@ -113368,10 +113507,10 @@ function transformDeclarations(context) {
113368
113507
  return newFile;
113369
113508
  }
113370
113509
  needsDeclare = true;
113371
- const updated2 = isSourceFileJS(sourceFile) ? factory2.createNodeArray(transformDeclarationsForJS(sourceFile)) : visitNodes2(sourceFile.statements, visitDeclarationStatements, isStatement);
113510
+ const updated = isSourceFileJS(sourceFile) ? factory2.createNodeArray(transformDeclarationsForJS(sourceFile)) : visitNodes2(sourceFile.statements, visitDeclarationStatements, isStatement);
113372
113511
  return factory2.updateSourceFile(
113373
113512
  sourceFile,
113374
- transformAndReplaceLatePaintedStatements(updated2),
113513
+ transformAndReplaceLatePaintedStatements(updated),
113375
113514
  /*isDeclarationFile*/
113376
113515
  true,
113377
113516
  /*referencedFiles*/
@@ -113435,7 +113574,7 @@ function transformDeclarations(context) {
113435
113574
  combinedStatements = setTextRange(factory2.createNodeArray([...combinedStatements, createEmptyExports(factory2)]), combinedStatements);
113436
113575
  }
113437
113576
  }
113438
- const updated = factory2.updateSourceFile(
113577
+ return factory2.updateSourceFile(
113439
113578
  node,
113440
113579
  combinedStatements,
113441
113580
  /*isDeclarationFile*/
@@ -113445,8 +113584,6 @@ function transformDeclarations(context) {
113445
113584
  node.hasNoDefaultLib,
113446
113585
  getLibReferences()
113447
113586
  );
113448
- updated.exportedModulesFromDeclarationEmit = exportedModulesFromDeclarationEmit;
113449
- return updated;
113450
113587
  function getLibReferences() {
113451
113588
  return arrayFrom(libs2.keys(), (lib) => ({ fileName: lib, pos: -1, end: -1 }));
113452
113589
  }
@@ -124816,6 +124953,12 @@ function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationTo
124816
124953
  outputFiles.push({ name: fileName, writeByteOrderMark, text });
124817
124954
  }
124818
124955
  }
124956
+ var SignatureInfo = /* @__PURE__ */ ((SignatureInfo2) => {
124957
+ SignatureInfo2[SignatureInfo2["ComputedDts"] = 0] = "ComputedDts";
124958
+ SignatureInfo2[SignatureInfo2["StoredSignatureAtEmit"] = 1] = "StoredSignatureAtEmit";
124959
+ SignatureInfo2[SignatureInfo2["UsedVersion"] = 2] = "UsedVersion";
124960
+ return SignatureInfo2;
124961
+ })(SignatureInfo || {});
124819
124962
  var BuilderState;
124820
124963
  ((BuilderState2) => {
124821
124964
  function createManyToManyPathMap() {
@@ -124953,12 +125096,11 @@ var BuilderState;
124953
125096
  }
124954
125097
  BuilderState2.canReuseOldState = canReuseOldState;
124955
125098
  function create(newProgram, oldState, disableUseFileVersionAsSignature) {
124956
- var _a, _b, _c;
125099
+ var _a, _b;
124957
125100
  const fileInfos = /* @__PURE__ */ new Map();
124958
125101
  const options = newProgram.getCompilerOptions();
124959
125102
  const isOutFile = options.outFile;
124960
125103
  const referencedMap = options.module !== 0 /* None */ && !isOutFile ? createManyToManyPathMap() : void 0;
124961
- const exportedModulesMap = referencedMap ? createManyToManyPathMap() : void 0;
124962
125104
  const useOldState = canReuseOldState(referencedMap, oldState);
124963
125105
  newProgram.getTypeChecker();
124964
125106
  for (const sourceFile of newProgram.getSourceFiles()) {
@@ -124970,13 +125112,6 @@ var BuilderState;
124970
125112
  if (newReferences) {
124971
125113
  referencedMap.set(sourceFile.resolvedPath, newReferences);
124972
125114
  }
124973
- if (useOldState) {
124974
- const oldUncommittedExportedModules = (_c = oldState.oldExportedModulesMap) == null ? void 0 : _c.get(sourceFile.resolvedPath);
124975
- const exportedModules = oldUncommittedExportedModules === void 0 ? oldState.exportedModulesMap.getValues(sourceFile.resolvedPath) : oldUncommittedExportedModules || void 0;
124976
- if (exportedModules) {
124977
- exportedModulesMap.set(sourceFile.resolvedPath, exportedModules);
124978
- }
124979
- }
124980
125115
  }
124981
125116
  fileInfos.set(sourceFile.resolvedPath, {
124982
125117
  version: version2,
@@ -124989,7 +125124,6 @@ var BuilderState;
124989
125124
  return {
124990
125125
  fileInfos,
124991
125126
  referencedMap,
124992
- exportedModulesMap,
124993
125127
  useFileVersionAsSignature: !disableUseFileVersionAsSignature && !useOldState
124994
125128
  };
124995
125129
  }
@@ -125000,7 +125134,7 @@ var BuilderState;
125000
125134
  }
125001
125135
  BuilderState2.releaseCache = releaseCache2;
125002
125136
  function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, host) {
125003
- var _a, _b;
125137
+ var _a;
125004
125138
  const result = getFilesAffectedByWithOldState(
125005
125139
  state,
125006
125140
  programOfThisState,
@@ -125009,7 +125143,6 @@ var BuilderState;
125009
125143
  host
125010
125144
  );
125011
125145
  (_a = state.oldSignatures) == null ? void 0 : _a.clear();
125012
- (_b = state.oldExportedModulesMap) == null ? void 0 : _b.clear();
125013
125146
  return result;
125014
125147
  }
125015
125148
  BuilderState2.getFilesAffectedBy = getFilesAffectedBy;
@@ -125063,24 +125196,16 @@ var BuilderState;
125063
125196
  const prevSignature = info.signature;
125064
125197
  let latestSignature;
125065
125198
  if (!sourceFile.isDeclarationFile && !useFileVersionAsSignature) {
125066
- computeDtsSignature(programOfThisState, sourceFile, cancellationToken, host, (signature, sourceFiles) => {
125199
+ computeDtsSignature(programOfThisState, sourceFile, cancellationToken, host, (signature) => {
125067
125200
  latestSignature = signature;
125068
- if (latestSignature !== prevSignature) {
125069
- updateExportedModules(state, sourceFile, sourceFiles[0].exportedModulesFromDeclarationEmit);
125070
- }
125201
+ if (host.storeSignatureInfo)
125202
+ (state.signatureInfo ?? (state.signatureInfo = /* @__PURE__ */ new Map())).set(sourceFile.resolvedPath, 0 /* ComputedDts */);
125071
125203
  });
125072
125204
  }
125073
125205
  if (latestSignature === void 0) {
125074
125206
  latestSignature = sourceFile.version;
125075
- if (state.exportedModulesMap && latestSignature !== prevSignature) {
125076
- (state.oldExportedModulesMap || (state.oldExportedModulesMap = /* @__PURE__ */ new Map())).set(sourceFile.resolvedPath, state.exportedModulesMap.getValues(sourceFile.resolvedPath) || false);
125077
- const references = state.referencedMap ? state.referencedMap.getValues(sourceFile.resolvedPath) : void 0;
125078
- if (references) {
125079
- state.exportedModulesMap.set(sourceFile.resolvedPath, references);
125080
- } else {
125081
- state.exportedModulesMap.deleteKey(sourceFile.resolvedPath);
125082
- }
125083
- }
125207
+ if (host.storeSignatureInfo)
125208
+ (state.signatureInfo ?? (state.signatureInfo = /* @__PURE__ */ new Map())).set(sourceFile.resolvedPath, 2 /* UsedVersion */);
125084
125209
  }
125085
125210
  (state.oldSignatures || (state.oldSignatures = /* @__PURE__ */ new Map())).set(sourceFile.resolvedPath, prevSignature || false);
125086
125211
  (state.hasCalledUpdateShapeSignature || (state.hasCalledUpdateShapeSignature = /* @__PURE__ */ new Set())).add(sourceFile.resolvedPath);
@@ -125088,28 +125213,6 @@ var BuilderState;
125088
125213
  return latestSignature !== prevSignature;
125089
125214
  }
125090
125215
  BuilderState2.updateShapeSignature = updateShapeSignature;
125091
- function updateExportedModules(state, sourceFile, exportedModulesFromDeclarationEmit) {
125092
- if (!state.exportedModulesMap)
125093
- return;
125094
- (state.oldExportedModulesMap || (state.oldExportedModulesMap = /* @__PURE__ */ new Map())).set(sourceFile.resolvedPath, state.exportedModulesMap.getValues(sourceFile.resolvedPath) || false);
125095
- const exportedModules = getExportedModules(exportedModulesFromDeclarationEmit);
125096
- if (exportedModules) {
125097
- state.exportedModulesMap.set(sourceFile.resolvedPath, exportedModules);
125098
- } else {
125099
- state.exportedModulesMap.deleteKey(sourceFile.resolvedPath);
125100
- }
125101
- }
125102
- BuilderState2.updateExportedModules = updateExportedModules;
125103
- function getExportedModules(exportedModulesFromDeclarationEmit) {
125104
- let exportedModules;
125105
- exportedModulesFromDeclarationEmit == null ? void 0 : exportedModulesFromDeclarationEmit.forEach(
125106
- (symbol) => getReferencedFilesFromImportedModuleSymbol(symbol).forEach(
125107
- (path) => (exportedModules ?? (exportedModules = /* @__PURE__ */ new Set())).add(path)
125108
- )
125109
- );
125110
- return exportedModules;
125111
- }
125112
- BuilderState2.getExportedModules = getExportedModules;
125113
125216
  function getAllDependencies(state, programOfThisState, sourceFile) {
125114
125217
  const compilerOptions = programOfThisState.getCompilerOptions();
125115
125218
  if (compilerOptions.outFile) {
@@ -125484,7 +125587,7 @@ function assertSourceFileOkWithoutNextAffectedCall(state, sourceFile) {
125484
125587
  Debug.assert(!sourceFile || !state.affectedFiles || state.affectedFiles[state.affectedFilesIndex - 1] !== sourceFile || !state.semanticDiagnosticsPerFile.has(sourceFile.resolvedPath));
125485
125588
  }
125486
125589
  function getNextAffectedFile(state, cancellationToken, host) {
125487
- var _a, _b;
125590
+ var _a;
125488
125591
  while (true) {
125489
125592
  const { affectedFiles } = state;
125490
125593
  if (affectedFiles) {
@@ -125508,7 +125611,6 @@ function getNextAffectedFile(state, cancellationToken, host) {
125508
125611
  state.changedFilesSet.delete(state.currentChangedFilePath);
125509
125612
  state.currentChangedFilePath = void 0;
125510
125613
  (_a = state.oldSignatures) == null ? void 0 : _a.clear();
125511
- (_b = state.oldExportedModulesMap) == null ? void 0 : _b.clear();
125512
125614
  state.affectedFiles = void 0;
125513
125615
  }
125514
125616
  const nextKey = state.changedFilesSet.keys().next();
@@ -125669,7 +125771,7 @@ function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, hos
125669
125771
  }
125670
125772
  function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, host) {
125671
125773
  var _a;
125672
- if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath))
125774
+ if (!state.referencedMap || !state.changedFilesSet.has(affectedFile.resolvedPath))
125673
125775
  return;
125674
125776
  if (!isChangedSignature(state, affectedFile.resolvedPath))
125675
125777
  return;
@@ -125692,7 +125794,7 @@ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile
125692
125794
  }
125693
125795
  }
125694
125796
  const seenFileAndExportsOfFile = /* @__PURE__ */ new Set();
125695
- (_a = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) == null ? void 0 : _a.forEach((exportedFromPath) => {
125797
+ (_a = state.referencedMap.getKeys(affectedFile.resolvedPath)) == null ? void 0 : _a.forEach((exportedFromPath) => {
125696
125798
  if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, host))
125697
125799
  return true;
125698
125800
  const references = state.referencedMap.getKeys(exportedFromPath);
@@ -125706,27 +125808,17 @@ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile
125706
125808
  });
125707
125809
  }
125708
125810
  function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, host) {
125709
- var _a, _b;
125811
+ var _a;
125710
125812
  if (!tryAddToSet(seenFileAndExportsOfFile, filePath))
125711
125813
  return void 0;
125712
125814
  if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, host))
125713
125815
  return true;
125714
125816
  handleDtsMayChangeOf(state, filePath, cancellationToken, host);
125715
- (_a = state.exportedModulesMap.getKeys(filePath)) == null ? void 0 : _a.forEach(
125716
- (exportedFromPath) => handleDtsMayChangeOfFileAndExportsOfFile(
125717
- state,
125718
- exportedFromPath,
125719
- seenFileAndExportsOfFile,
125720
- cancellationToken,
125721
- host
125722
- )
125723
- );
125724
- (_b = state.referencedMap.getKeys(filePath)) == null ? void 0 : _b.forEach(
125725
- (referencingFilePath) => !seenFileAndExportsOfFile.has(referencingFilePath) && // Not already removed diagnostic file
125726
- handleDtsMayChangeOf(
125727
- // Dont add to seen since this is not yet done with the export removal
125817
+ (_a = state.referencedMap.getKeys(filePath)) == null ? void 0 : _a.forEach(
125818
+ (referencingFilePath) => handleDtsMayChangeOfFileAndExportsOfFile(
125728
125819
  state,
125729
125820
  referencingFilePath,
125821
+ seenFileAndExportsOfFile,
125730
125822
  cancellationToken,
125731
125823
  host
125732
125824
  )
@@ -125841,18 +125933,6 @@ function getBuildInfo2(state) {
125841
125933
  toFileIdListId(state.referencedMap.getValues(key))
125842
125934
  ]);
125843
125935
  }
125844
- let exportedModulesMap;
125845
- if (state.exportedModulesMap) {
125846
- exportedModulesMap = mapDefined(arrayFrom(state.exportedModulesMap.keys()).sort(compareStringsCaseSensitive), (key) => {
125847
- var _a2;
125848
- const oldValue = (_a2 = state.oldExportedModulesMap) == null ? void 0 : _a2.get(key);
125849
- if (oldValue === void 0)
125850
- return [toFileId(key), toFileIdListId(state.exportedModulesMap.getValues(key))];
125851
- if (oldValue)
125852
- return [toFileId(key), toFileIdListId(oldValue)];
125853
- return void 0;
125854
- });
125855
- }
125856
125936
  const semanticDiagnosticsPerFile = convertToProgramBuildInfoDiagnostics(state.semanticDiagnosticsPerFile);
125857
125937
  let affectedFilesPendingEmit;
125858
125938
  if ((_a = state.affectedFilesPendingEmit) == null ? void 0 : _a.size) {
@@ -125891,7 +125971,6 @@ function getBuildInfo2(state) {
125891
125971
  options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions),
125892
125972
  fileIdsList,
125893
125973
  referencedMap,
125894
- exportedModulesMap,
125895
125974
  semanticDiagnosticsPerFile,
125896
125975
  emitDiagnosticsPerFile,
125897
125976
  affectedFilesPendingEmit,
@@ -126211,7 +126290,7 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
126211
126290
  if (!getEmitDeclarations(state.compilerOptions))
126212
126291
  return writeFile2 || maybeBind(host, host.writeFile);
126213
126292
  return (fileName, text, writeByteOrderMark, onError, sourceFiles, data) => {
126214
- var _a, _b, _c, _d;
126293
+ var _a, _b, _c;
126215
126294
  if (isDeclarationFileName(fileName)) {
126216
126295
  if (!state.compilerOptions.outFile) {
126217
126296
  Debug.assert((sourceFiles == null ? void 0 : sourceFiles.length) === 1);
@@ -126230,10 +126309,8 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
126230
126309
  if (!((_a = data == null ? void 0 : data.diagnostics) == null ? void 0 : _a.length))
126231
126310
  emitSignature = signature;
126232
126311
  if (signature !== file.version) {
126233
- if (host.storeFilesChangingSignatureDuringEmit)
126234
- (state.filesChangingSignature ?? (state.filesChangingSignature = /* @__PURE__ */ new Set())).add(file.resolvedPath);
126235
- if (state.exportedModulesMap)
126236
- BuilderState.updateExportedModules(state, file, file.exportedModulesFromDeclarationEmit);
126312
+ if (host.storeSignatureInfo)
126313
+ (state.signatureInfo ?? (state.signatureInfo = /* @__PURE__ */ new Map())).set(file.resolvedPath, 1 /* StoredSignatureAtEmit */);
126237
126314
  if (state.affectedFiles) {
126238
126315
  const existing = (_b = state.oldSignatures) == null ? void 0 : _b.get(file.resolvedPath);
126239
126316
  if (existing === void 0)
@@ -126241,14 +126318,13 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
126241
126318
  info.signature = signature;
126242
126319
  } else {
126243
126320
  info.signature = signature;
126244
- (_c = state.oldExportedModulesMap) == null ? void 0 : _c.clear();
126245
126321
  }
126246
126322
  }
126247
126323
  }
126248
126324
  }
126249
126325
  if (state.compilerOptions.composite) {
126250
126326
  const filePath = sourceFiles[0].resolvedPath;
126251
- emitSignature = handleNewSignature((_d = state.emitSignatures) == null ? void 0 : _d.get(filePath), emitSignature);
126327
+ emitSignature = handleNewSignature((_c = state.emitSignatures) == null ? void 0 : _c.get(filePath), emitSignature);
126252
126328
  if (!emitSignature)
126253
126329
  return;
126254
126330
  (state.emitSignatures ?? (state.emitSignatures = /* @__PURE__ */ new Map())).set(filePath, emitSignature);
@@ -126440,7 +126516,6 @@ function createBuilderProgramUsingProgramBuildInfo(buildInfo, buildInfoPath, hos
126440
126516
  fileInfos,
126441
126517
  compilerOptions: program.options ? convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
126442
126518
  referencedMap: toManyToManyPathMap(program.referencedMap),
126443
- exportedModulesMap: toManyToManyPathMap(program.exportedModulesMap),
126444
126519
  semanticDiagnosticsPerFile: toPerFileDiagnostics(program.semanticDiagnosticsPerFile),
126445
126520
  emitDiagnosticsPerFile: toPerFileDiagnostics(program.emitDiagnosticsPerFile),
126446
126521
  hasReusableDiagnostic: true,
@@ -128110,7 +128185,7 @@ function createCompilerHostFromProgramHost(host, getCompilerOptions, directorySt
128110
128185
  getEnvironmentVariable: maybeBind(host, host.getEnvironmentVariable) || (() => ""),
128111
128186
  createHash: maybeBind(host, host.createHash),
128112
128187
  readDirectory: maybeBind(host, host.readDirectory),
128113
- storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit,
128188
+ storeSignatureInfo: host.storeSignatureInfo,
128114
128189
  jsDocParsingMode: host.jsDocParsingMode
128115
128190
  };
128116
128191
  return compilerHost;
@@ -128177,7 +128252,7 @@ function createProgramHost(system, createProgram2) {
128177
128252
  writeFile: (path, data, writeByteOrderMark) => system.writeFile(path, data, writeByteOrderMark),
128178
128253
  createHash: maybeBind(system, system.createHash),
128179
128254
  createProgram: createProgram2 || createEmitAndSemanticDiagnosticsBuilderProgram,
128180
- storeFilesChangingSignatureDuringEmit: system.storeFilesChangingSignatureDuringEmit,
128255
+ storeSignatureInfo: system.storeSignatureInfo,
128181
128256
  now: maybeBind(system, system.now)
128182
128257
  };
128183
128258
  }
@@ -128283,7 +128358,7 @@ function createIncrementalCompilerHost(options, system = sys) {
128283
128358
  system
128284
128359
  );
128285
128360
  host.createHash = maybeBind(system, system.createHash);
128286
- host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit;
128361
+ host.storeSignatureInfo = system.storeSignatureInfo;
128287
128362
  setGetSourceFileAsHashVersioned(host);
128288
128363
  changeCompilerHostLikeToUseCache(host, (fileName) => toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName));
128289
128364
  return host;
@@ -139133,15 +139208,25 @@ registerRefactor(refactorName3, {
139133
139208
  extractToTypeDefAction.kind
139134
139209
  ],
139135
139210
  getAvailableActions: function getRefactorActionsToExtractType(context) {
139136
- const info = getRangeToExtract(context, context.triggerReason === "invoked");
139211
+ const { info, affectedTextRange } = getRangeToExtract(context, context.triggerReason === "invoked");
139137
139212
  if (!info)
139138
139213
  return emptyArray;
139139
139214
  if (!isRefactorErrorInfo(info)) {
139140
- return [{
139215
+ const refactorInfo = [{
139141
139216
  name: refactorName3,
139142
139217
  description: getLocaleSpecificMessage(Diagnostics.Extract_type),
139143
139218
  actions: info.isJS ? [extractToTypeDefAction] : append([extractToTypeAliasAction], info.typeElements && extractToInterfaceAction)
139144
139219
  }];
139220
+ return refactorInfo.map((info2) => ({
139221
+ ...info2,
139222
+ actions: info2.actions.map((action) => ({
139223
+ ...action,
139224
+ range: affectedTextRange ? {
139225
+ start: { line: getLineAndCharacterOfPosition(context.file, affectedTextRange.pos).line, offset: getLineAndCharacterOfPosition(context.file, affectedTextRange.pos).character },
139226
+ end: { line: getLineAndCharacterOfPosition(context.file, affectedTextRange.end).line, offset: getLineAndCharacterOfPosition(context.file, affectedTextRange.end).character }
139227
+ } : void 0
139228
+ }))
139229
+ }));
139145
139230
  }
139146
139231
  if (context.preferences.provideRefactorNotApplicableReason) {
139147
139232
  return [{
@@ -139158,7 +139243,7 @@ registerRefactor(refactorName3, {
139158
139243
  },
139159
139244
  getEditsForAction: function getRefactorEditsToExtractType(context, actionName2) {
139160
139245
  const { file } = context;
139161
- const info = getRangeToExtract(context);
139246
+ const { info } = getRangeToExtract(context);
139162
139247
  Debug.assert(info && !isRefactorErrorInfo(info), "Expected to find a range to extract");
139163
139248
  const name = getUniqueName("NewType", file);
139164
139249
  const edits = ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
@@ -139194,14 +139279,14 @@ function getRangeToExtract(context, considerEmptySpans = true) {
139194
139279
  const isCursorRequest = range.pos === range.end && considerEmptySpans;
139195
139280
  const firstType = getFirstTypeAt(file, startPosition, range, isCursorRequest);
139196
139281
  if (!firstType || !isTypeNode(firstType))
139197
- return { error: getLocaleSpecificMessage(Diagnostics.Selection_is_not_a_valid_type_node) };
139282
+ return { info: { error: getLocaleSpecificMessage(Diagnostics.Selection_is_not_a_valid_type_node) }, affectedTextRange: void 0 };
139198
139283
  const checker = context.program.getTypeChecker();
139199
139284
  const enclosingNode = getEnclosingNode(firstType, isJS);
139200
139285
  if (enclosingNode === void 0)
139201
- return { error: getLocaleSpecificMessage(Diagnostics.No_type_could_be_extracted_from_this_type_node) };
139286
+ return { info: { error: getLocaleSpecificMessage(Diagnostics.No_type_could_be_extracted_from_this_type_node) }, affectedTextRange: void 0 };
139202
139287
  const expandedFirstType = getExpandedSelectionNode(firstType, enclosingNode);
139203
139288
  if (!isTypeNode(expandedFirstType))
139204
- return { error: getLocaleSpecificMessage(Diagnostics.Selection_is_not_a_valid_type_node) };
139289
+ return { info: { error: getLocaleSpecificMessage(Diagnostics.Selection_is_not_a_valid_type_node) }, affectedTextRange: void 0 };
139205
139290
  const typeList = [];
139206
139291
  if ((isUnionTypeNode(expandedFirstType.parent) || isIntersectionTypeNode(expandedFirstType.parent)) && range.end > firstType.end) {
139207
139292
  addRange(
@@ -139212,11 +139297,11 @@ function getRangeToExtract(context, considerEmptySpans = true) {
139212
139297
  );
139213
139298
  }
139214
139299
  const selection = typeList.length > 1 ? typeList : expandedFirstType;
139215
- const typeParameters = collectTypeParameters(checker, selection, enclosingNode, file);
139300
+ const { typeParameters, affectedTextRange } = collectTypeParameters(checker, selection, enclosingNode, file);
139216
139301
  if (!typeParameters)
139217
- return { error: getLocaleSpecificMessage(Diagnostics.No_type_could_be_extracted_from_this_type_node) };
139302
+ return { info: { error: getLocaleSpecificMessage(Diagnostics.No_type_could_be_extracted_from_this_type_node) }, affectedTextRange: void 0 };
139218
139303
  const typeElements = flattenTypeLiteralNodeReference(checker, selection);
139219
- return { isJS, selection, enclosingNode, typeParameters, typeElements };
139304
+ return { info: { isJS, selection, enclosingNode, typeParameters, typeElements }, affectedTextRange };
139220
139305
  }
139221
139306
  function getFirstTypeAt(file, startPosition, range, isCursorRequest) {
139222
139307
  const currentNodes = [
@@ -139270,12 +139355,12 @@ function rangeContainsSkipTrivia(r1, node, file) {
139270
139355
  function collectTypeParameters(checker, selection, enclosingNode, file) {
139271
139356
  const result = [];
139272
139357
  const selectionArray = toArray(selection);
139273
- const selectionRange = { pos: selectionArray[0].pos, end: selectionArray[selectionArray.length - 1].end };
139358
+ const selectionRange = { pos: selectionArray[0].getStart(file), end: selectionArray[selectionArray.length - 1].end };
139274
139359
  for (const t of selectionArray) {
139275
139360
  if (visitor(t))
139276
- return void 0;
139361
+ return { typeParameters: void 0, affectedTextRange: void 0 };
139277
139362
  }
139278
- return result;
139363
+ return { typeParameters: result, affectedTextRange: selectionRange };
139279
139364
  function visitor(node) {
139280
139365
  if (isTypeReferenceNode(node)) {
139281
139366
  if (isIdentifier(node.typeName)) {
@@ -139641,7 +139726,12 @@ registerRefactor(refactorName5, {
139641
139726
  getAvailableActions: function getRefactorActionsToMoveToNewFile(context) {
139642
139727
  const statements = getStatementsToMove(context);
139643
139728
  if (context.preferences.allowTextChangesInNewFiles && statements) {
139644
- return [{ name: refactorName5, description, actions: [moveToNewFileAction] }];
139729
+ const file = context.file;
139730
+ const affectedTextRange = {
139731
+ start: { line: getLineAndCharacterOfPosition(file, statements.all[0].getStart(file)).line, offset: getLineAndCharacterOfPosition(file, statements.all[0].getStart(file)).character },
139732
+ end: { line: getLineAndCharacterOfPosition(file, last(statements.all).end).line, offset: getLineAndCharacterOfPosition(file, last(statements.all).end).character }
139733
+ };
139734
+ return [{ name: refactorName5, description, actions: [{ ...moveToNewFileAction, range: affectedTextRange }] }];
139645
139735
  }
139646
139736
  if (context.preferences.provideRefactorNotApplicableReason) {
139647
139737
  return [{ name: refactorName5, description, actions: [{ ...moveToNewFileAction, notApplicableReason: getLocaleSpecificMessage(Diagnostics.Selection_is_not_a_valid_statement_or_statements) }] }];
@@ -139747,12 +139837,12 @@ var moveToFileAction = {
139747
139837
  registerRefactor(refactorNameForMoveToFile, {
139748
139838
  kinds: [moveToFileAction.kind],
139749
139839
  getAvailableActions: function getRefactorActionsToMoveToFile(context, interactiveRefactorArguments) {
139840
+ const file = context.file;
139750
139841
  const statements = getStatementsToMove(context);
139751
139842
  if (!interactiveRefactorArguments) {
139752
139843
  return emptyArray;
139753
139844
  }
139754
139845
  if (context.endPosition !== void 0) {
139755
- const file = context.file;
139756
139846
  const startNodeAncestor = findAncestor(getTokenAtPosition(file, context.startPosition), isBlockLike);
139757
139847
  const endNodeAncestor = findAncestor(getTokenAtPosition(file, context.endPosition), isBlockLike);
139758
139848
  if (startNodeAncestor && !isSourceFile(startNodeAncestor) && endNodeAncestor && !isSourceFile(endNodeAncestor)) {
@@ -139760,7 +139850,11 @@ registerRefactor(refactorNameForMoveToFile, {
139760
139850
  }
139761
139851
  }
139762
139852
  if (context.preferences.allowTextChangesInNewFiles && statements) {
139763
- return [{ name: refactorNameForMoveToFile, description: description2, actions: [moveToFileAction] }];
139853
+ const affectedTextRange = {
139854
+ start: { line: getLineAndCharacterOfPosition(file, statements.all[0].getStart(file)).line, offset: getLineAndCharacterOfPosition(file, statements.all[0].getStart(file)).character },
139855
+ end: { line: getLineAndCharacterOfPosition(file, last(statements.all).end).line, offset: getLineAndCharacterOfPosition(file, last(statements.all).end).character }
139856
+ };
139857
+ return [{ name: refactorNameForMoveToFile, description: description2, actions: [{ ...moveToFileAction, range: affectedTextRange }] }];
139764
139858
  }
139765
139859
  if (context.preferences.provideRefactorNotApplicableReason) {
139766
139860
  return [{ name: refactorNameForMoveToFile, description: description2, actions: [{ ...moveToFileAction, notApplicableReason: getLocaleSpecificMessage(Diagnostics.Selection_is_not_a_valid_statement_or_statements) }] }];
@@ -142318,7 +142412,7 @@ function getRefactorActionsToExtractSymbol(context) {
142318
142412
  }
142319
142413
  return errors;
142320
142414
  }
142321
- const extractions = getPossibleExtractions(targetRange, context);
142415
+ const { affectedTextRange, extractions } = getPossibleExtractions(targetRange, context);
142322
142416
  if (extractions === void 0) {
142323
142417
  return emptyArray;
142324
142418
  }
@@ -142338,7 +142432,11 @@ function getRefactorActionsToExtractSymbol(context) {
142338
142432
  functionActions.push({
142339
142433
  description: description3,
142340
142434
  name: `function_scope_${i}`,
142341
- kind: extractFunctionAction.kind
142435
+ kind: extractFunctionAction.kind,
142436
+ range: {
142437
+ start: { line: getLineAndCharacterOfPosition(context.file, affectedTextRange.pos).line, offset: getLineAndCharacterOfPosition(context.file, affectedTextRange.pos).character },
142438
+ end: { line: getLineAndCharacterOfPosition(context.file, affectedTextRange.end).line, offset: getLineAndCharacterOfPosition(context.file, affectedTextRange.end).character }
142439
+ }
142342
142440
  });
142343
142441
  }
142344
142442
  } else if (!innermostErrorFunctionAction) {
@@ -142358,7 +142456,11 @@ function getRefactorActionsToExtractSymbol(context) {
142358
142456
  constantActions.push({
142359
142457
  description: description3,
142360
142458
  name: `constant_scope_${i}`,
142361
- kind: extractConstantAction.kind
142459
+ kind: extractConstantAction.kind,
142460
+ range: {
142461
+ start: { line: getLineAndCharacterOfPosition(context.file, affectedTextRange.pos).line, offset: getLineAndCharacterOfPosition(context.file, affectedTextRange.pos).character },
142462
+ end: { line: getLineAndCharacterOfPosition(context.file, affectedTextRange.end).line, offset: getLineAndCharacterOfPosition(context.file, affectedTextRange.end).character }
142463
+ }
142362
142464
  });
142363
142465
  }
142364
142466
  } else if (!innermostErrorConstantAction) {
@@ -142797,7 +142899,7 @@ function getConstantExtractionAtIndex(targetRange, context, requestedChangesInde
142797
142899
  return extractConstantInScope(expression, scopes[requestedChangesIndex], usagesPerScope[requestedChangesIndex], targetRange.facts, context);
142798
142900
  }
142799
142901
  function getPossibleExtractions(targetRange, context) {
142800
- const { scopes, readsAndWrites: { functionErrorsPerScope, constantErrorsPerScope } } = getPossibleExtractionsWorker(targetRange, context);
142902
+ const { scopes, affectedTextRange, readsAndWrites: { functionErrorsPerScope, constantErrorsPerScope } } = getPossibleExtractionsWorker(targetRange, context);
142801
142903
  const extractions = scopes.map((scope, i) => {
142802
142904
  const functionDescriptionPart = getDescriptionForFunctionInScope(scope);
142803
142905
  const constantDescriptionPart = getDescriptionForConstantInScope(scope);
@@ -142828,7 +142930,7 @@ function getPossibleExtractions(targetRange, context) {
142828
142930
  }
142829
142931
  };
142830
142932
  });
142831
- return extractions;
142933
+ return { affectedTextRange, extractions };
142832
142934
  }
142833
142935
  function getPossibleExtractionsWorker(targetRange, context) {
142834
142936
  const { file: sourceFile } = context;
@@ -142842,7 +142944,7 @@ function getPossibleExtractionsWorker(targetRange, context) {
142842
142944
  context.program.getTypeChecker(),
142843
142945
  context.cancellationToken
142844
142946
  );
142845
- return { scopes, readsAndWrites };
142947
+ return { scopes, affectedTextRange: enclosingTextRange, readsAndWrites };
142846
142948
  }
142847
142949
  function getDescriptionForFunctionInScope(scope) {
142848
142950
  return isFunctionLikeDeclaration(scope) ? "inner function" : isClassLike(scope) ? "method" : "function";
@@ -173559,6 +173661,7 @@ __export(ts_exports2, {
173559
173661
  SignatureCheckMode: () => SignatureCheckMode,
173560
173662
  SignatureFlags: () => SignatureFlags,
173561
173663
  SignatureHelp: () => ts_SignatureHelp_exports,
173664
+ SignatureInfo: () => SignatureInfo,
173562
173665
  SignatureKind: () => SignatureKind,
173563
173666
  SmartSelectionRange: () => ts_SmartSelectionRange_exports,
173564
173667
  SnippetKind: () => SnippetKind,
@@ -186056,7 +186159,8 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
186056
186159
  getApplicableRefactors(args) {
186057
186160
  const { file, project } = this.getFileAndProject(args);
186058
186161
  const scriptInfo = project.getScriptInfoForNormalizedPath(file);
186059
- return project.getLanguageService().getApplicableRefactors(file, this.extractPositionOrRange(args, scriptInfo), this.getPreferences(file), args.triggerReason, args.kind, args.includeInteractiveActions);
186162
+ const result = project.getLanguageService().getApplicableRefactors(file, this.extractPositionOrRange(args, scriptInfo), this.getPreferences(file), args.triggerReason, args.kind, args.includeInteractiveActions);
186163
+ return result.map((result2) => ({ ...result2, actions: result2.actions.map((action) => ({ ...action, range: action.range ? { start: convertToLocation({ line: action.range.start.line, character: action.range.start.offset }), end: convertToLocation({ line: action.range.end.line, character: action.range.end.offset }) } : void 0 })) }));
186060
186164
  }
186061
186165
  getEditsForRefactor(args, simplifiedResult) {
186062
186166
  const { file, project } = this.getFileAndProject(args);
@@ -187759,6 +187863,7 @@ if (typeof console !== "undefined") {
187759
187863
  SignatureCheckMode,
187760
187864
  SignatureFlags,
187761
187865
  SignatureHelp,
187866
+ SignatureInfo,
187762
187867
  SignatureKind,
187763
187868
  SmartSelectionRange,
187764
187869
  SnippetKind,