typescript 5.4.0-dev.20240108 → 5.4.0-dev.20240110

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/typescript.js CHANGED
@@ -35,7 +35,7 @@ var ts = (() => {
35
35
  "src/compiler/corePublic.ts"() {
36
36
  "use strict";
37
37
  versionMajorMinor = "5.4";
38
- version = `${versionMajorMinor}.0-dev.20240108`;
38
+ version = `${versionMajorMinor}.0-dev.20240110`;
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -13917,7 +13917,7 @@ ${lanes.join("\n")}
13917
13917
  case 116 /* VoidKeyword */:
13918
13918
  return node.parent.kind !== 222 /* VoidExpression */;
13919
13919
  case 233 /* ExpressionWithTypeArguments */:
13920
- return isHeritageClause(node.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(node);
13920
+ return isPartOfTypeExpressionWithTypeArguments(node);
13921
13921
  case 168 /* TypeParameter */:
13922
13922
  return node.parent.kind === 200 /* MappedType */ || node.parent.kind === 195 /* InferType */;
13923
13923
  case 80 /* Identifier */:
@@ -13942,7 +13942,7 @@ ${lanes.join("\n")}
13942
13942
  }
13943
13943
  switch (parent2.kind) {
13944
13944
  case 233 /* ExpressionWithTypeArguments */:
13945
- return isHeritageClause(parent2.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(parent2);
13945
+ return isPartOfTypeExpressionWithTypeArguments(parent2);
13946
13946
  case 168 /* TypeParameter */:
13947
13947
  return node === parent2.constraint;
13948
13948
  case 352 /* JSDocTemplateTag */:
@@ -13976,6 +13976,9 @@ ${lanes.join("\n")}
13976
13976
  }
13977
13977
  return false;
13978
13978
  }
13979
+ function isPartOfTypeExpressionWithTypeArguments(node) {
13980
+ return isJSDocImplementsTag(node.parent) || isJSDocAugmentsTag(node.parent) || isHeritageClause(node.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(node);
13981
+ }
13979
13982
  function isChildOfNodeWithKind(node, kind) {
13980
13983
  while (node) {
13981
13984
  if (node.kind === kind) {
@@ -17529,7 +17532,7 @@ ${lanes.join("\n")}
17529
17532
  this.exportSymbol = void 0;
17530
17533
  this.constEnumOnlyModule = void 0;
17531
17534
  this.isReferenced = void 0;
17532
- this.isAssigned = void 0;
17535
+ this.lastAssignmentPos = void 0;
17533
17536
  this.links = void 0;
17534
17537
  }
17535
17538
  function Type3(checker, flags) {
@@ -18711,10 +18714,6 @@ ${lanes.join("\n")}
18711
18714
  function isCatchClauseVariableDeclaration(node) {
18712
18715
  return node.kind === 260 /* VariableDeclaration */ && node.parent.kind === 299 /* CatchClause */;
18713
18716
  }
18714
- function isParameterOrCatchClauseVariable(symbol) {
18715
- const declaration = symbol.valueDeclaration && getRootDeclaration(symbol.valueDeclaration);
18716
- return !!declaration && (isParameter(declaration) || isCatchClauseVariableDeclaration(declaration));
18717
- }
18718
18717
  function isFunctionExpressionOrArrowFunction(node) {
18719
18718
  return node.kind === 218 /* FunctionExpression */ || node.kind === 219 /* ArrowFunction */;
18720
18719
  }
@@ -46778,6 +46777,14 @@ ${lanes.join("\n")}
46778
46777
  emptyArray,
46779
46778
  emptyArray
46780
46779
  );
46780
+ var resolvingApparentMappedType = createAnonymousType(
46781
+ /*symbol*/
46782
+ void 0,
46783
+ emptySymbols,
46784
+ emptyArray,
46785
+ emptyArray,
46786
+ emptyArray
46787
+ );
46781
46788
  var markerSuperType = createTypeParameter();
46782
46789
  var markerSubType = createTypeParameter();
46783
46790
  markerSubType.constraint = markerSuperType;
@@ -49827,29 +49834,7 @@ ${lanes.join("\n")}
49827
49834
  function getContainersOfSymbol(symbol, enclosingDeclaration, meaning) {
49828
49835
  const container = getParentOfSymbol(symbol);
49829
49836
  if (container && !(symbol.flags & 262144 /* TypeParameter */)) {
49830
- const additionalContainers = mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer);
49831
- const reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration);
49832
- const objectLiteralContainer = getVariableDeclarationOfObjectLiteral(container, meaning);
49833
- if (enclosingDeclaration && container.flags & getQualifiedLeftMeaning(meaning) && getAccessibleSymbolChain(
49834
- container,
49835
- enclosingDeclaration,
49836
- 1920 /* Namespace */,
49837
- /*useOnlyExternalAliasing*/
49838
- false
49839
- )) {
49840
- return append(concatenate(concatenate([container], additionalContainers), reexportContainers), objectLiteralContainer);
49841
- }
49842
- const firstVariableMatch = !(container.flags & getQualifiedLeftMeaning(meaning)) && container.flags & 788968 /* Type */ && getDeclaredTypeOfSymbol(container).flags & 524288 /* Object */ && meaning === 111551 /* Value */ ? forEachSymbolTableInScope(enclosingDeclaration, (t) => {
49843
- return forEachEntry(t, (s) => {
49844
- if (s.flags & getQualifiedLeftMeaning(meaning) && getTypeOfSymbol(s) === getDeclaredTypeOfSymbol(container)) {
49845
- return s;
49846
- }
49847
- });
49848
- }) : void 0;
49849
- let res = firstVariableMatch ? [firstVariableMatch, ...additionalContainers, container] : [...additionalContainers, container];
49850
- res = append(res, objectLiteralContainer);
49851
- res = addRange(res, reexportContainers);
49852
- return res;
49837
+ return getWithAlternativeContainers(container);
49853
49838
  }
49854
49839
  const candidates = mapDefined(symbol.declarations, (d) => {
49855
49840
  if (!isAmbientModule(d) && d.parent) {
@@ -49871,7 +49856,40 @@ ${lanes.join("\n")}
49871
49856
  if (!length(candidates)) {
49872
49857
  return void 0;
49873
49858
  }
49874
- return mapDefined(candidates, (candidate) => getAliasForSymbolInContainer(candidate, symbol) ? candidate : void 0);
49859
+ const containers = mapDefined(candidates, (candidate) => getAliasForSymbolInContainer(candidate, symbol) ? candidate : void 0);
49860
+ let bestContainers = [];
49861
+ let alternativeContainers = [];
49862
+ for (const container2 of containers) {
49863
+ const [bestMatch, ...rest] = getWithAlternativeContainers(container2);
49864
+ bestContainers = append(bestContainers, bestMatch);
49865
+ alternativeContainers = addRange(alternativeContainers, rest);
49866
+ }
49867
+ return concatenate(bestContainers, alternativeContainers);
49868
+ function getWithAlternativeContainers(container2) {
49869
+ const additionalContainers = mapDefined(container2.declarations, fileSymbolIfFileSymbolExportEqualsContainer);
49870
+ const reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration);
49871
+ const objectLiteralContainer = getVariableDeclarationOfObjectLiteral(container2, meaning);
49872
+ if (enclosingDeclaration && container2.flags & getQualifiedLeftMeaning(meaning) && getAccessibleSymbolChain(
49873
+ container2,
49874
+ enclosingDeclaration,
49875
+ 1920 /* Namespace */,
49876
+ /*useOnlyExternalAliasing*/
49877
+ false
49878
+ )) {
49879
+ return append(concatenate(concatenate([container2], additionalContainers), reexportContainers), objectLiteralContainer);
49880
+ }
49881
+ const firstVariableMatch = !(container2.flags & getQualifiedLeftMeaning(meaning)) && container2.flags & 788968 /* Type */ && getDeclaredTypeOfSymbol(container2).flags & 524288 /* Object */ && meaning === 111551 /* Value */ ? forEachSymbolTableInScope(enclosingDeclaration, (t) => {
49882
+ return forEachEntry(t, (s) => {
49883
+ if (s.flags & getQualifiedLeftMeaning(meaning) && getTypeOfSymbol(s) === getDeclaredTypeOfSymbol(container2)) {
49884
+ return s;
49885
+ }
49886
+ });
49887
+ }) : void 0;
49888
+ let res = firstVariableMatch ? [firstVariableMatch, ...additionalContainers, container2] : [...additionalContainers, container2];
49889
+ res = append(res, objectLiteralContainer);
49890
+ res = addRange(res, reexportContainers);
49891
+ return res;
49892
+ }
49875
49893
  function fileSymbolIfFileSymbolExportEqualsContainer(d) {
49876
49894
  return container && getFileSymbolIfFileSymbolExportEqualsContainer(d, container);
49877
49895
  }
@@ -49909,6 +49927,13 @@ ${lanes.join("\n")}
49909
49927
  });
49910
49928
  }
49911
49929
  function getSymbolIfSameReference(s1, s2) {
49930
+ var _a, _b;
49931
+ if (s1.flags & 524288 /* TypeAlias */ && ((_a = s2.declarations) == null ? void 0 : _a.find(isTypeAlias))) {
49932
+ s2 = getDeclaredTypeOfTypeAlias(s2).aliasSymbol || s2;
49933
+ }
49934
+ if (s2.flags & 524288 /* TypeAlias */ && ((_b = s1.declarations) == null ? void 0 : _b.find(isTypeAlias))) {
49935
+ s1 = getDeclaredTypeOfTypeAlias(s1).aliasSymbol || s1;
49936
+ }
49912
49937
  if (getMergedSymbol(resolveSymbol(getMergedSymbol(s1))) === getMergedSymbol(resolveSymbol(getMergedSymbol(s2)))) {
49913
49938
  return s1;
49914
49939
  }
@@ -57647,14 +57672,30 @@ ${lanes.join("\n")}
57647
57672
  return !!(typeParameter.symbol && forEach(typeParameter.symbol.declarations, (decl) => isTypeParameterDeclaration(decl) && decl.default));
57648
57673
  }
57649
57674
  function getApparentTypeOfMappedType(type) {
57650
- return type.resolvedApparentType || (type.resolvedApparentType = getResolvedApparentTypeOfMappedType(type));
57675
+ if (type.resolvedApparentType) {
57676
+ if (type.resolvedApparentType === resolvingApparentMappedType) {
57677
+ return type.resolvedApparentType = type;
57678
+ }
57679
+ return type.resolvedApparentType;
57680
+ }
57681
+ type.resolvedApparentType = resolvingApparentMappedType;
57682
+ return type.resolvedApparentType = getResolvedApparentTypeOfMappedType(type);
57651
57683
  }
57652
57684
  function getResolvedApparentTypeOfMappedType(type) {
57653
- const typeVariable = getHomomorphicTypeVariable(type);
57654
- if (typeVariable && !type.declaration.nameType) {
57655
- const constraint = getConstraintOfTypeParameter(typeVariable);
57685
+ const mappedType = type.target || type;
57686
+ const typeVariable = getHomomorphicTypeVariable(mappedType);
57687
+ if (typeVariable && !mappedType.declaration.nameType) {
57688
+ let constraint;
57689
+ if (!type.target) {
57690
+ constraint = getConstraintOfTypeParameter(typeVariable);
57691
+ } else {
57692
+ const modifiersConstraint = getConstraintOfType(getModifiersTypeFromMappedType(type));
57693
+ if (modifiersConstraint) {
57694
+ constraint = getApparentType(modifiersConstraint);
57695
+ }
57696
+ }
57656
57697
  if (constraint && everyType(constraint, isArrayOrTupleType)) {
57657
- return instantiateType(type, prependTypeMapping(typeVariable, constraint, type.mapper));
57698
+ return instantiateType(mappedType, prependTypeMapping(typeVariable, constraint, mappedType.mapper));
57658
57699
  }
57659
57700
  }
57660
57701
  return type;
@@ -57745,6 +57786,7 @@ ${lanes.join("\n")}
57745
57786
  clone2.parent = (_c = (_b = singleProp.valueDeclaration) == null ? void 0 : _b.symbol) == null ? void 0 : _c.parent;
57746
57787
  clone2.links.containingType = containingType;
57747
57788
  clone2.links.mapper = links == null ? void 0 : links.mapper;
57789
+ clone2.links.writeType = getWriteTypeOfSymbol(singleProp);
57748
57790
  return clone2;
57749
57791
  } else {
57750
57792
  return singleProp;
@@ -64370,6 +64412,18 @@ ${lanes.join("\n")}
64370
64412
  }
64371
64413
  return result2;
64372
64414
  }
64415
+ function getApparentMappedTypeKeys(nameType, targetType) {
64416
+ const modifiersType = getApparentType(getModifiersTypeFromMappedType(targetType));
64417
+ const mappedKeys = [];
64418
+ forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(
64419
+ modifiersType,
64420
+ 8576 /* StringOrNumberLiteralOrUnique */,
64421
+ /*stringsOnly*/
64422
+ false,
64423
+ (t) => void mappedKeys.push(instantiateType(nameType, appendTypeMapping(targetType.mapper, getTypeParameterFromMappedType(targetType), t)))
64424
+ );
64425
+ return getUnionType(mappedKeys);
64426
+ }
64373
64427
  function structuredTypeRelatedToWorker(source2, target2, reportErrors2, intersectionState, saveErrorInfo) {
64374
64428
  let result2;
64375
64429
  let originalErrorInfo;
@@ -64552,16 +64606,8 @@ ${lanes.join("\n")}
64552
64606
  const constraintType = getConstraintTypeFromMappedType(targetType);
64553
64607
  let targetKeys;
64554
64608
  if (nameType && isMappedTypeWithKeyofConstraintDeclaration(targetType)) {
64555
- const modifiersType = getApparentType(getModifiersTypeFromMappedType(targetType));
64556
- const mappedKeys = [];
64557
- forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(
64558
- modifiersType,
64559
- 8576 /* StringOrNumberLiteralOrUnique */,
64560
- /*stringsOnly*/
64561
- false,
64562
- (t) => void mappedKeys.push(instantiateType(nameType, appendTypeMapping(targetType.mapper, getTypeParameterFromMappedType(targetType), t)))
64563
- );
64564
- targetKeys = getUnionType([...mappedKeys, nameType]);
64609
+ const mappedKeys = getApparentMappedTypeKeys(nameType, targetType);
64610
+ targetKeys = getUnionType([mappedKeys, nameType]);
64565
64611
  } else {
64566
64612
  targetKeys = nameType || constraintType;
64567
64613
  }
@@ -64732,9 +64778,18 @@ ${lanes.join("\n")}
64732
64778
  }
64733
64779
  }
64734
64780
  } else if (sourceFlags & 4194304 /* Index */) {
64735
- if (result2 = isRelatedTo(keyofConstraintType, target2, 1 /* Source */, reportErrors2)) {
64781
+ const isDeferredMappedIndex = shouldDeferIndexType(source2.type, source2.indexFlags) && getObjectFlags(source2.type) & 32 /* Mapped */;
64782
+ if (result2 = isRelatedTo(keyofConstraintType, target2, 1 /* Source */, reportErrors2 && !isDeferredMappedIndex)) {
64736
64783
  return result2;
64737
64784
  }
64785
+ if (isDeferredMappedIndex) {
64786
+ const mappedType = source2.type;
64787
+ const nameType = getNameTypeFromMappedType(mappedType);
64788
+ const sourceMappedKeys = nameType && isMappedTypeWithKeyofConstraintDeclaration(mappedType) ? getApparentMappedTypeKeys(nameType, mappedType) : nameType || getConstraintTypeFromMappedType(mappedType);
64789
+ if (result2 = isRelatedTo(sourceMappedKeys, target2, 1 /* Source */, reportErrors2)) {
64790
+ return result2;
64791
+ }
64792
+ }
64738
64793
  } else if (sourceFlags & 134217728 /* TemplateLiteral */ && !(targetFlags & 524288 /* Object */)) {
64739
64794
  if (!(targetFlags & 134217728 /* TemplateLiteral */)) {
64740
64795
  const constraint = getBaseConstraintOfType(source2);
@@ -68671,7 +68726,7 @@ ${lanes.join("\n")}
68671
68726
  case 80 /* Identifier */:
68672
68727
  if (!isThisInTypeQuery(node)) {
68673
68728
  const symbol = getResolvedSymbol(node);
68674
- return isConstantVariable(symbol) || isParameterOrCatchClauseVariable(symbol) && !isSymbolAssigned(symbol);
68729
+ return isConstantVariable(symbol) || isParameterOrMutableLocalVariable(symbol) && !isSymbolAssigned(symbol);
68675
68730
  }
68676
68731
  break;
68677
68732
  case 211 /* PropertyAccessExpression */:
@@ -68680,7 +68735,7 @@ ${lanes.join("\n")}
68680
68735
  case 206 /* ObjectBindingPattern */:
68681
68736
  case 207 /* ArrayBindingPattern */:
68682
68737
  const rootDeclaration = getRootDeclaration(node.parent);
68683
- return isVariableDeclaration(rootDeclaration) && isVarConstLike(rootDeclaration);
68738
+ return isParameter(rootDeclaration) || isCatchClauseVariableDeclaration(rootDeclaration) ? !isSomeSymbolAssigned(rootDeclaration) : isVariableDeclaration(rootDeclaration) && isVarConstLike(rootDeclaration);
68684
68739
  }
68685
68740
  return false;
68686
68741
  }
@@ -69761,10 +69816,17 @@ ${lanes.join("\n")}
69761
69816
  return findAncestor(node.parent, (node2) => isFunctionLike(node2) && !getImmediatelyInvokedFunctionExpression(node2) || node2.kind === 268 /* ModuleBlock */ || node2.kind === 312 /* SourceFile */ || node2.kind === 172 /* PropertyDeclaration */);
69762
69817
  }
69763
69818
  function isSymbolAssigned(symbol) {
69764
- if (!symbol.valueDeclaration) {
69819
+ return !isPastLastAssignment(
69820
+ symbol,
69821
+ /*location*/
69822
+ void 0
69823
+ );
69824
+ }
69825
+ function isPastLastAssignment(symbol, location) {
69826
+ const parent2 = findAncestor(symbol.valueDeclaration, isFunctionOrSourceFile);
69827
+ if (!parent2) {
69765
69828
  return false;
69766
69829
  }
69767
- const parent2 = getRootDeclaration(symbol.valueDeclaration).parent;
69768
69830
  const links = getNodeLinks(parent2);
69769
69831
  if (!(links.flags & 131072 /* AssignmentsMarked */)) {
69770
69832
  links.flags |= 131072 /* AssignmentsMarked */;
@@ -69772,7 +69834,7 @@ ${lanes.join("\n")}
69772
69834
  markNodeAssignments(parent2);
69773
69835
  }
69774
69836
  }
69775
- return symbol.isAssigned || false;
69837
+ return !symbol.lastAssignmentPos || location && symbol.lastAssignmentPos < location.pos;
69776
69838
  }
69777
69839
  function isSomeSymbolAssigned(rootDeclaration) {
69778
69840
  Debug.assert(isVariableDeclaration(rootDeclaration) || isParameter(rootDeclaration));
@@ -69785,23 +69847,81 @@ ${lanes.join("\n")}
69785
69847
  return some(node.elements, (e) => e.kind !== 232 /* OmittedExpression */ && isSomeSymbolAssignedWorker(e.name));
69786
69848
  }
69787
69849
  function hasParentWithAssignmentsMarked(node) {
69788
- return !!findAncestor(node.parent, (node2) => (isFunctionLike(node2) || isCatchClause(node2)) && !!(getNodeLinks(node2).flags & 131072 /* AssignmentsMarked */));
69850
+ return !!findAncestor(node.parent, (node2) => isFunctionOrSourceFile(node2) && !!(getNodeLinks(node2).flags & 131072 /* AssignmentsMarked */));
69851
+ }
69852
+ function isFunctionOrSourceFile(node) {
69853
+ return isFunctionLikeDeclaration(node) || isSourceFile(node);
69789
69854
  }
69790
69855
  function markNodeAssignments(node) {
69791
- if (node.kind === 80 /* Identifier */) {
69792
- if (isAssignmentTarget(node)) {
69793
- const symbol = getResolvedSymbol(node);
69794
- if (isParameterOrCatchClauseVariable(symbol)) {
69795
- symbol.isAssigned = true;
69856
+ switch (node.kind) {
69857
+ case 80 /* Identifier */:
69858
+ if (isAssignmentTarget(node)) {
69859
+ const symbol = getResolvedSymbol(node);
69860
+ if (isParameterOrMutableLocalVariable(symbol) && symbol.lastAssignmentPos !== Number.MAX_VALUE) {
69861
+ const referencingFunction = findAncestor(node, isFunctionOrSourceFile);
69862
+ const declaringFunction = findAncestor(symbol.valueDeclaration, isFunctionOrSourceFile);
69863
+ symbol.lastAssignmentPos = referencingFunction === declaringFunction ? extendAssignmentPosition(node, symbol.valueDeclaration) : Number.MAX_VALUE;
69864
+ }
69796
69865
  }
69866
+ return;
69867
+ case 281 /* ExportSpecifier */:
69868
+ const exportDeclaration = node.parent.parent;
69869
+ if (!node.isTypeOnly && !exportDeclaration.isTypeOnly && !exportDeclaration.moduleSpecifier) {
69870
+ const symbol = resolveEntityName(
69871
+ node.propertyName || node.name,
69872
+ 111551 /* Value */,
69873
+ /*ignoreErrors*/
69874
+ true,
69875
+ /*dontResolveAlias*/
69876
+ true
69877
+ );
69878
+ if (symbol && isParameterOrMutableLocalVariable(symbol)) {
69879
+ symbol.lastAssignmentPos = Number.MAX_VALUE;
69880
+ }
69881
+ }
69882
+ return;
69883
+ case 264 /* InterfaceDeclaration */:
69884
+ case 265 /* TypeAliasDeclaration */:
69885
+ case 266 /* EnumDeclaration */:
69886
+ return;
69887
+ }
69888
+ if (isTypeNode(node)) {
69889
+ return;
69890
+ }
69891
+ forEachChild(node, markNodeAssignments);
69892
+ }
69893
+ function extendAssignmentPosition(node, declaration) {
69894
+ let pos = node.pos;
69895
+ while (node && node.pos > declaration.pos) {
69896
+ switch (node.kind) {
69897
+ case 243 /* VariableStatement */:
69898
+ case 244 /* ExpressionStatement */:
69899
+ case 245 /* IfStatement */:
69900
+ case 246 /* DoStatement */:
69901
+ case 247 /* WhileStatement */:
69902
+ case 248 /* ForStatement */:
69903
+ case 249 /* ForInStatement */:
69904
+ case 250 /* ForOfStatement */:
69905
+ case 254 /* WithStatement */:
69906
+ case 255 /* SwitchStatement */:
69907
+ case 258 /* TryStatement */:
69908
+ case 263 /* ClassDeclaration */:
69909
+ pos = node.end;
69797
69910
  }
69798
- } else {
69799
- forEachChild(node, markNodeAssignments);
69911
+ node = node.parent;
69800
69912
  }
69913
+ return pos;
69801
69914
  }
69802
69915
  function isConstantVariable(symbol) {
69803
69916
  return symbol.flags & 3 /* Variable */ && (getDeclarationNodeFlagsFromSymbol(symbol) & 6 /* Constant */) !== 0;
69804
69917
  }
69918
+ function isParameterOrMutableLocalVariable(symbol) {
69919
+ const declaration = symbol.valueDeclaration && getRootDeclaration(symbol.valueDeclaration);
69920
+ return !!declaration && (isParameter(declaration) || isVariableDeclaration(declaration) && (isCatchClause(declaration.parent) || isMutableLocalVariableDeclaration(declaration)));
69921
+ }
69922
+ function isMutableLocalVariableDeclaration(declaration) {
69923
+ return !!(declaration.parent.flags & 1 /* Let */) && !(getCombinedModifierFlags(declaration) & 32 /* Export */ || declaration.parent.parent.kind === 243 /* VariableStatement */ && isGlobalSourceFile(declaration.parent.parent.parent));
69924
+ }
69805
69925
  function parameterInitializerContainsUndefined(declaration) {
69806
69926
  const links = getNodeLinks(declaration);
69807
69927
  if (links.parameterInitializerContainsUndefined === void 0) {
@@ -70050,7 +70170,7 @@ ${lanes.join("\n")}
70050
70170
  const isModuleExports = symbol.flags & 134217728 /* ModuleExports */;
70051
70171
  const typeIsAutomatic = type === autoType || type === autoArrayType;
70052
70172
  const isAutomaticTypeInNonNull = typeIsAutomatic && node.parent.kind === 235 /* NonNullExpression */;
70053
- while (flowContainer !== declarationContainer && (flowContainer.kind === 218 /* FunctionExpression */ || flowContainer.kind === 219 /* ArrowFunction */ || isObjectLiteralOrClassExpressionMethodOrAccessor(flowContainer)) && (isConstantVariable(localOrExportSymbol) && type !== autoArrayType || isParameter2 && !isSymbolAssigned(localOrExportSymbol))) {
70173
+ while (flowContainer !== declarationContainer && (flowContainer.kind === 218 /* FunctionExpression */ || flowContainer.kind === 219 /* ArrowFunction */ || isObjectLiteralOrClassExpressionMethodOrAccessor(flowContainer)) && (isConstantVariable(localOrExportSymbol) && type !== autoArrayType || isParameterOrMutableLocalVariable(localOrExportSymbol) && isPastLastAssignment(localOrExportSymbol, node))) {
70054
70174
  flowContainer = getControlFlowContainer(flowContainer);
70055
70175
  }
70056
70176
  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 */;
@@ -116367,7 +116487,14 @@ ${lanes.join("\n")}
116367
116487
  function willEmitLeadingNewLine(node) {
116368
116488
  if (!currentSourceFile)
116369
116489
  return false;
116370
- if (some(getLeadingCommentRanges(currentSourceFile.text, node.pos), commentWillEmitNewLine))
116490
+ const leadingCommentRanges = getLeadingCommentRanges(currentSourceFile.text, node.pos);
116491
+ if (leadingCommentRanges) {
116492
+ const parseNode = getParseTreeNode(node);
116493
+ if (parseNode && isParenthesizedExpression(parseNode.parent)) {
116494
+ return true;
116495
+ }
116496
+ }
116497
+ if (some(leadingCommentRanges, commentWillEmitNewLine))
116371
116498
  return true;
116372
116499
  if (some(getSyntheticLeadingComments(node), commentWillEmitNewLine))
116373
116500
  return true;
@@ -150993,14 +151120,14 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
150993
151120
  aliasDeclaration.name
150994
151121
  );
150995
151122
  const comparer = ts_OrganizeImports_exports.getOrganizeImportsComparer(preferences, sortKind === 2 /* CaseInsensitive */);
150996
- const insertionIndex = ts_OrganizeImports_exports.getImportSpecifierInsertionIndex(aliasDeclaration.parent.elements, newSpecifier, comparer);
150997
- if (aliasDeclaration.parent.elements.indexOf(aliasDeclaration) !== insertionIndex) {
151123
+ const insertionIndex = ts_OrganizeImports_exports.getImportSpecifierInsertionIndex(aliasDeclaration.parent.elements, newSpecifier, comparer, preferences);
151124
+ if (insertionIndex !== aliasDeclaration.parent.elements.indexOf(aliasDeclaration)) {
150998
151125
  changes.delete(sourceFile, aliasDeclaration);
150999
151126
  changes.insertImportSpecifierAtIndex(sourceFile, newSpecifier, aliasDeclaration.parent, insertionIndex);
151000
151127
  return aliasDeclaration;
151001
151128
  }
151002
151129
  }
151003
- changes.deleteRange(sourceFile, aliasDeclaration.getFirstToken());
151130
+ changes.deleteRange(sourceFile, { pos: getTokenPosOfNode(aliasDeclaration.getFirstToken()), end: getTokenPosOfNode(aliasDeclaration.propertyName ?? aliasDeclaration.name) });
151004
151131
  return aliasDeclaration;
151005
151132
  } else {
151006
151133
  Debug.assert(aliasDeclaration.parent.parent.isTypeOnly);
@@ -151096,7 +151223,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
151096
151223
  const specifierSort = (existingSpecifiers == null ? void 0 : existingSpecifiers.length) && ts_OrganizeImports_exports.detectImportSpecifierSorting(existingSpecifiers, preferences);
151097
151224
  if (specifierSort && !(ignoreCaseForSorting && specifierSort === 1 /* CaseSensitive */)) {
151098
151225
  for (const spec of newSpecifiers) {
151099
- const insertionIndex = promoteFromTypeOnly2 && !spec.isTypeOnly ? 0 : ts_OrganizeImports_exports.getImportSpecifierInsertionIndex(existingSpecifiers, spec, comparer);
151226
+ const insertionIndex = promoteFromTypeOnly2 && !spec.isTypeOnly ? 0 : ts_OrganizeImports_exports.getImportSpecifierInsertionIndex(existingSpecifiers, spec, comparer, preferences);
151100
151227
  changes.insertImportSpecifierAtIndex(sourceFile, spec, clause.namedBindings, insertionIndex);
151101
151228
  }
151102
151229
  } else if (existingSpecifiers == null ? void 0 : existingSpecifiers.length) {
@@ -166612,14 +166739,14 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
166612
166739
  if (shouldRemove)
166613
166740
  importGroup = removeUnusedImports(importGroup, sourceFile, program);
166614
166741
  if (shouldCombine)
166615
- importGroup = coalesceImportsWorker(importGroup, comparer, sourceFile);
166742
+ importGroup = coalesceImportsWorker(importGroup, comparer, sourceFile, preferences);
166616
166743
  if (shouldSort)
166617
166744
  importGroup = stableSort(importGroup, (s1, s2) => compareImportsOrRequireStatements(s1, s2, comparer));
166618
166745
  return importGroup;
166619
166746
  };
166620
166747
  topLevelImportGroupDecls.forEach((importGroupDecl) => organizeImportsWorker(importGroupDecl, processImportsOfSameModuleSpecifier));
166621
166748
  if (mode !== "RemoveUnused" /* RemoveUnused */) {
166622
- getTopLevelExportGroups(sourceFile).forEach((exportGroupDecl) => organizeImportsWorker(exportGroupDecl, (group2) => coalesceExportsWorker(group2, comparer)));
166749
+ getTopLevelExportGroups(sourceFile).forEach((exportGroupDecl) => organizeImportsWorker(exportGroupDecl, (group2) => coalesceExportsWorker(group2, comparer, preferences)));
166623
166750
  }
166624
166751
  for (const ambientModule of sourceFile.statements.filter(isAmbientModule)) {
166625
166752
  if (!ambientModule.body)
@@ -166628,7 +166755,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
166628
166755
  ambientModuleImportGroupDecls.forEach((importGroupDecl) => organizeImportsWorker(importGroupDecl, processImportsOfSameModuleSpecifier));
166629
166756
  if (mode !== "RemoveUnused" /* RemoveUnused */) {
166630
166757
  const ambientModuleExportDecls = ambientModule.body.statements.filter(isExportDeclaration);
166631
- organizeImportsWorker(ambientModuleExportDecls, (group2) => coalesceExportsWorker(group2, comparer));
166758
+ organizeImportsWorker(ambientModuleExportDecls, (group2) => coalesceExportsWorker(group2, comparer, preferences));
166632
166759
  }
166633
166760
  }
166634
166761
  return changeTracker.getChanges();
@@ -166760,11 +166887,11 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
166760
166887
  function getExternalModuleName2(specifier) {
166761
166888
  return specifier !== void 0 && isStringLiteralLike(specifier) ? specifier.text : void 0;
166762
166889
  }
166763
- function coalesceImports(importGroup, ignoreCase, sourceFile) {
166890
+ function coalesceImports(importGroup, ignoreCase, sourceFile, preferences) {
166764
166891
  const comparer = getOrganizeImportsOrdinalStringComparer(ignoreCase);
166765
- return coalesceImportsWorker(importGroup, comparer, sourceFile);
166892
+ return coalesceImportsWorker(importGroup, comparer, sourceFile, preferences);
166766
166893
  }
166767
- function coalesceImportsWorker(importGroup, comparer, sourceFile) {
166894
+ function coalesceImportsWorker(importGroup, comparer, sourceFile, preferences) {
166768
166895
  if (importGroup.length === 0) {
166769
166896
  return importGroup;
166770
166897
  }
@@ -166818,7 +166945,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
166818
166945
  }
166819
166946
  newImportSpecifiers.push(...getNewImportSpecifiers(namedImports));
166820
166947
  const sortedImportSpecifiers = factory.createNodeArray(
166821
- sortSpecifiers(newImportSpecifiers, comparer),
166948
+ sortSpecifiers(newImportSpecifiers, comparer, preferences),
166822
166949
  firstNamedImport == null ? void 0 : firstNamedImport.importClause.namedBindings.elements.hasTrailingComma
166823
166950
  );
166824
166951
  const newNamedImports = sortedImportSpecifiers.length === 0 ? newDefaultImport ? void 0 : factory.createNamedImports(emptyArray) : firstNamedImport ? factory.updateNamedImports(firstNamedImport.importClause.namedBindings, sortedImportSpecifiers) : factory.createNamedImports(sortedImportSpecifiers);
@@ -166878,11 +167005,11 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
166878
167005
  regularImports
166879
167006
  };
166880
167007
  }
166881
- function coalesceExports(exportGroup, ignoreCase) {
167008
+ function coalesceExports(exportGroup, ignoreCase, preferences) {
166882
167009
  const comparer = getOrganizeImportsOrdinalStringComparer(ignoreCase);
166883
- return coalesceExportsWorker(exportGroup, comparer);
167010
+ return coalesceExportsWorker(exportGroup, comparer, preferences);
166884
167011
  }
166885
- function coalesceExportsWorker(exportGroup, comparer) {
167012
+ function coalesceExportsWorker(exportGroup, comparer, preferences) {
166886
167013
  if (exportGroup.length === 0) {
166887
167014
  return exportGroup;
166888
167015
  }
@@ -166897,7 +167024,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
166897
167024
  }
166898
167025
  const newExportSpecifiers = [];
166899
167026
  newExportSpecifiers.push(...flatMap(exportGroup2, (i) => i.exportClause && isNamedExports(i.exportClause) ? i.exportClause.elements : emptyArray));
166900
- const sortedExportSpecifiers = sortSpecifiers(newExportSpecifiers, comparer);
167027
+ const sortedExportSpecifiers = sortSpecifiers(newExportSpecifiers, comparer, preferences);
166901
167028
  const exportDecl = exportGroup2[0];
166902
167029
  coalescedExports.push(
166903
167030
  factory.updateExportDeclaration(
@@ -166941,11 +167068,18 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
166941
167068
  importDeclaration.attributes
166942
167069
  );
166943
167070
  }
166944
- function sortSpecifiers(specifiers, comparer) {
166945
- return stableSort(specifiers, (s1, s2) => compareImportOrExportSpecifiers(s1, s2, comparer));
167071
+ function sortSpecifiers(specifiers, comparer, preferences) {
167072
+ return stableSort(specifiers, (s1, s2) => compareImportOrExportSpecifiers(s1, s2, comparer, preferences));
166946
167073
  }
166947
- function compareImportOrExportSpecifiers(s1, s2, comparer) {
166948
- return compareBooleans(s1.isTypeOnly, s2.isTypeOnly) || comparer(s1.name.text, s2.name.text);
167074
+ function compareImportOrExportSpecifiers(s1, s2, comparer, preferences) {
167075
+ switch (preferences == null ? void 0 : preferences.organizeImportsTypeOrder) {
167076
+ case "first":
167077
+ return compareBooleans(s2.isTypeOnly, s1.isTypeOnly) || comparer(s1.name.text, s2.name.text);
167078
+ case "inline":
167079
+ return comparer(s1.name.text, s2.name.text);
167080
+ default:
167081
+ return compareBooleans(s1.isTypeOnly, s2.isTypeOnly) || comparer(s1.name.text, s2.name.text);
167082
+ }
166949
167083
  }
166950
167084
  function compareModuleSpecifiers2(m1, m2, ignoreCase) {
166951
167085
  const comparer = getOrganizeImportsOrdinalStringComparer(!!ignoreCase);
@@ -167050,8 +167184,8 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
167050
167184
  const index = binarySearch(sortedImports, newImport, identity, (a, b) => compareImportsOrRequireStatements(a, b, comparer));
167051
167185
  return index < 0 ? ~index : index;
167052
167186
  }
167053
- function getImportSpecifierInsertionIndex(sortedImports, newImport, comparer) {
167054
- const index = binarySearch(sortedImports, newImport, identity, (s1, s2) => compareImportOrExportSpecifiers(s1, s2, comparer));
167187
+ function getImportSpecifierInsertionIndex(sortedImports, newImport, comparer, preferences) {
167188
+ const index = binarySearch(sortedImports, newImport, identity, (s1, s2) => compareImportOrExportSpecifiers(s1, s2, comparer, preferences));
167055
167189
  return index < 0 ? ~index : index;
167056
167190
  }
167057
167191
  function compareImportsOrRequireStatements(s1, s2, comparer) {
@@ -167180,8 +167314,26 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
167180
167314
  }
167181
167315
  };
167182
167316
  detectImportSpecifierSorting = memoizeCached((specifiers, preferences) => {
167183
- if (!arrayIsSorted(specifiers, (s1, s2) => compareBooleans(s1.isTypeOnly, s2.isTypeOnly))) {
167184
- return 0 /* None */;
167317
+ switch (preferences.organizeImportsTypeOrder) {
167318
+ case "first":
167319
+ if (!arrayIsSorted(specifiers, (s1, s2) => compareBooleans(s2.isTypeOnly, s1.isTypeOnly)))
167320
+ return 0 /* None */;
167321
+ break;
167322
+ case "inline":
167323
+ if (!arrayIsSorted(specifiers, (s1, s2) => {
167324
+ const comparer = getStringComparer(
167325
+ /*ignoreCase*/
167326
+ true
167327
+ );
167328
+ return comparer(s1.name.text, s2.name.text);
167329
+ })) {
167330
+ return 0 /* None */;
167331
+ }
167332
+ break;
167333
+ default:
167334
+ if (!arrayIsSorted(specifiers, (s1, s2) => compareBooleans(s1.isTypeOnly, s2.isTypeOnly)))
167335
+ return 0 /* None */;
167336
+ break;
167185
167337
  }
167186
167338
  const collateCaseSensitive = getOrganizeImportsComparer(
167187
167339
  preferences,
@@ -167193,6 +167345,21 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
167193
167345
  /*ignoreCase*/
167194
167346
  true
167195
167347
  );
167348
+ if (preferences.organizeImportsTypeOrder !== "inline") {
167349
+ const { type: regularImports, regular: typeImports } = groupBy(specifiers, (s) => s.isTypeOnly ? "type" : "regular");
167350
+ const regularCaseSensitivity = (regularImports == null ? void 0 : regularImports.length) ? detectSortCaseSensitivity(regularImports, (specifier) => specifier.name.text, collateCaseSensitive, collateCaseInsensitive) : void 0;
167351
+ const typeCaseSensitivity = (typeImports == null ? void 0 : typeImports.length) ? detectSortCaseSensitivity(typeImports, (specifier) => specifier.name.text ?? "", collateCaseSensitive, collateCaseInsensitive) : void 0;
167352
+ if (regularCaseSensitivity === void 0) {
167353
+ return typeCaseSensitivity ?? 0 /* None */;
167354
+ }
167355
+ if (typeCaseSensitivity === void 0) {
167356
+ return regularCaseSensitivity;
167357
+ }
167358
+ if (regularCaseSensitivity === 0 /* None */ || typeCaseSensitivity === 0 /* None */) {
167359
+ return 0 /* None */;
167360
+ }
167361
+ return typeCaseSensitivity & regularCaseSensitivity;
167362
+ }
167196
167363
  return detectSortCaseSensitivity(specifiers, (specifier) => specifier.name.text, collateCaseSensitive, collateCaseInsensitive);
167197
167364
  }, new ImportSpecifierSortingCache());
167198
167365
  }
@@ -187033,7 +187200,6 @@ ${e.message}`;
187033
187200
  isPackedArrayLiteral: () => isPackedArrayLiteral,
187034
187201
  isParameter: () => isParameter,
187035
187202
  isParameterDeclaration: () => isParameterDeclaration,
187036
- isParameterOrCatchClauseVariable: () => isParameterOrCatchClauseVariable,
187037
187203
  isParameterPropertyDeclaration: () => isParameterPropertyDeclaration,
187038
187204
  isParameterPropertyModifier: () => isParameterPropertyModifier,
187039
187205
  isParenthesizedExpression: () => isParenthesizedExpression,
@@ -189455,7 +189621,6 @@ ${e.message}`;
189455
189621
  isPackedArrayLiteral: () => isPackedArrayLiteral,
189456
189622
  isParameter: () => isParameter,
189457
189623
  isParameterDeclaration: () => isParameterDeclaration,
189458
- isParameterOrCatchClauseVariable: () => isParameterOrCatchClauseVariable,
189459
189624
  isParameterPropertyDeclaration: () => isParameterPropertyDeclaration,
189460
189625
  isParameterPropertyModifier: () => isParameterPropertyModifier,
189461
189626
  isParenthesizedExpression: () => isParenthesizedExpression,
@@ -54,7 +54,7 @@ var path = __toESM(require("path"));
54
54
 
55
55
  // src/compiler/corePublic.ts
56
56
  var versionMajorMinor = "5.4";
57
- var version = `${versionMajorMinor}.0-dev.20240108`;
57
+ var version = `${versionMajorMinor}.0-dev.20240110`;
58
58
 
59
59
  // src/compiler/core.ts
60
60
  var emptyArray = [];
@@ -11129,7 +11129,7 @@ function Symbol4(flags, name) {
11129
11129
  this.exportSymbol = void 0;
11130
11130
  this.constEnumOnlyModule = void 0;
11131
11131
  this.isReferenced = void 0;
11132
- this.isAssigned = void 0;
11132
+ this.lastAssignmentPos = void 0;
11133
11133
  this.links = void 0;
11134
11134
  }
11135
11135
  function Type3(checker, flags) {