@typescript-deploys/pr-build 5.4.0-pr-56034-9 → 5.4.0-pr-55774-44

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(
@@ -59368,6 +59368,14 @@ function createTypeChecker(host) {
59368
59368
  return getCheckFlags(s) & 4096 /* Late */;
59369
59369
  }
59370
59370
  function forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(type, include, stringsOnly, cb) {
59371
+ if (isTupleType(type)) {
59372
+ forEachType(getUnionType(getElementTypes(type).map((_, i) => getStringLiteralType("" + i))), cb);
59373
+ return;
59374
+ }
59375
+ if (isArrayType(type)) {
59376
+ cb(numberType);
59377
+ return;
59378
+ }
59371
59379
  for (const prop of getPropertiesOfType(type)) {
59372
59380
  cb(getLiteralTypeFromProperty(prop, include));
59373
59381
  }
@@ -59917,14 +59925,30 @@ function createTypeChecker(host) {
59917
59925
  return !!(typeParameter.symbol && forEach(typeParameter.symbol.declarations, (decl) => isTypeParameterDeclaration(decl) && decl.default));
59918
59926
  }
59919
59927
  function getApparentTypeOfMappedType(type) {
59920
- return type.resolvedApparentType || (type.resolvedApparentType = getResolvedApparentTypeOfMappedType(type));
59928
+ if (type.resolvedApparentType) {
59929
+ if (type.resolvedApparentType === resolvingApparentMappedType) {
59930
+ return type.resolvedApparentType = type;
59931
+ }
59932
+ return type.resolvedApparentType;
59933
+ }
59934
+ type.resolvedApparentType = resolvingApparentMappedType;
59935
+ return type.resolvedApparentType = getResolvedApparentTypeOfMappedType(type);
59921
59936
  }
59922
59937
  function getResolvedApparentTypeOfMappedType(type) {
59923
- const typeVariable = getHomomorphicTypeVariable(type);
59924
- if (typeVariable && !type.declaration.nameType) {
59925
- const constraint = getConstraintOfTypeParameter(typeVariable);
59938
+ const mappedType = type.target || type;
59939
+ const typeVariable = getHomomorphicTypeVariable(mappedType);
59940
+ if (typeVariable && !mappedType.declaration.nameType) {
59941
+ let constraint;
59942
+ if (!type.target) {
59943
+ constraint = getConstraintOfTypeParameter(typeVariable);
59944
+ } else {
59945
+ const modifiersConstraint = getConstraintOfType(getModifiersTypeFromMappedType(type));
59946
+ if (modifiersConstraint) {
59947
+ constraint = getApparentType(modifiersConstraint);
59948
+ }
59949
+ }
59926
59950
  if (constraint && everyType(constraint, isArrayOrTupleType)) {
59927
- return instantiateType(type, prependTypeMapping(typeVariable, constraint, type.mapper));
59951
+ return instantiateType(mappedType, prependTypeMapping(typeVariable, constraint, mappedType.mapper));
59928
59952
  }
59929
59953
  }
59930
59954
  return type;
@@ -60015,6 +60039,7 @@ function createTypeChecker(host) {
60015
60039
  clone2.parent = (_c = (_b = singleProp.valueDeclaration) == null ? void 0 : _b.symbol) == null ? void 0 : _c.parent;
60016
60040
  clone2.links.containingType = containingType;
60017
60041
  clone2.links.mapper = links == null ? void 0 : links.mapper;
60042
+ clone2.links.writeType = getWriteTypeOfSymbol(singleProp);
60018
60043
  return clone2;
60019
60044
  } else {
60020
60045
  return singleProp;
@@ -61235,7 +61260,7 @@ function createTypeChecker(host) {
61235
61260
  if (constraint) {
61236
61261
  constraints = append(constraints, constraint);
61237
61262
  }
61238
- } else if (type.flags & 262144 /* TypeParameter */ && parent2.kind === 200 /* MappedType */ && node === parent2.type) {
61263
+ } else if (type.flags & 262144 /* TypeParameter */ && parent2.kind === 200 /* MappedType */ && (node === parent2.type || node === parent2.nameType)) {
61239
61264
  const mappedType = getTypeFromTypeNode(parent2);
61240
61265
  if (getTypeParameterFromMappedType(mappedType) === getActualTypeVariable(type)) {
61241
61266
  const typeParameter = getHomomorphicTypeVariable(mappedType);
@@ -61483,14 +61508,6 @@ function createTypeChecker(host) {
61483
61508
  reportErrors2
61484
61509
  )) || emptyObjectType;
61485
61510
  }
61486
- function getGlobalImportAttributesType(reportErrors2) {
61487
- return deferredGlobalImportAttributesType || (deferredGlobalImportAttributesType = getGlobalType(
61488
- "ImportAttributes",
61489
- /*arity*/
61490
- 0,
61491
- reportErrors2
61492
- )) || emptyObjectType;
61493
- }
61494
61511
  function getGlobalESSymbolConstructorSymbol(reportErrors2) {
61495
61512
  return deferredGlobalESSymbolConstructorSymbol || (deferredGlobalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol", reportErrors2));
61496
61513
  }
@@ -66648,6 +66665,18 @@ function createTypeChecker(host) {
66648
66665
  }
66649
66666
  return result2;
66650
66667
  }
66668
+ function getApparentMappedTypeKeys(nameType, targetType) {
66669
+ const modifiersType = getApparentType(getModifiersTypeFromMappedType(targetType));
66670
+ const mappedKeys = [];
66671
+ forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(
66672
+ modifiersType,
66673
+ 8576 /* StringOrNumberLiteralOrUnique */,
66674
+ /*stringsOnly*/
66675
+ false,
66676
+ (t) => void mappedKeys.push(instantiateType(nameType, appendTypeMapping(targetType.mapper, getTypeParameterFromMappedType(targetType), t)))
66677
+ );
66678
+ return getUnionType(mappedKeys);
66679
+ }
66651
66680
  function structuredTypeRelatedToWorker(source2, target2, reportErrors2, intersectionState, saveErrorInfo) {
66652
66681
  let result2;
66653
66682
  let originalErrorInfo;
@@ -66830,16 +66859,8 @@ function createTypeChecker(host) {
66830
66859
  const constraintType = getConstraintTypeFromMappedType(targetType);
66831
66860
  let targetKeys;
66832
66861
  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]);
66862
+ const mappedKeys = getApparentMappedTypeKeys(nameType, targetType);
66863
+ targetKeys = getUnionType([mappedKeys, nameType]);
66843
66864
  } else {
66844
66865
  targetKeys = nameType || constraintType;
66845
66866
  }
@@ -67010,9 +67031,18 @@ function createTypeChecker(host) {
67010
67031
  }
67011
67032
  }
67012
67033
  } else if (sourceFlags & 4194304 /* Index */) {
67013
- if (result2 = isRelatedTo(keyofConstraintType, target2, 1 /* Source */, reportErrors2)) {
67034
+ const isDeferredMappedIndex = shouldDeferIndexType(source2.type, source2.indexFlags) && getObjectFlags(source2.type) & 32 /* Mapped */;
67035
+ if (result2 = isRelatedTo(keyofConstraintType, target2, 1 /* Source */, reportErrors2 && !isDeferredMappedIndex)) {
67014
67036
  return result2;
67015
67037
  }
67038
+ if (isDeferredMappedIndex) {
67039
+ const mappedType = source2.type;
67040
+ const nameType = getNameTypeFromMappedType(mappedType);
67041
+ const sourceMappedKeys = nameType && isMappedTypeWithKeyofConstraintDeclaration(mappedType) ? getApparentMappedTypeKeys(nameType, mappedType) : nameType || getConstraintTypeFromMappedType(mappedType);
67042
+ if (result2 = isRelatedTo(sourceMappedKeys, target2, 1 /* Source */, reportErrors2)) {
67043
+ return result2;
67044
+ }
67045
+ }
67016
67046
  } else if (sourceFlags & 134217728 /* TemplateLiteral */ && !(targetFlags & 524288 /* Object */)) {
67017
67047
  if (!(targetFlags & 134217728 /* TemplateLiteral */)) {
67018
67048
  const constraint = getBaseConstraintOfType(source2);
@@ -70949,7 +70979,7 @@ function createTypeChecker(host) {
70949
70979
  case 80 /* Identifier */:
70950
70980
  if (!isThisInTypeQuery(node)) {
70951
70981
  const symbol = getResolvedSymbol(node);
70952
- return isConstantVariable(symbol) || isParameterOrCatchClauseVariable(symbol) && !isSymbolAssigned(symbol);
70982
+ return isConstantVariable(symbol) || isParameterOrMutableLocalVariable(symbol) && !isSymbolAssigned(symbol);
70953
70983
  }
70954
70984
  break;
70955
70985
  case 211 /* PropertyAccessExpression */:
@@ -70958,7 +70988,7 @@ function createTypeChecker(host) {
70958
70988
  case 206 /* ObjectBindingPattern */:
70959
70989
  case 207 /* ArrayBindingPattern */:
70960
70990
  const rootDeclaration = getRootDeclaration(node.parent);
70961
- return isVariableDeclaration(rootDeclaration) && isVarConstLike(rootDeclaration);
70991
+ return isParameter(rootDeclaration) || isCatchClauseVariableDeclaration(rootDeclaration) ? !isSomeSymbolAssigned(rootDeclaration) : isVariableDeclaration(rootDeclaration) && isVarConstLike(rootDeclaration);
70962
70992
  }
70963
70993
  return false;
70964
70994
  }
@@ -72039,10 +72069,17 @@ function createTypeChecker(host) {
72039
72069
  return findAncestor(node.parent, (node2) => isFunctionLike(node2) && !getImmediatelyInvokedFunctionExpression(node2) || node2.kind === 268 /* ModuleBlock */ || node2.kind === 312 /* SourceFile */ || node2.kind === 172 /* PropertyDeclaration */);
72040
72070
  }
72041
72071
  function isSymbolAssigned(symbol) {
72042
- if (!symbol.valueDeclaration) {
72072
+ return !isPastLastAssignment(
72073
+ symbol,
72074
+ /*location*/
72075
+ void 0
72076
+ );
72077
+ }
72078
+ function isPastLastAssignment(symbol, location) {
72079
+ const parent2 = findAncestor(symbol.valueDeclaration, isFunctionOrSourceFile);
72080
+ if (!parent2) {
72043
72081
  return false;
72044
72082
  }
72045
- const parent2 = getRootDeclaration(symbol.valueDeclaration).parent;
72046
72083
  const links = getNodeLinks(parent2);
72047
72084
  if (!(links.flags & 131072 /* AssignmentsMarked */)) {
72048
72085
  links.flags |= 131072 /* AssignmentsMarked */;
@@ -72050,7 +72087,7 @@ function createTypeChecker(host) {
72050
72087
  markNodeAssignments(parent2);
72051
72088
  }
72052
72089
  }
72053
- return symbol.isAssigned || false;
72090
+ return !symbol.lastAssignmentPos || location && symbol.lastAssignmentPos < location.pos;
72054
72091
  }
72055
72092
  function isSomeSymbolAssigned(rootDeclaration) {
72056
72093
  Debug.assert(isVariableDeclaration(rootDeclaration) || isParameter(rootDeclaration));
@@ -72063,23 +72100,81 @@ function createTypeChecker(host) {
72063
72100
  return some(node.elements, (e) => e.kind !== 232 /* OmittedExpression */ && isSomeSymbolAssignedWorker(e.name));
72064
72101
  }
72065
72102
  function hasParentWithAssignmentsMarked(node) {
72066
- return !!findAncestor(node.parent, (node2) => (isFunctionLike(node2) || isCatchClause(node2)) && !!(getNodeLinks(node2).flags & 131072 /* AssignmentsMarked */));
72103
+ return !!findAncestor(node.parent, (node2) => isFunctionOrSourceFile(node2) && !!(getNodeLinks(node2).flags & 131072 /* AssignmentsMarked */));
72104
+ }
72105
+ function isFunctionOrSourceFile(node) {
72106
+ return isFunctionLikeDeclaration(node) || isSourceFile(node);
72067
72107
  }
72068
72108
  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;
72109
+ switch (node.kind) {
72110
+ case 80 /* Identifier */:
72111
+ if (isAssignmentTarget(node)) {
72112
+ const symbol = getResolvedSymbol(node);
72113
+ if (isParameterOrMutableLocalVariable(symbol) && symbol.lastAssignmentPos !== Number.MAX_VALUE) {
72114
+ const referencingFunction = findAncestor(node, isFunctionOrSourceFile);
72115
+ const declaringFunction = findAncestor(symbol.valueDeclaration, isFunctionOrSourceFile);
72116
+ symbol.lastAssignmentPos = referencingFunction === declaringFunction ? extendAssignmentPosition(node, symbol.valueDeclaration) : Number.MAX_VALUE;
72117
+ }
72074
72118
  }
72119
+ return;
72120
+ case 281 /* ExportSpecifier */:
72121
+ const exportDeclaration = node.parent.parent;
72122
+ if (!node.isTypeOnly && !exportDeclaration.isTypeOnly && !exportDeclaration.moduleSpecifier) {
72123
+ const symbol = resolveEntityName(
72124
+ node.propertyName || node.name,
72125
+ 111551 /* Value */,
72126
+ /*ignoreErrors*/
72127
+ true,
72128
+ /*dontResolveAlias*/
72129
+ true
72130
+ );
72131
+ if (symbol && isParameterOrMutableLocalVariable(symbol)) {
72132
+ symbol.lastAssignmentPos = Number.MAX_VALUE;
72133
+ }
72134
+ }
72135
+ return;
72136
+ case 264 /* InterfaceDeclaration */:
72137
+ case 265 /* TypeAliasDeclaration */:
72138
+ case 266 /* EnumDeclaration */:
72139
+ return;
72140
+ }
72141
+ if (isTypeNode(node)) {
72142
+ return;
72143
+ }
72144
+ forEachChild(node, markNodeAssignments);
72145
+ }
72146
+ function extendAssignmentPosition(node, declaration) {
72147
+ let pos = node.pos;
72148
+ while (node && node.pos > declaration.pos) {
72149
+ switch (node.kind) {
72150
+ case 243 /* VariableStatement */:
72151
+ case 244 /* ExpressionStatement */:
72152
+ case 245 /* IfStatement */:
72153
+ case 246 /* DoStatement */:
72154
+ case 247 /* WhileStatement */:
72155
+ case 248 /* ForStatement */:
72156
+ case 249 /* ForInStatement */:
72157
+ case 250 /* ForOfStatement */:
72158
+ case 254 /* WithStatement */:
72159
+ case 255 /* SwitchStatement */:
72160
+ case 258 /* TryStatement */:
72161
+ case 263 /* ClassDeclaration */:
72162
+ pos = node.end;
72075
72163
  }
72076
- } else {
72077
- forEachChild(node, markNodeAssignments);
72164
+ node = node.parent;
72078
72165
  }
72166
+ return pos;
72079
72167
  }
72080
72168
  function isConstantVariable(symbol) {
72081
72169
  return symbol.flags & 3 /* Variable */ && (getDeclarationNodeFlagsFromSymbol(symbol) & 6 /* Constant */) !== 0;
72082
72170
  }
72171
+ function isParameterOrMutableLocalVariable(symbol) {
72172
+ const declaration = symbol.valueDeclaration && getRootDeclaration(symbol.valueDeclaration);
72173
+ return !!declaration && (isParameter(declaration) || isVariableDeclaration(declaration) && (isCatchClause(declaration.parent) || isMutableLocalVariableDeclaration(declaration)));
72174
+ }
72175
+ function isMutableLocalVariableDeclaration(declaration) {
72176
+ return !!(declaration.parent.flags & 1 /* Let */) && !(getCombinedModifierFlags(declaration) & 32 /* Export */ || declaration.parent.parent.kind === 243 /* VariableStatement */ && isGlobalSourceFile(declaration.parent.parent.parent));
72177
+ }
72083
72178
  function parameterInitializerContainsUndefined(declaration) {
72084
72179
  const links = getNodeLinks(declaration);
72085
72180
  if (links.parameterInitializerContainsUndefined === void 0) {
@@ -72328,7 +72423,7 @@ function createTypeChecker(host) {
72328
72423
  const isModuleExports = symbol.flags & 134217728 /* ModuleExports */;
72329
72424
  const typeIsAutomatic = type === autoType || type === autoArrayType;
72330
72425
  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))) {
72426
+ while (flowContainer !== declarationContainer && (flowContainer.kind === 218 /* FunctionExpression */ || flowContainer.kind === 219 /* ArrowFunction */ || isObjectLiteralOrClassExpressionMethodOrAccessor(flowContainer)) && (isConstantVariable(localOrExportSymbol) && type !== autoArrayType || isParameterOrMutableLocalVariable(localOrExportSymbol) && isPastLastAssignment(localOrExportSymbol, node))) {
72332
72427
  flowContainer = getControlFlowContainer(flowContainer);
72333
72428
  }
72334
72429
  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 +73694,6 @@ function createTypeChecker(host) {
73599
73694
  case 286 /* JsxOpeningElement */:
73600
73695
  case 285 /* JsxSelfClosingElement */:
73601
73696
  return getContextualJsxElementAttributesType(parent2, contextFlags);
73602
- case 301 /* ImportAttribute */:
73603
- return getContextualImportAttributeType(parent2);
73604
73697
  }
73605
73698
  return void 0;
73606
73699
  }
@@ -73648,12 +73741,6 @@ function createTypeChecker(host) {
73648
73741
  }
73649
73742
  }
73650
73743
  }
73651
- function getContextualImportAttributeType(node) {
73652
- return getTypeOfPropertyOfContextualType(getGlobalImportAttributesType(
73653
- /*reportErrors*/
73654
- false
73655
- ), getNameFromImportAttribute(node));
73656
- }
73657
73744
  function getContextualJsxElementAttributesType(node, contextFlags) {
73658
73745
  if (isJsxOpeningElement(node) && contextFlags !== 4 /* Completions */) {
73659
73746
  const index = findContextualNode(
@@ -85739,13 +85826,6 @@ function createTypeChecker(host) {
85739
85826
  var _a;
85740
85827
  const node = declaration.attributes;
85741
85828
  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
85829
  const validForTypeAttributes = isExclusivelyTypeOnlyImportOrExport(declaration);
85750
85830
  const override = getResolutionModeOverride(node, validForTypeAttributes ? grammarErrorOnNode : void 0);
85751
85831
  const isImportAttributes2 = declaration.attributes.token === 118 /* WithKeyword */;
@@ -85765,9 +85845,6 @@ function createTypeChecker(host) {
85765
85845
  }
85766
85846
  }
85767
85847
  }
85768
- function checkImportAttribute(node) {
85769
- return getRegularTypeOfLiteralType(checkExpressionCached(node.value));
85770
- }
85771
85848
  function checkImportDeclaration(node) {
85772
85849
  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
85850
  return;
@@ -87183,12 +87260,6 @@ function createTypeChecker(host) {
87183
87260
  if (isMetaProperty(node.parent) && node.parent.keywordToken === node.kind) {
87184
87261
  return checkMetaPropertyKeyword(node.parent);
87185
87262
  }
87186
- if (isImportAttributes(node)) {
87187
- return getGlobalImportAttributesType(
87188
- /*reportErrors*/
87189
- false
87190
- );
87191
- }
87192
87263
  return errorType;
87193
87264
  }
87194
87265
  function getTypeOfAssignmentPattern(expr) {
@@ -118393,7 +118464,14 @@ function createPrinter(printerOptions = {}, handlers = {}) {
118393
118464
  function willEmitLeadingNewLine(node) {
118394
118465
  if (!currentSourceFile)
118395
118466
  return false;
118396
- if (some(getLeadingCommentRanges(currentSourceFile.text, node.pos), commentWillEmitNewLine))
118467
+ const leadingCommentRanges = getLeadingCommentRanges(currentSourceFile.text, node.pos);
118468
+ if (leadingCommentRanges) {
118469
+ const parseNode = getParseTreeNode(node);
118470
+ if (parseNode && isParenthesizedExpression(parseNode.parent)) {
118471
+ return true;
118472
+ }
118473
+ }
118474
+ if (some(leadingCommentRanges, commentWillEmitNewLine))
118397
118475
  return true;
118398
118476
  if (some(getSyntheticLeadingComments(node), commentWillEmitNewLine))
118399
118477
  return true;
@@ -124494,7 +124572,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
124494
124572
  }
124495
124573
  const isFromNodeModulesSearch = resolution.isExternalLibraryImport;
124496
124574
  const isJsFile = !resolutionExtensionIsTSOrJson(resolution.extension);
124497
- const isJsFileFromNodeModules = isFromNodeModulesSearch && isJsFile;
124575
+ const isJsFileFromNodeModules = isFromNodeModulesSearch && isJsFile && (!resolution.originalPath || pathContainsNodeModules(resolution.resolvedFileName));
124498
124576
  const resolvedFileName = resolution.resolvedFileName;
124499
124577
  if (isFromNodeModulesSearch) {
124500
124578
  currentNodeModulesDepth++;
@@ -152351,14 +152429,14 @@ function promoteFromTypeOnly(changes, aliasDeclaration, program, sourceFile, pre
152351
152429
  aliasDeclaration.name
152352
152430
  );
152353
152431
  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) {
152432
+ const insertionIndex = ts_OrganizeImports_exports.getImportSpecifierInsertionIndex(aliasDeclaration.parent.elements, newSpecifier, comparer, preferences);
152433
+ if (insertionIndex !== aliasDeclaration.parent.elements.indexOf(aliasDeclaration)) {
152356
152434
  changes.delete(sourceFile, aliasDeclaration);
152357
152435
  changes.insertImportSpecifierAtIndex(sourceFile, newSpecifier, aliasDeclaration.parent, insertionIndex);
152358
152436
  return aliasDeclaration;
152359
152437
  }
152360
152438
  }
152361
- changes.deleteRange(sourceFile, aliasDeclaration.getFirstToken());
152439
+ changes.deleteRange(sourceFile, { pos: getTokenPosOfNode(aliasDeclaration.getFirstToken()), end: getTokenPosOfNode(aliasDeclaration.propertyName ?? aliasDeclaration.name) });
152362
152440
  return aliasDeclaration;
152363
152441
  } else {
152364
152442
  Debug.assert(aliasDeclaration.parent.parent.isTypeOnly);
@@ -152454,7 +152532,7 @@ function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImpor
152454
152532
  const specifierSort = (existingSpecifiers == null ? void 0 : existingSpecifiers.length) && ts_OrganizeImports_exports.detectImportSpecifierSorting(existingSpecifiers, preferences);
152455
152533
  if (specifierSort && !(ignoreCaseForSorting && specifierSort === 1 /* CaseSensitive */)) {
152456
152534
  for (const spec of newSpecifiers) {
152457
- const insertionIndex = promoteFromTypeOnly2 && !spec.isTypeOnly ? 0 : ts_OrganizeImports_exports.getImportSpecifierInsertionIndex(existingSpecifiers, spec, comparer);
152535
+ const insertionIndex = promoteFromTypeOnly2 && !spec.isTypeOnly ? 0 : ts_OrganizeImports_exports.getImportSpecifierInsertionIndex(existingSpecifiers, spec, comparer, preferences);
152458
152536
  changes.insertImportSpecifierAtIndex(sourceFile, spec, clause.namedBindings, insertionIndex);
152459
152537
  }
152460
152538
  } else if (existingSpecifiers == null ? void 0 : existingSpecifiers.length) {
@@ -160809,7 +160887,7 @@ function getCompletionData(program, log, sourceFile, compilerOptions, position,
160809
160887
  return isIdentifier(e) ? e : isPropertyAccessExpression(e) ? getLeftMostName(e.expression) : void 0;
160810
160888
  }
160811
160889
  function tryGetGlobalSymbols() {
160812
- const result = tryGetObjectTypeLiteralInTypeArgumentCompletionSymbols() || tryGetObjectLikeCompletionSymbols() || tryGetImportCompletionSymbols() || tryGetImportOrExportClauseCompletionSymbols() || tryGetImportAttributesCompletionSymbols() || tryGetLocalNamedExportCompletionSymbols() || tryGetConstructorCompletion() || tryGetClassLikeCompletionSymbols() || tryGetJsxCompletionSymbols() || (getGlobalCompletions(), 1 /* Success */);
160890
+ const result = tryGetObjectTypeLiteralInTypeArgumentCompletionSymbols() || tryGetObjectLikeCompletionSymbols() || tryGetImportCompletionSymbols() || tryGetImportOrExportClauseCompletionSymbols() || tryGetLocalNamedExportCompletionSymbols() || tryGetConstructorCompletion() || tryGetClassLikeCompletionSymbols() || tryGetJsxCompletionSymbols() || (getGlobalCompletions(), 1 /* Success */);
160813
160891
  return result === 1 /* Success */;
160814
160892
  }
160815
160893
  function tryGetConstructorCompletion() {
@@ -161277,16 +161355,6 @@ function getCompletionData(program, log, sourceFile, compilerOptions, position,
161277
161355
  }
161278
161356
  return 1 /* Success */;
161279
161357
  }
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
161358
  function tryGetLocalNamedExportCompletionSymbols() {
161291
161359
  var _a;
161292
161360
  const namedExports = contextToken && (contextToken.kind === 19 /* OpenBraceToken */ || contextToken.kind === 28 /* CommaToken */) ? tryCast(contextToken.parent, isNamedExports) : void 0;
@@ -167329,14 +167397,14 @@ function organizeImports(sourceFile, formatContext, host, program, preferences,
167329
167397
  if (shouldRemove)
167330
167398
  importGroup = removeUnusedImports(importGroup, sourceFile, program);
167331
167399
  if (shouldCombine)
167332
- importGroup = coalesceImportsWorker(importGroup, comparer, sourceFile);
167400
+ importGroup = coalesceImportsWorker(importGroup, comparer, sourceFile, preferences);
167333
167401
  if (shouldSort)
167334
167402
  importGroup = stableSort(importGroup, (s1, s2) => compareImportsOrRequireStatements(s1, s2, comparer));
167335
167403
  return importGroup;
167336
167404
  };
167337
167405
  topLevelImportGroupDecls.forEach((importGroupDecl) => organizeImportsWorker(importGroupDecl, processImportsOfSameModuleSpecifier));
167338
167406
  if (mode !== "RemoveUnused" /* RemoveUnused */) {
167339
- getTopLevelExportGroups(sourceFile).forEach((exportGroupDecl) => organizeImportsWorker(exportGroupDecl, (group2) => coalesceExportsWorker(group2, comparer)));
167407
+ getTopLevelExportGroups(sourceFile).forEach((exportGroupDecl) => organizeImportsWorker(exportGroupDecl, (group2) => coalesceExportsWorker(group2, comparer, preferences)));
167340
167408
  }
167341
167409
  for (const ambientModule of sourceFile.statements.filter(isAmbientModule)) {
167342
167410
  if (!ambientModule.body)
@@ -167345,7 +167413,7 @@ function organizeImports(sourceFile, formatContext, host, program, preferences,
167345
167413
  ambientModuleImportGroupDecls.forEach((importGroupDecl) => organizeImportsWorker(importGroupDecl, processImportsOfSameModuleSpecifier));
167346
167414
  if (mode !== "RemoveUnused" /* RemoveUnused */) {
167347
167415
  const ambientModuleExportDecls = ambientModule.body.statements.filter(isExportDeclaration);
167348
- organizeImportsWorker(ambientModuleExportDecls, (group2) => coalesceExportsWorker(group2, comparer));
167416
+ organizeImportsWorker(ambientModuleExportDecls, (group2) => coalesceExportsWorker(group2, comparer, preferences));
167349
167417
  }
167350
167418
  }
167351
167419
  return changeTracker.getChanges();
@@ -167477,11 +167545,11 @@ function hasModuleDeclarationMatchingSpecifier(sourceFile, moduleSpecifier) {
167477
167545
  function getExternalModuleName2(specifier) {
167478
167546
  return specifier !== void 0 && isStringLiteralLike(specifier) ? specifier.text : void 0;
167479
167547
  }
167480
- function coalesceImports(importGroup, ignoreCase, sourceFile) {
167548
+ function coalesceImports(importGroup, ignoreCase, sourceFile, preferences) {
167481
167549
  const comparer = getOrganizeImportsOrdinalStringComparer(ignoreCase);
167482
- return coalesceImportsWorker(importGroup, comparer, sourceFile);
167550
+ return coalesceImportsWorker(importGroup, comparer, sourceFile, preferences);
167483
167551
  }
167484
- function coalesceImportsWorker(importGroup, comparer, sourceFile) {
167552
+ function coalesceImportsWorker(importGroup, comparer, sourceFile, preferences) {
167485
167553
  if (importGroup.length === 0) {
167486
167554
  return importGroup;
167487
167555
  }
@@ -167535,7 +167603,7 @@ function coalesceImportsWorker(importGroup, comparer, sourceFile) {
167535
167603
  }
167536
167604
  newImportSpecifiers.push(...getNewImportSpecifiers(namedImports));
167537
167605
  const sortedImportSpecifiers = factory.createNodeArray(
167538
- sortSpecifiers(newImportSpecifiers, comparer),
167606
+ sortSpecifiers(newImportSpecifiers, comparer, preferences),
167539
167607
  firstNamedImport == null ? void 0 : firstNamedImport.importClause.namedBindings.elements.hasTrailingComma
167540
167608
  );
167541
167609
  const newNamedImports = sortedImportSpecifiers.length === 0 ? newDefaultImport ? void 0 : factory.createNamedImports(emptyArray) : firstNamedImport ? factory.updateNamedImports(firstNamedImport.importClause.namedBindings, sortedImportSpecifiers) : factory.createNamedImports(sortedImportSpecifiers);
@@ -167595,11 +167663,11 @@ function getCategorizedImports(importGroup) {
167595
167663
  regularImports
167596
167664
  };
167597
167665
  }
167598
- function coalesceExports(exportGroup, ignoreCase) {
167666
+ function coalesceExports(exportGroup, ignoreCase, preferences) {
167599
167667
  const comparer = getOrganizeImportsOrdinalStringComparer(ignoreCase);
167600
- return coalesceExportsWorker(exportGroup, comparer);
167668
+ return coalesceExportsWorker(exportGroup, comparer, preferences);
167601
167669
  }
167602
- function coalesceExportsWorker(exportGroup, comparer) {
167670
+ function coalesceExportsWorker(exportGroup, comparer, preferences) {
167603
167671
  if (exportGroup.length === 0) {
167604
167672
  return exportGroup;
167605
167673
  }
@@ -167614,7 +167682,7 @@ function coalesceExportsWorker(exportGroup, comparer) {
167614
167682
  }
167615
167683
  const newExportSpecifiers = [];
167616
167684
  newExportSpecifiers.push(...flatMap(exportGroup2, (i) => i.exportClause && isNamedExports(i.exportClause) ? i.exportClause.elements : emptyArray));
167617
- const sortedExportSpecifiers = sortSpecifiers(newExportSpecifiers, comparer);
167685
+ const sortedExportSpecifiers = sortSpecifiers(newExportSpecifiers, comparer, preferences);
167618
167686
  const exportDecl = exportGroup2[0];
167619
167687
  coalescedExports.push(
167620
167688
  factory.updateExportDeclaration(
@@ -167658,11 +167726,18 @@ function updateImportDeclarationAndClause(importDeclaration, name, namedBindings
167658
167726
  importDeclaration.attributes
167659
167727
  );
167660
167728
  }
167661
- function sortSpecifiers(specifiers, comparer) {
167662
- return stableSort(specifiers, (s1, s2) => compareImportOrExportSpecifiers(s1, s2, comparer));
167729
+ function sortSpecifiers(specifiers, comparer, preferences) {
167730
+ return stableSort(specifiers, (s1, s2) => compareImportOrExportSpecifiers(s1, s2, comparer, preferences));
167663
167731
  }
167664
- function compareImportOrExportSpecifiers(s1, s2, comparer) {
167665
- return compareBooleans(s1.isTypeOnly, s2.isTypeOnly) || comparer(s1.name.text, s2.name.text);
167732
+ function compareImportOrExportSpecifiers(s1, s2, comparer, preferences) {
167733
+ switch (preferences == null ? void 0 : preferences.organizeImportsTypeOrder) {
167734
+ case "first":
167735
+ return compareBooleans(s2.isTypeOnly, s1.isTypeOnly) || comparer(s1.name.text, s2.name.text);
167736
+ case "inline":
167737
+ return comparer(s1.name.text, s2.name.text);
167738
+ default:
167739
+ return compareBooleans(s1.isTypeOnly, s2.isTypeOnly) || comparer(s1.name.text, s2.name.text);
167740
+ }
167666
167741
  }
167667
167742
  function compareModuleSpecifiers2(m1, m2, ignoreCase) {
167668
167743
  const comparer = getOrganizeImportsOrdinalStringComparer(!!ignoreCase);
@@ -167784,8 +167859,26 @@ var ImportSpecifierSortingCache = class {
167784
167859
  }
167785
167860
  };
167786
167861
  var detectImportSpecifierSorting = memoizeCached((specifiers, preferences) => {
167787
- if (!arrayIsSorted(specifiers, (s1, s2) => compareBooleans(s1.isTypeOnly, s2.isTypeOnly))) {
167788
- return 0 /* None */;
167862
+ switch (preferences.organizeImportsTypeOrder) {
167863
+ case "first":
167864
+ if (!arrayIsSorted(specifiers, (s1, s2) => compareBooleans(s2.isTypeOnly, s1.isTypeOnly)))
167865
+ return 0 /* None */;
167866
+ break;
167867
+ case "inline":
167868
+ if (!arrayIsSorted(specifiers, (s1, s2) => {
167869
+ const comparer = getStringComparer(
167870
+ /*ignoreCase*/
167871
+ true
167872
+ );
167873
+ return comparer(s1.name.text, s2.name.text);
167874
+ })) {
167875
+ return 0 /* None */;
167876
+ }
167877
+ break;
167878
+ default:
167879
+ if (!arrayIsSorted(specifiers, (s1, s2) => compareBooleans(s1.isTypeOnly, s2.isTypeOnly)))
167880
+ return 0 /* None */;
167881
+ break;
167789
167882
  }
167790
167883
  const collateCaseSensitive = getOrganizeImportsComparer(
167791
167884
  preferences,
@@ -167797,14 +167890,29 @@ var detectImportSpecifierSorting = memoizeCached((specifiers, preferences) => {
167797
167890
  /*ignoreCase*/
167798
167891
  true
167799
167892
  );
167893
+ if (preferences.organizeImportsTypeOrder !== "inline") {
167894
+ const { type: regularImports, regular: typeImports } = groupBy(specifiers, (s) => s.isTypeOnly ? "type" : "regular");
167895
+ const regularCaseSensitivity = (regularImports == null ? void 0 : regularImports.length) ? detectSortCaseSensitivity(regularImports, (specifier) => specifier.name.text, collateCaseSensitive, collateCaseInsensitive) : void 0;
167896
+ const typeCaseSensitivity = (typeImports == null ? void 0 : typeImports.length) ? detectSortCaseSensitivity(typeImports, (specifier) => specifier.name.text ?? "", collateCaseSensitive, collateCaseInsensitive) : void 0;
167897
+ if (regularCaseSensitivity === void 0) {
167898
+ return typeCaseSensitivity ?? 0 /* None */;
167899
+ }
167900
+ if (typeCaseSensitivity === void 0) {
167901
+ return regularCaseSensitivity;
167902
+ }
167903
+ if (regularCaseSensitivity === 0 /* None */ || typeCaseSensitivity === 0 /* None */) {
167904
+ return 0 /* None */;
167905
+ }
167906
+ return typeCaseSensitivity & regularCaseSensitivity;
167907
+ }
167800
167908
  return detectSortCaseSensitivity(specifiers, (specifier) => specifier.name.text, collateCaseSensitive, collateCaseInsensitive);
167801
167909
  }, new ImportSpecifierSortingCache());
167802
167910
  function getImportDeclarationInsertionIndex(sortedImports, newImport, comparer) {
167803
167911
  const index = binarySearch(sortedImports, newImport, identity, (a, b) => compareImportsOrRequireStatements(a, b, comparer));
167804
167912
  return index < 0 ? ~index : index;
167805
167913
  }
167806
- function getImportSpecifierInsertionIndex(sortedImports, newImport, comparer) {
167807
- const index = binarySearch(sortedImports, newImport, identity, (s1, s2) => compareImportOrExportSpecifiers(s1, s2, comparer));
167914
+ function getImportSpecifierInsertionIndex(sortedImports, newImport, comparer, preferences) {
167915
+ const index = binarySearch(sortedImports, newImport, identity, (s1, s2) => compareImportOrExportSpecifiers(s1, s2, comparer, preferences));
167808
167916
  return index < 0 ? ~index : index;
167809
167917
  }
167810
167918
  function compareImportsOrRequireStatements(s1, s2, comparer) {
@@ -174793,7 +174901,6 @@ __export(ts_exports2, {
174793
174901
  getModuleSpecifierEndingPreference: () => getModuleSpecifierEndingPreference,
174794
174902
  getModuleSpecifierResolverHost: () => getModuleSpecifierResolverHost,
174795
174903
  getNameForExportedSymbol: () => getNameForExportedSymbol,
174796
- getNameFromImportAttribute: () => getNameFromImportAttribute,
174797
174904
  getNameFromIndexInfo: () => getNameFromIndexInfo,
174798
174905
  getNameFromPropertyName: () => getNameFromPropertyName,
174799
174906
  getNameOfAccessExpression: () => getNameOfAccessExpression,
@@ -175551,7 +175658,6 @@ __export(ts_exports2, {
175551
175658
  isPackedArrayLiteral: () => isPackedArrayLiteral,
175552
175659
  isParameter: () => isParameter,
175553
175660
  isParameterDeclaration: () => isParameterDeclaration,
175554
- isParameterOrCatchClauseVariable: () => isParameterOrCatchClauseVariable,
175555
175661
  isParameterPropertyDeclaration: () => isParameterPropertyDeclaration,
175556
175662
  isParameterPropertyModifier: () => isParameterPropertyModifier,
175557
175663
  isParenthesizedExpression: () => isParenthesizedExpression,
@@ -189595,7 +189701,6 @@ start(initializeNodeSystem(), require("os").platform());
189595
189701
  getModuleSpecifierEndingPreference,
189596
189702
  getModuleSpecifierResolverHost,
189597
189703
  getNameForExportedSymbol,
189598
- getNameFromImportAttribute,
189599
189704
  getNameFromIndexInfo,
189600
189705
  getNameFromPropertyName,
189601
189706
  getNameOfAccessExpression,
@@ -190353,7 +190458,6 @@ start(initializeNodeSystem(), require("os").platform());
190353
190458
  isPackedArrayLiteral,
190354
190459
  isParameter,
190355
190460
  isParameterDeclaration,
190356
- isParameterOrCatchClauseVariable,
190357
190461
  isParameterPropertyDeclaration,
190358
190462
  isParameterPropertyModifier,
190359
190463
  isParenthesizedExpression,