@typescript-deploys/pr-build 5.4.0-pr-56034-9 → 5.4.0-pr-49218-45

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/tsserver.js CHANGED
@@ -898,7 +898,6 @@ __export(server_exports, {
898
898
  getModuleSpecifierEndingPreference: () => getModuleSpecifierEndingPreference,
899
899
  getModuleSpecifierResolverHost: () => getModuleSpecifierResolverHost,
900
900
  getNameForExportedSymbol: () => getNameForExportedSymbol,
901
- getNameFromImportAttribute: () => getNameFromImportAttribute,
902
901
  getNameFromIndexInfo: () => getNameFromIndexInfo,
903
902
  getNameFromPropertyName: () => getNameFromPropertyName,
904
903
  getNameOfAccessExpression: () => getNameOfAccessExpression,
@@ -1656,7 +1655,6 @@ __export(server_exports, {
1656
1655
  isPackedArrayLiteral: () => isPackedArrayLiteral,
1657
1656
  isParameter: () => isParameter,
1658
1657
  isParameterDeclaration: () => isParameterDeclaration,
1659
- isParameterOrCatchClauseVariable: () => isParameterOrCatchClauseVariable,
1660
1658
  isParameterPropertyDeclaration: () => isParameterPropertyDeclaration,
1661
1659
  isParameterPropertyModifier: () => isParameterPropertyModifier,
1662
1660
  isParenthesizedExpression: () => isParenthesizedExpression,
@@ -2342,7 +2340,7 @@ module.exports = __toCommonJS(server_exports);
2342
2340
 
2343
2341
  // src/compiler/corePublic.ts
2344
2342
  var versionMajorMinor = "5.4";
2345
- var version = `${versionMajorMinor}.0-insiders.20240108`;
2343
+ var version = `${versionMajorMinor}.0-insiders.20240110`;
2346
2344
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2347
2345
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2348
2346
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -6601,7 +6599,6 @@ var InternalSymbolName = /* @__PURE__ */ ((InternalSymbolName2) => {
6601
6599
  InternalSymbolName2["Default"] = "default";
6602
6600
  InternalSymbolName2["This"] = "this";
6603
6601
  InternalSymbolName2["InstantiationExpression"] = "__instantiationExpression";
6604
- InternalSymbolName2["ImportAttributes"] = "__importAttributes";
6605
6602
  return InternalSymbolName2;
6606
6603
  })(InternalSymbolName || {});
6607
6604
  var NodeCheckFlags = /* @__PURE__ */ ((NodeCheckFlags2) => {
@@ -16549,7 +16546,7 @@ function isPartOfTypeNode(node) {
16549
16546
  case 116 /* VoidKeyword */:
16550
16547
  return node.parent.kind !== 222 /* VoidExpression */;
16551
16548
  case 233 /* ExpressionWithTypeArguments */:
16552
- return isHeritageClause(node.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(node);
16549
+ return isPartOfTypeExpressionWithTypeArguments(node);
16553
16550
  case 168 /* TypeParameter */:
16554
16551
  return node.parent.kind === 200 /* MappedType */ || node.parent.kind === 195 /* InferType */;
16555
16552
  case 80 /* Identifier */:
@@ -16574,7 +16571,7 @@ function isPartOfTypeNode(node) {
16574
16571
  }
16575
16572
  switch (parent2.kind) {
16576
16573
  case 233 /* ExpressionWithTypeArguments */:
16577
- return isHeritageClause(parent2.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(parent2);
16574
+ return isPartOfTypeExpressionWithTypeArguments(parent2);
16578
16575
  case 168 /* TypeParameter */:
16579
16576
  return node === parent2.constraint;
16580
16577
  case 352 /* JSDocTemplateTag */:
@@ -16608,6 +16605,9 @@ function isPartOfTypeNode(node) {
16608
16605
  }
16609
16606
  return false;
16610
16607
  }
16608
+ function isPartOfTypeExpressionWithTypeArguments(node) {
16609
+ return isJSDocImplementsTag(node.parent) || isJSDocAugmentsTag(node.parent) || isHeritageClause(node.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(node);
16610
+ }
16611
16611
  function isChildOfNodeWithKind(node, kind) {
16612
16612
  while (node) {
16613
16613
  if (node.kind === kind) {
@@ -20243,7 +20243,7 @@ function Symbol4(flags, name) {
20243
20243
  this.exportSymbol = void 0;
20244
20244
  this.constEnumOnlyModule = void 0;
20245
20245
  this.isReferenced = void 0;
20246
- this.isAssigned = void 0;
20246
+ this.lastAssignmentPos = void 0;
20247
20247
  this.links = void 0;
20248
20248
  }
20249
20249
  function Type3(checker, flags) {
@@ -21718,10 +21718,6 @@ function isInfinityOrNaNString(name) {
21718
21718
  function isCatchClauseVariableDeclaration(node) {
21719
21719
  return node.kind === 260 /* VariableDeclaration */ && node.parent.kind === 299 /* CatchClause */;
21720
21720
  }
21721
- function isParameterOrCatchClauseVariable(symbol) {
21722
- const declaration = symbol.valueDeclaration && getRootDeclaration(symbol.valueDeclaration);
21723
- return !!declaration && (isParameter(declaration) || isCatchClauseVariableDeclaration(declaration));
21724
- }
21725
21721
  function isFunctionExpressionOrArrowFunction(node) {
21726
21722
  return node.kind === 218 /* FunctionExpression */ || node.kind === 219 /* ArrowFunction */;
21727
21723
  }
@@ -21906,9 +21902,6 @@ var stringReplace = String.prototype.replace;
21906
21902
  function replaceFirstStar(s, replacement) {
21907
21903
  return stringReplace.call(s, "*", replacement);
21908
21904
  }
21909
- function getNameFromImportAttribute(node) {
21910
- return isIdentifier(node.name) ? node.name.escapedText : escapeLeadingUnderscores(node.name.text);
21911
- }
21912
21905
 
21913
21906
  // src/compiler/factory/baseNodeFactory.ts
21914
21907
  function createBaseNodeFactory() {
@@ -49029,6 +49022,14 @@ function createTypeChecker(host) {
49029
49022
  emptyArray,
49030
49023
  emptyArray
49031
49024
  );
49025
+ var resolvingApparentMappedType = createAnonymousType(
49026
+ /*symbol*/
49027
+ void 0,
49028
+ emptySymbols,
49029
+ emptyArray,
49030
+ emptyArray,
49031
+ emptyArray
49032
+ );
49032
49033
  var markerSuperType = createTypeParameter();
49033
49034
  var markerSubType = createTypeParameter();
49034
49035
  markerSubType.constraint = markerSuperType;
@@ -49183,7 +49184,6 @@ function createTypeChecker(host) {
49183
49184
  var deferredGlobalImportMetaType;
49184
49185
  var deferredGlobalImportMetaExpressionType;
49185
49186
  var deferredGlobalImportCallOptionsType;
49186
- var deferredGlobalImportAttributesType;
49187
49187
  var deferredGlobalDisposableType;
49188
49188
  var deferredGlobalAsyncDisposableType;
49189
49189
  var deferredGlobalExtractSymbol;
@@ -52079,29 +52079,7 @@ function createTypeChecker(host) {
52079
52079
  function getContainersOfSymbol(symbol, enclosingDeclaration, meaning) {
52080
52080
  const container = getParentOfSymbol(symbol);
52081
52081
  if (container && !(symbol.flags & 262144 /* TypeParameter */)) {
52082
- const additionalContainers = mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer);
52083
- const reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration);
52084
- const objectLiteralContainer = getVariableDeclarationOfObjectLiteral(container, meaning);
52085
- if (enclosingDeclaration && container.flags & getQualifiedLeftMeaning(meaning) && getAccessibleSymbolChain(
52086
- container,
52087
- enclosingDeclaration,
52088
- 1920 /* Namespace */,
52089
- /*useOnlyExternalAliasing*/
52090
- false
52091
- )) {
52092
- return append(concatenate(concatenate([container], additionalContainers), reexportContainers), objectLiteralContainer);
52093
- }
52094
- const firstVariableMatch = !(container.flags & getQualifiedLeftMeaning(meaning)) && container.flags & 788968 /* Type */ && getDeclaredTypeOfSymbol(container).flags & 524288 /* Object */ && meaning === 111551 /* Value */ ? forEachSymbolTableInScope(enclosingDeclaration, (t) => {
52095
- return forEachEntry(t, (s) => {
52096
- if (s.flags & getQualifiedLeftMeaning(meaning) && getTypeOfSymbol(s) === getDeclaredTypeOfSymbol(container)) {
52097
- return s;
52098
- }
52099
- });
52100
- }) : void 0;
52101
- let res = firstVariableMatch ? [firstVariableMatch, ...additionalContainers, container] : [...additionalContainers, container];
52102
- res = append(res, objectLiteralContainer);
52103
- res = addRange(res, reexportContainers);
52104
- return res;
52082
+ return getWithAlternativeContainers(container);
52105
52083
  }
52106
52084
  const candidates = mapDefined(symbol.declarations, (d) => {
52107
52085
  if (!isAmbientModule(d) && d.parent) {
@@ -52123,7 +52101,40 @@ function createTypeChecker(host) {
52123
52101
  if (!length(candidates)) {
52124
52102
  return void 0;
52125
52103
  }
52126
- return mapDefined(candidates, (candidate) => getAliasForSymbolInContainer(candidate, symbol) ? candidate : void 0);
52104
+ const containers = mapDefined(candidates, (candidate) => getAliasForSymbolInContainer(candidate, symbol) ? candidate : void 0);
52105
+ let bestContainers = [];
52106
+ let alternativeContainers = [];
52107
+ for (const container2 of containers) {
52108
+ const [bestMatch, ...rest] = getWithAlternativeContainers(container2);
52109
+ bestContainers = append(bestContainers, bestMatch);
52110
+ alternativeContainers = addRange(alternativeContainers, rest);
52111
+ }
52112
+ return concatenate(bestContainers, alternativeContainers);
52113
+ function getWithAlternativeContainers(container2) {
52114
+ const additionalContainers = mapDefined(container2.declarations, fileSymbolIfFileSymbolExportEqualsContainer);
52115
+ const reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration);
52116
+ const objectLiteralContainer = getVariableDeclarationOfObjectLiteral(container2, meaning);
52117
+ if (enclosingDeclaration && container2.flags & getQualifiedLeftMeaning(meaning) && getAccessibleSymbolChain(
52118
+ container2,
52119
+ enclosingDeclaration,
52120
+ 1920 /* Namespace */,
52121
+ /*useOnlyExternalAliasing*/
52122
+ false
52123
+ )) {
52124
+ return append(concatenate(concatenate([container2], additionalContainers), reexportContainers), objectLiteralContainer);
52125
+ }
52126
+ const firstVariableMatch = !(container2.flags & getQualifiedLeftMeaning(meaning)) && container2.flags & 788968 /* Type */ && getDeclaredTypeOfSymbol(container2).flags & 524288 /* Object */ && meaning === 111551 /* Value */ ? forEachSymbolTableInScope(enclosingDeclaration, (t) => {
52127
+ return forEachEntry(t, (s) => {
52128
+ if (s.flags & getQualifiedLeftMeaning(meaning) && getTypeOfSymbol(s) === getDeclaredTypeOfSymbol(container2)) {
52129
+ return s;
52130
+ }
52131
+ });
52132
+ }) : void 0;
52133
+ let res = firstVariableMatch ? [firstVariableMatch, ...additionalContainers, container2] : [...additionalContainers, container2];
52134
+ res = append(res, objectLiteralContainer);
52135
+ res = addRange(res, reexportContainers);
52136
+ return res;
52137
+ }
52127
52138
  function fileSymbolIfFileSymbolExportEqualsContainer(d) {
52128
52139
  return container && getFileSymbolIfFileSymbolExportEqualsContainer(d, container);
52129
52140
  }
@@ -52161,6 +52172,13 @@ function createTypeChecker(host) {
52161
52172
  });
52162
52173
  }
52163
52174
  function getSymbolIfSameReference(s1, s2) {
52175
+ var _a, _b;
52176
+ if (s1.flags & 524288 /* TypeAlias */ && ((_a = s2.declarations) == null ? void 0 : _a.find(isTypeAlias))) {
52177
+ s2 = getDeclaredTypeOfTypeAlias(s2).aliasSymbol || s2;
52178
+ }
52179
+ if (s2.flags & 524288 /* TypeAlias */ && ((_b = s1.declarations) == null ? void 0 : _b.find(isTypeAlias))) {
52180
+ s1 = getDeclaredTypeOfTypeAlias(s1).aliasSymbol || s1;
52181
+ }
52164
52182
  if (getMergedSymbol(resolveSymbol(getMergedSymbol(s1))) === getMergedSymbol(resolveSymbol(getMergedSymbol(s2)))) {
52165
52183
  return s1;
52166
52184
  }
@@ -57484,24 +57502,6 @@ function createTypeChecker(host) {
57484
57502
  0 /* Normal */
57485
57503
  ), declaration, reportErrors2);
57486
57504
  }
57487
- function getTypeFromImportAttributes(node) {
57488
- const links = getNodeLinks(node);
57489
- if (!links.resolvedType) {
57490
- const symbol = createSymbol(4096 /* ObjectLiteral */, "__importAttributes" /* ImportAttributes */);
57491
- const members = createSymbolTable();
57492
- forEach(node.elements, (attr) => {
57493
- const member = createSymbol(4 /* Property */, getNameFromImportAttribute(attr));
57494
- member.parent = symbol;
57495
- member.links.type = checkImportAttribute(attr);
57496
- member.links.target = member;
57497
- members.set(member.escapedName, member);
57498
- });
57499
- const type = createAnonymousType(symbol, members, emptyArray, emptyArray, emptyArray);
57500
- type.objectFlags |= 128 /* ObjectLiteral */ | 262144 /* NonInferrableType */;
57501
- links.resolvedType = type;
57502
- }
57503
- return links.resolvedType;
57504
- }
57505
57505
  function isGlobalSymbolConstructor(node) {
57506
57506
  const symbol = getSymbolOfNode(node);
57507
57507
  const globalSymbol = getGlobalESSymbolConstructorTypeSymbol(
@@ -59917,14 +59917,30 @@ function createTypeChecker(host) {
59917
59917
  return !!(typeParameter.symbol && forEach(typeParameter.symbol.declarations, (decl) => isTypeParameterDeclaration(decl) && decl.default));
59918
59918
  }
59919
59919
  function getApparentTypeOfMappedType(type) {
59920
- return type.resolvedApparentType || (type.resolvedApparentType = getResolvedApparentTypeOfMappedType(type));
59920
+ if (type.resolvedApparentType) {
59921
+ if (type.resolvedApparentType === resolvingApparentMappedType) {
59922
+ return type.resolvedApparentType = type;
59923
+ }
59924
+ return type.resolvedApparentType;
59925
+ }
59926
+ type.resolvedApparentType = resolvingApparentMappedType;
59927
+ return type.resolvedApparentType = getResolvedApparentTypeOfMappedType(type);
59921
59928
  }
59922
59929
  function getResolvedApparentTypeOfMappedType(type) {
59923
- const typeVariable = getHomomorphicTypeVariable(type);
59924
- if (typeVariable && !type.declaration.nameType) {
59925
- const constraint = getConstraintOfTypeParameter(typeVariable);
59930
+ const mappedType = type.target || type;
59931
+ const typeVariable = getHomomorphicTypeVariable(mappedType);
59932
+ if (typeVariable && !mappedType.declaration.nameType) {
59933
+ let constraint;
59934
+ if (!type.target) {
59935
+ constraint = getConstraintOfTypeParameter(typeVariable);
59936
+ } else {
59937
+ const modifiersConstraint = getConstraintOfType(getModifiersTypeFromMappedType(type));
59938
+ if (modifiersConstraint) {
59939
+ constraint = getApparentType(modifiersConstraint);
59940
+ }
59941
+ }
59926
59942
  if (constraint && everyType(constraint, isArrayOrTupleType)) {
59927
- return instantiateType(type, prependTypeMapping(typeVariable, constraint, type.mapper));
59943
+ return instantiateType(mappedType, prependTypeMapping(typeVariable, constraint, mappedType.mapper));
59928
59944
  }
59929
59945
  }
59930
59946
  return type;
@@ -60015,6 +60031,7 @@ function createTypeChecker(host) {
60015
60031
  clone2.parent = (_c = (_b = singleProp.valueDeclaration) == null ? void 0 : _b.symbol) == null ? void 0 : _c.parent;
60016
60032
  clone2.links.containingType = containingType;
60017
60033
  clone2.links.mapper = links == null ? void 0 : links.mapper;
60034
+ clone2.links.writeType = getWriteTypeOfSymbol(singleProp);
60018
60035
  return clone2;
60019
60036
  } else {
60020
60037
  return singleProp;
@@ -61483,14 +61500,6 @@ function createTypeChecker(host) {
61483
61500
  reportErrors2
61484
61501
  )) || emptyObjectType;
61485
61502
  }
61486
- function getGlobalImportAttributesType(reportErrors2) {
61487
- return deferredGlobalImportAttributesType || (deferredGlobalImportAttributesType = getGlobalType(
61488
- "ImportAttributes",
61489
- /*arity*/
61490
- 0,
61491
- reportErrors2
61492
- )) || emptyObjectType;
61493
- }
61494
61503
  function getGlobalESSymbolConstructorSymbol(reportErrors2) {
61495
61504
  return deferredGlobalESSymbolConstructorSymbol || (deferredGlobalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol", reportErrors2));
61496
61505
  }
@@ -65258,7 +65267,37 @@ function createTypeChecker(host) {
65258
65267
  const restIndex = sourceRestType || targetRestType ? paramCount - 1 : -1;
65259
65268
  for (let i = 0; i < paramCount; i++) {
65260
65269
  const sourceType = i === restIndex ? getRestTypeAtPosition(source, i) : tryGetTypeAtPosition(source, i);
65261
- const targetType = i === restIndex ? getRestTypeAtPosition(target, i) : tryGetTypeAtPosition(target, i);
65270
+ let targetType = i === restIndex ? getRestTypeAtPosition(target, i) : tryGetTypeAtPosition(target, i);
65271
+ if (i === restIndex && targetType && sourceType && isTupleType(sourceType)) {
65272
+ targetType = mapType(targetType, (t) => {
65273
+ if (!isTupleType(t) || // When both sides are tuples of the same structure, we don't want to "propagate" types from elements of variable positions
65274
+ // to the following positions as that would disallow signatures of the exact same structures when trailing fixed elements are involved:
65275
+ //
65276
+ // let fn: (...rest: [...string[], number]) => void = (...rest: [...string[], number]) => {}; // ok
65277
+ //
65278
+ // Since we want to allow contextual types to flow into paremeters, we don't need to differentiate between rest and variadic elements
65279
+ // as that doesn't affect the contextual type of the parameter
65280
+ isTupleTypeStructureMatching(sourceType, t, 2 /* MatchVariable */)) {
65281
+ return t;
65282
+ }
65283
+ const elementTypes = [];
65284
+ const elementFlags = [];
65285
+ const sourceArity = getTypeReferenceArity(sourceType);
65286
+ const targetArity = getTypeReferenceArity(t);
65287
+ for (let i2 = 0; i2 < sourceArity; i2++) {
65288
+ if (i2 >= targetArity) {
65289
+ if (sourceType.target.elementFlags[i2] & 3 /* Fixed */) {
65290
+ elementTypes.push(undefinedType);
65291
+ elementFlags.push(sourceType.target.elementFlags[i2]);
65292
+ }
65293
+ continue;
65294
+ }
65295
+ elementTypes.push(getTupleElementType(t, i2));
65296
+ elementFlags.push(sourceType.target.elementFlags[i2]);
65297
+ }
65298
+ return createTupleType(elementTypes, elementFlags);
65299
+ });
65300
+ }
65262
65301
  if (sourceType && targetType) {
65263
65302
  const sourceSig = checkMode & 3 /* Callback */ || isInstantiatedGenericParameter(source, i) ? void 0 : getSingleCallSignature(getNonNullableType(sourceType));
65264
65303
  const targetSig = checkMode & 3 /* Callback */ || isInstantiatedGenericParameter(target, i) ? void 0 : getSingleCallSignature(getNonNullableType(targetType));
@@ -66648,6 +66687,18 @@ function createTypeChecker(host) {
66648
66687
  }
66649
66688
  return result2;
66650
66689
  }
66690
+ function getApparentMappedTypeKeys(nameType, targetType) {
66691
+ const modifiersType = getApparentType(getModifiersTypeFromMappedType(targetType));
66692
+ const mappedKeys = [];
66693
+ forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(
66694
+ modifiersType,
66695
+ 8576 /* StringOrNumberLiteralOrUnique */,
66696
+ /*stringsOnly*/
66697
+ false,
66698
+ (t) => void mappedKeys.push(instantiateType(nameType, appendTypeMapping(targetType.mapper, getTypeParameterFromMappedType(targetType), t)))
66699
+ );
66700
+ return getUnionType(mappedKeys);
66701
+ }
66651
66702
  function structuredTypeRelatedToWorker(source2, target2, reportErrors2, intersectionState, saveErrorInfo) {
66652
66703
  let result2;
66653
66704
  let originalErrorInfo;
@@ -66830,16 +66881,8 @@ function createTypeChecker(host) {
66830
66881
  const constraintType = getConstraintTypeFromMappedType(targetType);
66831
66882
  let targetKeys;
66832
66883
  if (nameType && isMappedTypeWithKeyofConstraintDeclaration(targetType)) {
66833
- const modifiersType = getApparentType(getModifiersTypeFromMappedType(targetType));
66834
- const mappedKeys = [];
66835
- forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(
66836
- modifiersType,
66837
- 8576 /* StringOrNumberLiteralOrUnique */,
66838
- /*stringsOnly*/
66839
- false,
66840
- (t) => void mappedKeys.push(instantiateType(nameType, appendTypeMapping(targetType.mapper, getTypeParameterFromMappedType(targetType), t)))
66841
- );
66842
- targetKeys = getUnionType([...mappedKeys, nameType]);
66884
+ const mappedKeys = getApparentMappedTypeKeys(nameType, targetType);
66885
+ targetKeys = getUnionType([mappedKeys, nameType]);
66843
66886
  } else {
66844
66887
  targetKeys = nameType || constraintType;
66845
66888
  }
@@ -67010,9 +67053,18 @@ function createTypeChecker(host) {
67010
67053
  }
67011
67054
  }
67012
67055
  } else if (sourceFlags & 4194304 /* Index */) {
67013
- if (result2 = isRelatedTo(keyofConstraintType, target2, 1 /* Source */, reportErrors2)) {
67056
+ const isDeferredMappedIndex = shouldDeferIndexType(source2.type, source2.indexFlags) && getObjectFlags(source2.type) & 32 /* Mapped */;
67057
+ if (result2 = isRelatedTo(keyofConstraintType, target2, 1 /* Source */, reportErrors2 && !isDeferredMappedIndex)) {
67014
67058
  return result2;
67015
67059
  }
67060
+ if (isDeferredMappedIndex) {
67061
+ const mappedType = source2.type;
67062
+ const nameType = getNameTypeFromMappedType(mappedType);
67063
+ const sourceMappedKeys = nameType && isMappedTypeWithKeyofConstraintDeclaration(mappedType) ? getApparentMappedTypeKeys(nameType, mappedType) : nameType || getConstraintTypeFromMappedType(mappedType);
67064
+ if (result2 = isRelatedTo(sourceMappedKeys, target2, 1 /* Source */, reportErrors2)) {
67065
+ return result2;
67066
+ }
67067
+ }
67016
67068
  } else if (sourceFlags & 134217728 /* TemplateLiteral */ && !(targetFlags & 524288 /* Object */)) {
67017
67069
  if (!(targetFlags & 134217728 /* TemplateLiteral */)) {
67018
67070
  const constraint = getBaseConstraintOfType(source2);
@@ -68502,8 +68554,11 @@ function createTypeChecker(host) {
68502
68554
  }
68503
68555
  return void 0;
68504
68556
  }
68505
- function isTupleTypeStructureMatching(t1, t2) {
68506
- return getTypeReferenceArity(t1) === getTypeReferenceArity(t2) && every(t1.target.elementFlags, (f, i) => (f & 12 /* Variable */) === (t2.target.elementFlags[i] & 12 /* Variable */));
68557
+ function isTupleTypeStructureMatching(t1, t2, tupleStructureComparisonKind) {
68558
+ return getTypeReferenceArity(t1) === getTypeReferenceArity(t2) && every(t1.target.elementFlags, (f1, i) => {
68559
+ const f2 = t2.target.elementFlags[i];
68560
+ return f1 === f2 || !!(tupleStructureComparisonKind & 1 /* MatchFixed */ && f1 & 3 /* Fixed */ && f2 & 3 /* Fixed */) || !!(tupleStructureComparisonKind & 2 /* MatchVariable */ && f1 & 12 /* Variable */ && f2 & 12 /* Variable */);
68561
+ });
68507
68562
  }
68508
68563
  function isZeroBigInt({ value }) {
68509
68564
  return value.base10Value === "0";
@@ -69711,7 +69766,7 @@ function createTypeChecker(host) {
69711
69766
  const targetArity = getTypeReferenceArity(target);
69712
69767
  const elementTypes = getTypeArguments(target);
69713
69768
  const elementFlags = target.target.elementFlags;
69714
- if (isTupleType(source) && isTupleTypeStructureMatching(source, target)) {
69769
+ if (isTupleType(source) && isTupleTypeStructureMatching(source, target, 1 /* MatchFixed */)) {
69715
69770
  for (let i = 0; i < targetArity; i++) {
69716
69771
  inferFromTypes(getTypeArguments(source)[i], elementTypes[i]);
69717
69772
  }
@@ -70949,7 +71004,7 @@ function createTypeChecker(host) {
70949
71004
  case 80 /* Identifier */:
70950
71005
  if (!isThisInTypeQuery(node)) {
70951
71006
  const symbol = getResolvedSymbol(node);
70952
- return isConstantVariable(symbol) || isParameterOrCatchClauseVariable(symbol) && !isSymbolAssigned(symbol);
71007
+ return isConstantVariable(symbol) || isParameterOrMutableLocalVariable(symbol) && !isSymbolAssigned(symbol);
70953
71008
  }
70954
71009
  break;
70955
71010
  case 211 /* PropertyAccessExpression */:
@@ -70958,7 +71013,7 @@ function createTypeChecker(host) {
70958
71013
  case 206 /* ObjectBindingPattern */:
70959
71014
  case 207 /* ArrayBindingPattern */:
70960
71015
  const rootDeclaration = getRootDeclaration(node.parent);
70961
- return isVariableDeclaration(rootDeclaration) && isVarConstLike(rootDeclaration);
71016
+ return isParameter(rootDeclaration) || isCatchClauseVariableDeclaration(rootDeclaration) ? !isSomeSymbolAssigned(rootDeclaration) : isVariableDeclaration(rootDeclaration) && isVarConstLike(rootDeclaration);
70962
71017
  }
70963
71018
  return false;
70964
71019
  }
@@ -72039,10 +72094,17 @@ function createTypeChecker(host) {
72039
72094
  return findAncestor(node.parent, (node2) => isFunctionLike(node2) && !getImmediatelyInvokedFunctionExpression(node2) || node2.kind === 268 /* ModuleBlock */ || node2.kind === 312 /* SourceFile */ || node2.kind === 172 /* PropertyDeclaration */);
72040
72095
  }
72041
72096
  function isSymbolAssigned(symbol) {
72042
- if (!symbol.valueDeclaration) {
72097
+ return !isPastLastAssignment(
72098
+ symbol,
72099
+ /*location*/
72100
+ void 0
72101
+ );
72102
+ }
72103
+ function isPastLastAssignment(symbol, location) {
72104
+ const parent2 = findAncestor(symbol.valueDeclaration, isFunctionOrSourceFile);
72105
+ if (!parent2) {
72043
72106
  return false;
72044
72107
  }
72045
- const parent2 = getRootDeclaration(symbol.valueDeclaration).parent;
72046
72108
  const links = getNodeLinks(parent2);
72047
72109
  if (!(links.flags & 131072 /* AssignmentsMarked */)) {
72048
72110
  links.flags |= 131072 /* AssignmentsMarked */;
@@ -72050,7 +72112,7 @@ function createTypeChecker(host) {
72050
72112
  markNodeAssignments(parent2);
72051
72113
  }
72052
72114
  }
72053
- return symbol.isAssigned || false;
72115
+ return !symbol.lastAssignmentPos || location && symbol.lastAssignmentPos < location.pos;
72054
72116
  }
72055
72117
  function isSomeSymbolAssigned(rootDeclaration) {
72056
72118
  Debug.assert(isVariableDeclaration(rootDeclaration) || isParameter(rootDeclaration));
@@ -72063,23 +72125,81 @@ function createTypeChecker(host) {
72063
72125
  return some(node.elements, (e) => e.kind !== 232 /* OmittedExpression */ && isSomeSymbolAssignedWorker(e.name));
72064
72126
  }
72065
72127
  function hasParentWithAssignmentsMarked(node) {
72066
- return !!findAncestor(node.parent, (node2) => (isFunctionLike(node2) || isCatchClause(node2)) && !!(getNodeLinks(node2).flags & 131072 /* AssignmentsMarked */));
72128
+ return !!findAncestor(node.parent, (node2) => isFunctionOrSourceFile(node2) && !!(getNodeLinks(node2).flags & 131072 /* AssignmentsMarked */));
72129
+ }
72130
+ function isFunctionOrSourceFile(node) {
72131
+ return isFunctionLikeDeclaration(node) || isSourceFile(node);
72067
72132
  }
72068
72133
  function markNodeAssignments(node) {
72069
- if (node.kind === 80 /* Identifier */) {
72070
- if (isAssignmentTarget(node)) {
72071
- const symbol = getResolvedSymbol(node);
72072
- if (isParameterOrCatchClauseVariable(symbol)) {
72073
- symbol.isAssigned = true;
72134
+ switch (node.kind) {
72135
+ case 80 /* Identifier */:
72136
+ if (isAssignmentTarget(node)) {
72137
+ const symbol = getResolvedSymbol(node);
72138
+ if (isParameterOrMutableLocalVariable(symbol) && symbol.lastAssignmentPos !== Number.MAX_VALUE) {
72139
+ const referencingFunction = findAncestor(node, isFunctionOrSourceFile);
72140
+ const declaringFunction = findAncestor(symbol.valueDeclaration, isFunctionOrSourceFile);
72141
+ symbol.lastAssignmentPos = referencingFunction === declaringFunction ? extendAssignmentPosition(node, symbol.valueDeclaration) : Number.MAX_VALUE;
72142
+ }
72143
+ }
72144
+ return;
72145
+ case 281 /* ExportSpecifier */:
72146
+ const exportDeclaration = node.parent.parent;
72147
+ if (!node.isTypeOnly && !exportDeclaration.isTypeOnly && !exportDeclaration.moduleSpecifier) {
72148
+ const symbol = resolveEntityName(
72149
+ node.propertyName || node.name,
72150
+ 111551 /* Value */,
72151
+ /*ignoreErrors*/
72152
+ true,
72153
+ /*dontResolveAlias*/
72154
+ true
72155
+ );
72156
+ if (symbol && isParameterOrMutableLocalVariable(symbol)) {
72157
+ symbol.lastAssignmentPos = Number.MAX_VALUE;
72158
+ }
72074
72159
  }
72160
+ return;
72161
+ case 264 /* InterfaceDeclaration */:
72162
+ case 265 /* TypeAliasDeclaration */:
72163
+ case 266 /* EnumDeclaration */:
72164
+ return;
72165
+ }
72166
+ if (isTypeNode(node)) {
72167
+ return;
72168
+ }
72169
+ forEachChild(node, markNodeAssignments);
72170
+ }
72171
+ function extendAssignmentPosition(node, declaration) {
72172
+ let pos = node.pos;
72173
+ while (node && node.pos > declaration.pos) {
72174
+ switch (node.kind) {
72175
+ case 243 /* VariableStatement */:
72176
+ case 244 /* ExpressionStatement */:
72177
+ case 245 /* IfStatement */:
72178
+ case 246 /* DoStatement */:
72179
+ case 247 /* WhileStatement */:
72180
+ case 248 /* ForStatement */:
72181
+ case 249 /* ForInStatement */:
72182
+ case 250 /* ForOfStatement */:
72183
+ case 254 /* WithStatement */:
72184
+ case 255 /* SwitchStatement */:
72185
+ case 258 /* TryStatement */:
72186
+ case 263 /* ClassDeclaration */:
72187
+ pos = node.end;
72075
72188
  }
72076
- } else {
72077
- forEachChild(node, markNodeAssignments);
72189
+ node = node.parent;
72078
72190
  }
72191
+ return pos;
72079
72192
  }
72080
72193
  function isConstantVariable(symbol) {
72081
72194
  return symbol.flags & 3 /* Variable */ && (getDeclarationNodeFlagsFromSymbol(symbol) & 6 /* Constant */) !== 0;
72082
72195
  }
72196
+ function isParameterOrMutableLocalVariable(symbol) {
72197
+ const declaration = symbol.valueDeclaration && getRootDeclaration(symbol.valueDeclaration);
72198
+ return !!declaration && (isParameter(declaration) || isVariableDeclaration(declaration) && (isCatchClause(declaration.parent) || isMutableLocalVariableDeclaration(declaration)));
72199
+ }
72200
+ function isMutableLocalVariableDeclaration(declaration) {
72201
+ return !!(declaration.parent.flags & 1 /* Let */) && !(getCombinedModifierFlags(declaration) & 32 /* Export */ || declaration.parent.parent.kind === 243 /* VariableStatement */ && isGlobalSourceFile(declaration.parent.parent.parent));
72202
+ }
72083
72203
  function parameterInitializerContainsUndefined(declaration) {
72084
72204
  const links = getNodeLinks(declaration);
72085
72205
  if (links.parameterInitializerContainsUndefined === void 0) {
@@ -72328,7 +72448,7 @@ function createTypeChecker(host) {
72328
72448
  const isModuleExports = symbol.flags & 134217728 /* ModuleExports */;
72329
72449
  const typeIsAutomatic = type === autoType || type === autoArrayType;
72330
72450
  const isAutomaticTypeInNonNull = typeIsAutomatic && node.parent.kind === 235 /* NonNullExpression */;
72331
- while (flowContainer !== declarationContainer && (flowContainer.kind === 218 /* FunctionExpression */ || flowContainer.kind === 219 /* ArrowFunction */ || isObjectLiteralOrClassExpressionMethodOrAccessor(flowContainer)) && (isConstantVariable(localOrExportSymbol) && type !== autoArrayType || isParameter2 && !isSymbolAssigned(localOrExportSymbol))) {
72451
+ while (flowContainer !== declarationContainer && (flowContainer.kind === 218 /* FunctionExpression */ || flowContainer.kind === 219 /* ArrowFunction */ || isObjectLiteralOrClassExpressionMethodOrAccessor(flowContainer)) && (isConstantVariable(localOrExportSymbol) && type !== autoArrayType || isParameterOrMutableLocalVariable(localOrExportSymbol) && isPastLastAssignment(localOrExportSymbol, node))) {
72332
72452
  flowContainer = getControlFlowContainer(flowContainer);
72333
72453
  }
72334
72454
  const assumeInitialized = isParameter2 || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || isSameScopedBindingElement(node, declaration) || type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */)) !== 0 || isInTypeQuery(node) || isInAmbientOrTypeNode(node) || node.parent.kind === 281 /* ExportSpecifier */) || node.parent.kind === 235 /* NonNullExpression */ || declaration.kind === 260 /* VariableDeclaration */ && declaration.exclamationToken || declaration.flags & 33554432 /* Ambient */;
@@ -73599,8 +73719,6 @@ function createTypeChecker(host) {
73599
73719
  case 286 /* JsxOpeningElement */:
73600
73720
  case 285 /* JsxSelfClosingElement */:
73601
73721
  return getContextualJsxElementAttributesType(parent2, contextFlags);
73602
- case 301 /* ImportAttribute */:
73603
- return getContextualImportAttributeType(parent2);
73604
73722
  }
73605
73723
  return void 0;
73606
73724
  }
@@ -73648,12 +73766,6 @@ function createTypeChecker(host) {
73648
73766
  }
73649
73767
  }
73650
73768
  }
73651
- function getContextualImportAttributeType(node) {
73652
- return getTypeOfPropertyOfContextualType(getGlobalImportAttributesType(
73653
- /*reportErrors*/
73654
- false
73655
- ), getNameFromImportAttribute(node));
73656
- }
73657
73769
  function getContextualJsxElementAttributesType(node, contextFlags) {
73658
73770
  if (isJsxOpeningElement(node) && contextFlags !== 4 /* Completions */) {
73659
73771
  const index = findContextualNode(
@@ -85739,13 +85851,6 @@ function createTypeChecker(host) {
85739
85851
  var _a;
85740
85852
  const node = declaration.attributes;
85741
85853
  if (node) {
85742
- const importAttributesType = getGlobalImportAttributesType(
85743
- /*reportErrors*/
85744
- true
85745
- );
85746
- if (importAttributesType !== emptyObjectType) {
85747
- checkTypeAssignableTo(getTypeFromImportAttributes(node), getNullableType(importAttributesType, 32768 /* Undefined */), node);
85748
- }
85749
85854
  const validForTypeAttributes = isExclusivelyTypeOnlyImportOrExport(declaration);
85750
85855
  const override = getResolutionModeOverride(node, validForTypeAttributes ? grammarErrorOnNode : void 0);
85751
85856
  const isImportAttributes2 = declaration.attributes.token === 118 /* WithKeyword */;
@@ -85765,9 +85870,6 @@ function createTypeChecker(host) {
85765
85870
  }
85766
85871
  }
85767
85872
  }
85768
- function checkImportAttribute(node) {
85769
- return getRegularTypeOfLiteralType(checkExpressionCached(node.value));
85770
- }
85771
85873
  function checkImportDeclaration(node) {
85772
85874
  if (checkGrammarModuleElementContext(node, isInJSFile(node) ? Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_module : Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module)) {
85773
85875
  return;
@@ -87183,12 +87285,6 @@ function createTypeChecker(host) {
87183
87285
  if (isMetaProperty(node.parent) && node.parent.keywordToken === node.kind) {
87184
87286
  return checkMetaPropertyKeyword(node.parent);
87185
87287
  }
87186
- if (isImportAttributes(node)) {
87187
- return getGlobalImportAttributesType(
87188
- /*reportErrors*/
87189
- false
87190
- );
87191
- }
87192
87288
  return errorType;
87193
87289
  }
87194
87290
  function getTypeOfAssignmentPattern(expr) {
@@ -118393,7 +118489,14 @@ function createPrinter(printerOptions = {}, handlers = {}) {
118393
118489
  function willEmitLeadingNewLine(node) {
118394
118490
  if (!currentSourceFile)
118395
118491
  return false;
118396
- if (some(getLeadingCommentRanges(currentSourceFile.text, node.pos), commentWillEmitNewLine))
118492
+ const leadingCommentRanges = getLeadingCommentRanges(currentSourceFile.text, node.pos);
118493
+ if (leadingCommentRanges) {
118494
+ const parseNode = getParseTreeNode(node);
118495
+ if (parseNode && isParenthesizedExpression(parseNode.parent)) {
118496
+ return true;
118497
+ }
118498
+ }
118499
+ if (some(leadingCommentRanges, commentWillEmitNewLine))
118397
118500
  return true;
118398
118501
  if (some(getSyntheticLeadingComments(node), commentWillEmitNewLine))
118399
118502
  return true;
@@ -152351,14 +152454,14 @@ function promoteFromTypeOnly(changes, aliasDeclaration, program, sourceFile, pre
152351
152454
  aliasDeclaration.name
152352
152455
  );
152353
152456
  const comparer = ts_OrganizeImports_exports.getOrganizeImportsComparer(preferences, sortKind === 2 /* CaseInsensitive */);
152354
- const insertionIndex = ts_OrganizeImports_exports.getImportSpecifierInsertionIndex(aliasDeclaration.parent.elements, newSpecifier, comparer);
152355
- if (aliasDeclaration.parent.elements.indexOf(aliasDeclaration) !== insertionIndex) {
152457
+ const insertionIndex = ts_OrganizeImports_exports.getImportSpecifierInsertionIndex(aliasDeclaration.parent.elements, newSpecifier, comparer, preferences);
152458
+ if (insertionIndex !== aliasDeclaration.parent.elements.indexOf(aliasDeclaration)) {
152356
152459
  changes.delete(sourceFile, aliasDeclaration);
152357
152460
  changes.insertImportSpecifierAtIndex(sourceFile, newSpecifier, aliasDeclaration.parent, insertionIndex);
152358
152461
  return aliasDeclaration;
152359
152462
  }
152360
152463
  }
152361
- changes.deleteRange(sourceFile, aliasDeclaration.getFirstToken());
152464
+ changes.deleteRange(sourceFile, { pos: getTokenPosOfNode(aliasDeclaration.getFirstToken()), end: getTokenPosOfNode(aliasDeclaration.propertyName ?? aliasDeclaration.name) });
152362
152465
  return aliasDeclaration;
152363
152466
  } else {
152364
152467
  Debug.assert(aliasDeclaration.parent.parent.isTypeOnly);
@@ -152454,7 +152557,7 @@ function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImpor
152454
152557
  const specifierSort = (existingSpecifiers == null ? void 0 : existingSpecifiers.length) && ts_OrganizeImports_exports.detectImportSpecifierSorting(existingSpecifiers, preferences);
152455
152558
  if (specifierSort && !(ignoreCaseForSorting && specifierSort === 1 /* CaseSensitive */)) {
152456
152559
  for (const spec of newSpecifiers) {
152457
- const insertionIndex = promoteFromTypeOnly2 && !spec.isTypeOnly ? 0 : ts_OrganizeImports_exports.getImportSpecifierInsertionIndex(existingSpecifiers, spec, comparer);
152560
+ const insertionIndex = promoteFromTypeOnly2 && !spec.isTypeOnly ? 0 : ts_OrganizeImports_exports.getImportSpecifierInsertionIndex(existingSpecifiers, spec, comparer, preferences);
152458
152561
  changes.insertImportSpecifierAtIndex(sourceFile, spec, clause.namedBindings, insertionIndex);
152459
152562
  }
152460
152563
  } else if (existingSpecifiers == null ? void 0 : existingSpecifiers.length) {
@@ -160809,7 +160912,7 @@ function getCompletionData(program, log, sourceFile, compilerOptions, position,
160809
160912
  return isIdentifier(e) ? e : isPropertyAccessExpression(e) ? getLeftMostName(e.expression) : void 0;
160810
160913
  }
160811
160914
  function tryGetGlobalSymbols() {
160812
- const result = tryGetObjectTypeLiteralInTypeArgumentCompletionSymbols() || tryGetObjectLikeCompletionSymbols() || tryGetImportCompletionSymbols() || tryGetImportOrExportClauseCompletionSymbols() || tryGetImportAttributesCompletionSymbols() || tryGetLocalNamedExportCompletionSymbols() || tryGetConstructorCompletion() || tryGetClassLikeCompletionSymbols() || tryGetJsxCompletionSymbols() || (getGlobalCompletions(), 1 /* Success */);
160915
+ const result = tryGetObjectTypeLiteralInTypeArgumentCompletionSymbols() || tryGetObjectLikeCompletionSymbols() || tryGetImportCompletionSymbols() || tryGetImportOrExportClauseCompletionSymbols() || tryGetLocalNamedExportCompletionSymbols() || tryGetConstructorCompletion() || tryGetClassLikeCompletionSymbols() || tryGetJsxCompletionSymbols() || (getGlobalCompletions(), 1 /* Success */);
160813
160916
  return result === 1 /* Success */;
160814
160917
  }
160815
160918
  function tryGetConstructorCompletion() {
@@ -161277,16 +161380,6 @@ function getCompletionData(program, log, sourceFile, compilerOptions, position,
161277
161380
  }
161278
161381
  return 1 /* Success */;
161279
161382
  }
161280
- function tryGetImportAttributesCompletionSymbols() {
161281
- if (contextToken === void 0)
161282
- return 0 /* Continue */;
161283
- const importAttributes = contextToken.kind === 19 /* OpenBraceToken */ || contextToken.kind === 28 /* CommaToken */ ? tryCast(contextToken.parent, isImportAttributes) : void 0;
161284
- if (importAttributes === void 0)
161285
- return 0 /* Continue */;
161286
- const existing = new Set(importAttributes.elements.map(getNameFromImportAttribute));
161287
- symbols = filter(typeChecker.getTypeAtLocation(importAttributes).getApparentProperties(), (attr) => !existing.has(attr.escapedName));
161288
- return 1 /* Success */;
161289
- }
161290
161383
  function tryGetLocalNamedExportCompletionSymbols() {
161291
161384
  var _a;
161292
161385
  const namedExports = contextToken && (contextToken.kind === 19 /* OpenBraceToken */ || contextToken.kind === 28 /* CommaToken */) ? tryCast(contextToken.parent, isNamedExports) : void 0;
@@ -167329,14 +167422,14 @@ function organizeImports(sourceFile, formatContext, host, program, preferences,
167329
167422
  if (shouldRemove)
167330
167423
  importGroup = removeUnusedImports(importGroup, sourceFile, program);
167331
167424
  if (shouldCombine)
167332
- importGroup = coalesceImportsWorker(importGroup, comparer, sourceFile);
167425
+ importGroup = coalesceImportsWorker(importGroup, comparer, sourceFile, preferences);
167333
167426
  if (shouldSort)
167334
167427
  importGroup = stableSort(importGroup, (s1, s2) => compareImportsOrRequireStatements(s1, s2, comparer));
167335
167428
  return importGroup;
167336
167429
  };
167337
167430
  topLevelImportGroupDecls.forEach((importGroupDecl) => organizeImportsWorker(importGroupDecl, processImportsOfSameModuleSpecifier));
167338
167431
  if (mode !== "RemoveUnused" /* RemoveUnused */) {
167339
- getTopLevelExportGroups(sourceFile).forEach((exportGroupDecl) => organizeImportsWorker(exportGroupDecl, (group2) => coalesceExportsWorker(group2, comparer)));
167432
+ getTopLevelExportGroups(sourceFile).forEach((exportGroupDecl) => organizeImportsWorker(exportGroupDecl, (group2) => coalesceExportsWorker(group2, comparer, preferences)));
167340
167433
  }
167341
167434
  for (const ambientModule of sourceFile.statements.filter(isAmbientModule)) {
167342
167435
  if (!ambientModule.body)
@@ -167345,7 +167438,7 @@ function organizeImports(sourceFile, formatContext, host, program, preferences,
167345
167438
  ambientModuleImportGroupDecls.forEach((importGroupDecl) => organizeImportsWorker(importGroupDecl, processImportsOfSameModuleSpecifier));
167346
167439
  if (mode !== "RemoveUnused" /* RemoveUnused */) {
167347
167440
  const ambientModuleExportDecls = ambientModule.body.statements.filter(isExportDeclaration);
167348
- organizeImportsWorker(ambientModuleExportDecls, (group2) => coalesceExportsWorker(group2, comparer));
167441
+ organizeImportsWorker(ambientModuleExportDecls, (group2) => coalesceExportsWorker(group2, comparer, preferences));
167349
167442
  }
167350
167443
  }
167351
167444
  return changeTracker.getChanges();
@@ -167477,11 +167570,11 @@ function hasModuleDeclarationMatchingSpecifier(sourceFile, moduleSpecifier) {
167477
167570
  function getExternalModuleName2(specifier) {
167478
167571
  return specifier !== void 0 && isStringLiteralLike(specifier) ? specifier.text : void 0;
167479
167572
  }
167480
- function coalesceImports(importGroup, ignoreCase, sourceFile) {
167573
+ function coalesceImports(importGroup, ignoreCase, sourceFile, preferences) {
167481
167574
  const comparer = getOrganizeImportsOrdinalStringComparer(ignoreCase);
167482
- return coalesceImportsWorker(importGroup, comparer, sourceFile);
167575
+ return coalesceImportsWorker(importGroup, comparer, sourceFile, preferences);
167483
167576
  }
167484
- function coalesceImportsWorker(importGroup, comparer, sourceFile) {
167577
+ function coalesceImportsWorker(importGroup, comparer, sourceFile, preferences) {
167485
167578
  if (importGroup.length === 0) {
167486
167579
  return importGroup;
167487
167580
  }
@@ -167535,7 +167628,7 @@ function coalesceImportsWorker(importGroup, comparer, sourceFile) {
167535
167628
  }
167536
167629
  newImportSpecifiers.push(...getNewImportSpecifiers(namedImports));
167537
167630
  const sortedImportSpecifiers = factory.createNodeArray(
167538
- sortSpecifiers(newImportSpecifiers, comparer),
167631
+ sortSpecifiers(newImportSpecifiers, comparer, preferences),
167539
167632
  firstNamedImport == null ? void 0 : firstNamedImport.importClause.namedBindings.elements.hasTrailingComma
167540
167633
  );
167541
167634
  const newNamedImports = sortedImportSpecifiers.length === 0 ? newDefaultImport ? void 0 : factory.createNamedImports(emptyArray) : firstNamedImport ? factory.updateNamedImports(firstNamedImport.importClause.namedBindings, sortedImportSpecifiers) : factory.createNamedImports(sortedImportSpecifiers);
@@ -167595,11 +167688,11 @@ function getCategorizedImports(importGroup) {
167595
167688
  regularImports
167596
167689
  };
167597
167690
  }
167598
- function coalesceExports(exportGroup, ignoreCase) {
167691
+ function coalesceExports(exportGroup, ignoreCase, preferences) {
167599
167692
  const comparer = getOrganizeImportsOrdinalStringComparer(ignoreCase);
167600
- return coalesceExportsWorker(exportGroup, comparer);
167693
+ return coalesceExportsWorker(exportGroup, comparer, preferences);
167601
167694
  }
167602
- function coalesceExportsWorker(exportGroup, comparer) {
167695
+ function coalesceExportsWorker(exportGroup, comparer, preferences) {
167603
167696
  if (exportGroup.length === 0) {
167604
167697
  return exportGroup;
167605
167698
  }
@@ -167614,7 +167707,7 @@ function coalesceExportsWorker(exportGroup, comparer) {
167614
167707
  }
167615
167708
  const newExportSpecifiers = [];
167616
167709
  newExportSpecifiers.push(...flatMap(exportGroup2, (i) => i.exportClause && isNamedExports(i.exportClause) ? i.exportClause.elements : emptyArray));
167617
- const sortedExportSpecifiers = sortSpecifiers(newExportSpecifiers, comparer);
167710
+ const sortedExportSpecifiers = sortSpecifiers(newExportSpecifiers, comparer, preferences);
167618
167711
  const exportDecl = exportGroup2[0];
167619
167712
  coalescedExports.push(
167620
167713
  factory.updateExportDeclaration(
@@ -167658,11 +167751,18 @@ function updateImportDeclarationAndClause(importDeclaration, name, namedBindings
167658
167751
  importDeclaration.attributes
167659
167752
  );
167660
167753
  }
167661
- function sortSpecifiers(specifiers, comparer) {
167662
- return stableSort(specifiers, (s1, s2) => compareImportOrExportSpecifiers(s1, s2, comparer));
167754
+ function sortSpecifiers(specifiers, comparer, preferences) {
167755
+ return stableSort(specifiers, (s1, s2) => compareImportOrExportSpecifiers(s1, s2, comparer, preferences));
167663
167756
  }
167664
- function compareImportOrExportSpecifiers(s1, s2, comparer) {
167665
- return compareBooleans(s1.isTypeOnly, s2.isTypeOnly) || comparer(s1.name.text, s2.name.text);
167757
+ function compareImportOrExportSpecifiers(s1, s2, comparer, preferences) {
167758
+ switch (preferences == null ? void 0 : preferences.organizeImportsTypeOrder) {
167759
+ case "first":
167760
+ return compareBooleans(s2.isTypeOnly, s1.isTypeOnly) || comparer(s1.name.text, s2.name.text);
167761
+ case "inline":
167762
+ return comparer(s1.name.text, s2.name.text);
167763
+ default:
167764
+ return compareBooleans(s1.isTypeOnly, s2.isTypeOnly) || comparer(s1.name.text, s2.name.text);
167765
+ }
167666
167766
  }
167667
167767
  function compareModuleSpecifiers2(m1, m2, ignoreCase) {
167668
167768
  const comparer = getOrganizeImportsOrdinalStringComparer(!!ignoreCase);
@@ -167784,8 +167884,26 @@ var ImportSpecifierSortingCache = class {
167784
167884
  }
167785
167885
  };
167786
167886
  var detectImportSpecifierSorting = memoizeCached((specifiers, preferences) => {
167787
- if (!arrayIsSorted(specifiers, (s1, s2) => compareBooleans(s1.isTypeOnly, s2.isTypeOnly))) {
167788
- return 0 /* None */;
167887
+ switch (preferences.organizeImportsTypeOrder) {
167888
+ case "first":
167889
+ if (!arrayIsSorted(specifiers, (s1, s2) => compareBooleans(s2.isTypeOnly, s1.isTypeOnly)))
167890
+ return 0 /* None */;
167891
+ break;
167892
+ case "inline":
167893
+ if (!arrayIsSorted(specifiers, (s1, s2) => {
167894
+ const comparer = getStringComparer(
167895
+ /*ignoreCase*/
167896
+ true
167897
+ );
167898
+ return comparer(s1.name.text, s2.name.text);
167899
+ })) {
167900
+ return 0 /* None */;
167901
+ }
167902
+ break;
167903
+ default:
167904
+ if (!arrayIsSorted(specifiers, (s1, s2) => compareBooleans(s1.isTypeOnly, s2.isTypeOnly)))
167905
+ return 0 /* None */;
167906
+ break;
167789
167907
  }
167790
167908
  const collateCaseSensitive = getOrganizeImportsComparer(
167791
167909
  preferences,
@@ -167797,14 +167915,29 @@ var detectImportSpecifierSorting = memoizeCached((specifiers, preferences) => {
167797
167915
  /*ignoreCase*/
167798
167916
  true
167799
167917
  );
167918
+ if (preferences.organizeImportsTypeOrder !== "inline") {
167919
+ const { type: regularImports, regular: typeImports } = groupBy(specifiers, (s) => s.isTypeOnly ? "type" : "regular");
167920
+ const regularCaseSensitivity = (regularImports == null ? void 0 : regularImports.length) ? detectSortCaseSensitivity(regularImports, (specifier) => specifier.name.text, collateCaseSensitive, collateCaseInsensitive) : void 0;
167921
+ const typeCaseSensitivity = (typeImports == null ? void 0 : typeImports.length) ? detectSortCaseSensitivity(typeImports, (specifier) => specifier.name.text ?? "", collateCaseSensitive, collateCaseInsensitive) : void 0;
167922
+ if (regularCaseSensitivity === void 0) {
167923
+ return typeCaseSensitivity ?? 0 /* None */;
167924
+ }
167925
+ if (typeCaseSensitivity === void 0) {
167926
+ return regularCaseSensitivity;
167927
+ }
167928
+ if (regularCaseSensitivity === 0 /* None */ || typeCaseSensitivity === 0 /* None */) {
167929
+ return 0 /* None */;
167930
+ }
167931
+ return typeCaseSensitivity & regularCaseSensitivity;
167932
+ }
167800
167933
  return detectSortCaseSensitivity(specifiers, (specifier) => specifier.name.text, collateCaseSensitive, collateCaseInsensitive);
167801
167934
  }, new ImportSpecifierSortingCache());
167802
167935
  function getImportDeclarationInsertionIndex(sortedImports, newImport, comparer) {
167803
167936
  const index = binarySearch(sortedImports, newImport, identity, (a, b) => compareImportsOrRequireStatements(a, b, comparer));
167804
167937
  return index < 0 ? ~index : index;
167805
167938
  }
167806
- function getImportSpecifierInsertionIndex(sortedImports, newImport, comparer) {
167807
- const index = binarySearch(sortedImports, newImport, identity, (s1, s2) => compareImportOrExportSpecifiers(s1, s2, comparer));
167939
+ function getImportSpecifierInsertionIndex(sortedImports, newImport, comparer, preferences) {
167940
+ const index = binarySearch(sortedImports, newImport, identity, (s1, s2) => compareImportOrExportSpecifiers(s1, s2, comparer, preferences));
167808
167941
  return index < 0 ? ~index : index;
167809
167942
  }
167810
167943
  function compareImportsOrRequireStatements(s1, s2, comparer) {
@@ -174793,7 +174926,6 @@ __export(ts_exports2, {
174793
174926
  getModuleSpecifierEndingPreference: () => getModuleSpecifierEndingPreference,
174794
174927
  getModuleSpecifierResolverHost: () => getModuleSpecifierResolverHost,
174795
174928
  getNameForExportedSymbol: () => getNameForExportedSymbol,
174796
- getNameFromImportAttribute: () => getNameFromImportAttribute,
174797
174929
  getNameFromIndexInfo: () => getNameFromIndexInfo,
174798
174930
  getNameFromPropertyName: () => getNameFromPropertyName,
174799
174931
  getNameOfAccessExpression: () => getNameOfAccessExpression,
@@ -175551,7 +175683,6 @@ __export(ts_exports2, {
175551
175683
  isPackedArrayLiteral: () => isPackedArrayLiteral,
175552
175684
  isParameter: () => isParameter,
175553
175685
  isParameterDeclaration: () => isParameterDeclaration,
175554
- isParameterOrCatchClauseVariable: () => isParameterOrCatchClauseVariable,
175555
175686
  isParameterPropertyDeclaration: () => isParameterPropertyDeclaration,
175556
175687
  isParameterPropertyModifier: () => isParameterPropertyModifier,
175557
175688
  isParenthesizedExpression: () => isParenthesizedExpression,
@@ -189595,7 +189726,6 @@ start(initializeNodeSystem(), require("os").platform());
189595
189726
  getModuleSpecifierEndingPreference,
189596
189727
  getModuleSpecifierResolverHost,
189597
189728
  getNameForExportedSymbol,
189598
- getNameFromImportAttribute,
189599
189729
  getNameFromIndexInfo,
189600
189730
  getNameFromPropertyName,
189601
189731
  getNameOfAccessExpression,
@@ -190353,7 +190483,6 @@ start(initializeNodeSystem(), require("os").platform());
190353
190483
  isPackedArrayLiteral,
190354
190484
  isParameter,
190355
190485
  isParameterDeclaration,
190356
- isParameterOrCatchClauseVariable,
190357
190486
  isParameterPropertyDeclaration,
190358
190487
  isParameterPropertyModifier,
190359
190488
  isParenthesizedExpression,