typescript 5.4.0-dev.20240109 → 5.4.0-dev.20240111
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/tsc.js +181 -55
- package/lib/tsserver.js +259 -79
- package/lib/typescript.d.ts +9 -0
- package/lib/typescript.js +258 -79
- package/lib/typingsInstaller.js +1 -1
- package/package.json +2 -2
package/lib/tsserver.js
CHANGED
|
@@ -898,6 +898,7 @@ __export(server_exports, {
|
|
|
898
898
|
getModuleSpecifierEndingPreference: () => getModuleSpecifierEndingPreference,
|
|
899
899
|
getModuleSpecifierResolverHost: () => getModuleSpecifierResolverHost,
|
|
900
900
|
getNameForExportedSymbol: () => getNameForExportedSymbol,
|
|
901
|
+
getNameFromImportAttribute: () => getNameFromImportAttribute,
|
|
901
902
|
getNameFromIndexInfo: () => getNameFromIndexInfo,
|
|
902
903
|
getNameFromPropertyName: () => getNameFromPropertyName,
|
|
903
904
|
getNameOfAccessExpression: () => getNameOfAccessExpression,
|
|
@@ -2340,7 +2341,7 @@ module.exports = __toCommonJS(server_exports);
|
|
|
2340
2341
|
|
|
2341
2342
|
// src/compiler/corePublic.ts
|
|
2342
2343
|
var versionMajorMinor = "5.4";
|
|
2343
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
2344
|
+
var version = `${versionMajorMinor}.0-dev.20240111`;
|
|
2344
2345
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2345
2346
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2346
2347
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -6599,6 +6600,7 @@ var InternalSymbolName = /* @__PURE__ */ ((InternalSymbolName2) => {
|
|
|
6599
6600
|
InternalSymbolName2["Default"] = "default";
|
|
6600
6601
|
InternalSymbolName2["This"] = "this";
|
|
6601
6602
|
InternalSymbolName2["InstantiationExpression"] = "__instantiationExpression";
|
|
6603
|
+
InternalSymbolName2["ImportAttributes"] = "__importAttributes";
|
|
6602
6604
|
return InternalSymbolName2;
|
|
6603
6605
|
})(InternalSymbolName || {});
|
|
6604
6606
|
var NodeCheckFlags = /* @__PURE__ */ ((NodeCheckFlags2) => {
|
|
@@ -16546,7 +16548,7 @@ function isPartOfTypeNode(node) {
|
|
|
16546
16548
|
case 116 /* VoidKeyword */:
|
|
16547
16549
|
return node.parent.kind !== 222 /* VoidExpression */;
|
|
16548
16550
|
case 233 /* ExpressionWithTypeArguments */:
|
|
16549
|
-
return
|
|
16551
|
+
return isPartOfTypeExpressionWithTypeArguments(node);
|
|
16550
16552
|
case 168 /* TypeParameter */:
|
|
16551
16553
|
return node.parent.kind === 200 /* MappedType */ || node.parent.kind === 195 /* InferType */;
|
|
16552
16554
|
case 80 /* Identifier */:
|
|
@@ -16571,7 +16573,7 @@ function isPartOfTypeNode(node) {
|
|
|
16571
16573
|
}
|
|
16572
16574
|
switch (parent2.kind) {
|
|
16573
16575
|
case 233 /* ExpressionWithTypeArguments */:
|
|
16574
|
-
return
|
|
16576
|
+
return isPartOfTypeExpressionWithTypeArguments(parent2);
|
|
16575
16577
|
case 168 /* TypeParameter */:
|
|
16576
16578
|
return node === parent2.constraint;
|
|
16577
16579
|
case 352 /* JSDocTemplateTag */:
|
|
@@ -16605,6 +16607,9 @@ function isPartOfTypeNode(node) {
|
|
|
16605
16607
|
}
|
|
16606
16608
|
return false;
|
|
16607
16609
|
}
|
|
16610
|
+
function isPartOfTypeExpressionWithTypeArguments(node) {
|
|
16611
|
+
return isJSDocImplementsTag(node.parent) || isJSDocAugmentsTag(node.parent) || isHeritageClause(node.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(node);
|
|
16612
|
+
}
|
|
16608
16613
|
function isChildOfNodeWithKind(node, kind) {
|
|
16609
16614
|
while (node) {
|
|
16610
16615
|
if (node.kind === kind) {
|
|
@@ -21899,6 +21904,9 @@ var stringReplace = String.prototype.replace;
|
|
|
21899
21904
|
function replaceFirstStar(s, replacement) {
|
|
21900
21905
|
return stringReplace.call(s, "*", replacement);
|
|
21901
21906
|
}
|
|
21907
|
+
function getNameFromImportAttribute(node) {
|
|
21908
|
+
return isIdentifier(node.name) ? node.name.escapedText : escapeLeadingUnderscores(node.name.text);
|
|
21909
|
+
}
|
|
21902
21910
|
|
|
21903
21911
|
// src/compiler/factory/baseNodeFactory.ts
|
|
21904
21912
|
function createBaseNodeFactory() {
|
|
@@ -49019,6 +49027,14 @@ function createTypeChecker(host) {
|
|
|
49019
49027
|
emptyArray,
|
|
49020
49028
|
emptyArray
|
|
49021
49029
|
);
|
|
49030
|
+
var resolvingApparentMappedType = createAnonymousType(
|
|
49031
|
+
/*symbol*/
|
|
49032
|
+
void 0,
|
|
49033
|
+
emptySymbols,
|
|
49034
|
+
emptyArray,
|
|
49035
|
+
emptyArray,
|
|
49036
|
+
emptyArray
|
|
49037
|
+
);
|
|
49022
49038
|
var markerSuperType = createTypeParameter();
|
|
49023
49039
|
var markerSubType = createTypeParameter();
|
|
49024
49040
|
markerSubType.constraint = markerSuperType;
|
|
@@ -49173,6 +49189,7 @@ function createTypeChecker(host) {
|
|
|
49173
49189
|
var deferredGlobalImportMetaType;
|
|
49174
49190
|
var deferredGlobalImportMetaExpressionType;
|
|
49175
49191
|
var deferredGlobalImportCallOptionsType;
|
|
49192
|
+
var deferredGlobalImportAttributesType;
|
|
49176
49193
|
var deferredGlobalDisposableType;
|
|
49177
49194
|
var deferredGlobalAsyncDisposableType;
|
|
49178
49195
|
var deferredGlobalExtractSymbol;
|
|
@@ -52068,29 +52085,7 @@ function createTypeChecker(host) {
|
|
|
52068
52085
|
function getContainersOfSymbol(symbol, enclosingDeclaration, meaning) {
|
|
52069
52086
|
const container = getParentOfSymbol(symbol);
|
|
52070
52087
|
if (container && !(symbol.flags & 262144 /* TypeParameter */)) {
|
|
52071
|
-
|
|
52072
|
-
const reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration);
|
|
52073
|
-
const objectLiteralContainer = getVariableDeclarationOfObjectLiteral(container, meaning);
|
|
52074
|
-
if (enclosingDeclaration && container.flags & getQualifiedLeftMeaning(meaning) && getAccessibleSymbolChain(
|
|
52075
|
-
container,
|
|
52076
|
-
enclosingDeclaration,
|
|
52077
|
-
1920 /* Namespace */,
|
|
52078
|
-
/*useOnlyExternalAliasing*/
|
|
52079
|
-
false
|
|
52080
|
-
)) {
|
|
52081
|
-
return append(concatenate(concatenate([container], additionalContainers), reexportContainers), objectLiteralContainer);
|
|
52082
|
-
}
|
|
52083
|
-
const firstVariableMatch = !(container.flags & getQualifiedLeftMeaning(meaning)) && container.flags & 788968 /* Type */ && getDeclaredTypeOfSymbol(container).flags & 524288 /* Object */ && meaning === 111551 /* Value */ ? forEachSymbolTableInScope(enclosingDeclaration, (t) => {
|
|
52084
|
-
return forEachEntry(t, (s) => {
|
|
52085
|
-
if (s.flags & getQualifiedLeftMeaning(meaning) && getTypeOfSymbol(s) === getDeclaredTypeOfSymbol(container)) {
|
|
52086
|
-
return s;
|
|
52087
|
-
}
|
|
52088
|
-
});
|
|
52089
|
-
}) : void 0;
|
|
52090
|
-
let res = firstVariableMatch ? [firstVariableMatch, ...additionalContainers, container] : [...additionalContainers, container];
|
|
52091
|
-
res = append(res, objectLiteralContainer);
|
|
52092
|
-
res = addRange(res, reexportContainers);
|
|
52093
|
-
return res;
|
|
52088
|
+
return getWithAlternativeContainers(container);
|
|
52094
52089
|
}
|
|
52095
52090
|
const candidates = mapDefined(symbol.declarations, (d) => {
|
|
52096
52091
|
if (!isAmbientModule(d) && d.parent) {
|
|
@@ -52112,7 +52107,40 @@ function createTypeChecker(host) {
|
|
|
52112
52107
|
if (!length(candidates)) {
|
|
52113
52108
|
return void 0;
|
|
52114
52109
|
}
|
|
52115
|
-
|
|
52110
|
+
const containers = mapDefined(candidates, (candidate) => getAliasForSymbolInContainer(candidate, symbol) ? candidate : void 0);
|
|
52111
|
+
let bestContainers = [];
|
|
52112
|
+
let alternativeContainers = [];
|
|
52113
|
+
for (const container2 of containers) {
|
|
52114
|
+
const [bestMatch, ...rest] = getWithAlternativeContainers(container2);
|
|
52115
|
+
bestContainers = append(bestContainers, bestMatch);
|
|
52116
|
+
alternativeContainers = addRange(alternativeContainers, rest);
|
|
52117
|
+
}
|
|
52118
|
+
return concatenate(bestContainers, alternativeContainers);
|
|
52119
|
+
function getWithAlternativeContainers(container2) {
|
|
52120
|
+
const additionalContainers = mapDefined(container2.declarations, fileSymbolIfFileSymbolExportEqualsContainer);
|
|
52121
|
+
const reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration);
|
|
52122
|
+
const objectLiteralContainer = getVariableDeclarationOfObjectLiteral(container2, meaning);
|
|
52123
|
+
if (enclosingDeclaration && container2.flags & getQualifiedLeftMeaning(meaning) && getAccessibleSymbolChain(
|
|
52124
|
+
container2,
|
|
52125
|
+
enclosingDeclaration,
|
|
52126
|
+
1920 /* Namespace */,
|
|
52127
|
+
/*useOnlyExternalAliasing*/
|
|
52128
|
+
false
|
|
52129
|
+
)) {
|
|
52130
|
+
return append(concatenate(concatenate([container2], additionalContainers), reexportContainers), objectLiteralContainer);
|
|
52131
|
+
}
|
|
52132
|
+
const firstVariableMatch = !(container2.flags & getQualifiedLeftMeaning(meaning)) && container2.flags & 788968 /* Type */ && getDeclaredTypeOfSymbol(container2).flags & 524288 /* Object */ && meaning === 111551 /* Value */ ? forEachSymbolTableInScope(enclosingDeclaration, (t) => {
|
|
52133
|
+
return forEachEntry(t, (s) => {
|
|
52134
|
+
if (s.flags & getQualifiedLeftMeaning(meaning) && getTypeOfSymbol(s) === getDeclaredTypeOfSymbol(container2)) {
|
|
52135
|
+
return s;
|
|
52136
|
+
}
|
|
52137
|
+
});
|
|
52138
|
+
}) : void 0;
|
|
52139
|
+
let res = firstVariableMatch ? [firstVariableMatch, ...additionalContainers, container2] : [...additionalContainers, container2];
|
|
52140
|
+
res = append(res, objectLiteralContainer);
|
|
52141
|
+
res = addRange(res, reexportContainers);
|
|
52142
|
+
return res;
|
|
52143
|
+
}
|
|
52116
52144
|
function fileSymbolIfFileSymbolExportEqualsContainer(d) {
|
|
52117
52145
|
return container && getFileSymbolIfFileSymbolExportEqualsContainer(d, container);
|
|
52118
52146
|
}
|
|
@@ -52150,6 +52178,13 @@ function createTypeChecker(host) {
|
|
|
52150
52178
|
});
|
|
52151
52179
|
}
|
|
52152
52180
|
function getSymbolIfSameReference(s1, s2) {
|
|
52181
|
+
var _a, _b;
|
|
52182
|
+
if (s1.flags & 524288 /* TypeAlias */ && ((_a = s2.declarations) == null ? void 0 : _a.find(isTypeAlias))) {
|
|
52183
|
+
s2 = getDeclaredTypeOfTypeAlias(s2).aliasSymbol || s2;
|
|
52184
|
+
}
|
|
52185
|
+
if (s2.flags & 524288 /* TypeAlias */ && ((_b = s1.declarations) == null ? void 0 : _b.find(isTypeAlias))) {
|
|
52186
|
+
s1 = getDeclaredTypeOfTypeAlias(s1).aliasSymbol || s1;
|
|
52187
|
+
}
|
|
52153
52188
|
if (getMergedSymbol(resolveSymbol(getMergedSymbol(s1))) === getMergedSymbol(resolveSymbol(getMergedSymbol(s2)))) {
|
|
52154
52189
|
return s1;
|
|
52155
52190
|
}
|
|
@@ -57392,7 +57427,7 @@ function createTypeChecker(host) {
|
|
|
57392
57427
|
/*reportErrors*/
|
|
57393
57428
|
false
|
|
57394
57429
|
) : unknownType;
|
|
57395
|
-
return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0 /* Normal */, contextualType)));
|
|
57430
|
+
return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, reportErrors2 ? 0 /* Normal */ : 1 /* Contextual */, contextualType)));
|
|
57396
57431
|
}
|
|
57397
57432
|
if (isBindingPattern(element.name)) {
|
|
57398
57433
|
return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors2);
|
|
@@ -57473,6 +57508,24 @@ function createTypeChecker(host) {
|
|
|
57473
57508
|
0 /* Normal */
|
|
57474
57509
|
), declaration, reportErrors2);
|
|
57475
57510
|
}
|
|
57511
|
+
function getTypeFromImportAttributes(node) {
|
|
57512
|
+
const links = getNodeLinks(node);
|
|
57513
|
+
if (!links.resolvedType) {
|
|
57514
|
+
const symbol = createSymbol(4096 /* ObjectLiteral */, "__importAttributes" /* ImportAttributes */);
|
|
57515
|
+
const members = createSymbolTable();
|
|
57516
|
+
forEach(node.elements, (attr) => {
|
|
57517
|
+
const member = createSymbol(4 /* Property */, getNameFromImportAttribute(attr));
|
|
57518
|
+
member.parent = symbol;
|
|
57519
|
+
member.links.type = checkImportAttribute(attr);
|
|
57520
|
+
member.links.target = member;
|
|
57521
|
+
members.set(member.escapedName, member);
|
|
57522
|
+
});
|
|
57523
|
+
const type = createAnonymousType(symbol, members, emptyArray, emptyArray, emptyArray);
|
|
57524
|
+
type.objectFlags |= 128 /* ObjectLiteral */ | 262144 /* NonInferrableType */;
|
|
57525
|
+
links.resolvedType = type;
|
|
57526
|
+
}
|
|
57527
|
+
return links.resolvedType;
|
|
57528
|
+
}
|
|
57476
57529
|
function isGlobalSymbolConstructor(node) {
|
|
57477
57530
|
const symbol = getSymbolOfNode(node);
|
|
57478
57531
|
const globalSymbol = getGlobalESSymbolConstructorTypeSymbol(
|
|
@@ -57526,18 +57579,18 @@ function createTypeChecker(host) {
|
|
|
57526
57579
|
}
|
|
57527
57580
|
return false;
|
|
57528
57581
|
}
|
|
57529
|
-
function getTypeOfVariableOrParameterOrProperty(symbol) {
|
|
57582
|
+
function getTypeOfVariableOrParameterOrProperty(symbol, checkMode) {
|
|
57530
57583
|
const links = getSymbolLinks(symbol);
|
|
57531
57584
|
if (!links.type) {
|
|
57532
|
-
const type = getTypeOfVariableOrParameterOrPropertyWorker(symbol);
|
|
57533
|
-
if (!links.type && !isParameterOfContextSensitiveSignature(symbol)) {
|
|
57585
|
+
const type = getTypeOfVariableOrParameterOrPropertyWorker(symbol, checkMode);
|
|
57586
|
+
if (!links.type && !isParameterOfContextSensitiveSignature(symbol) && !checkMode) {
|
|
57534
57587
|
links.type = type;
|
|
57535
57588
|
}
|
|
57536
57589
|
return type;
|
|
57537
57590
|
}
|
|
57538
57591
|
return links.type;
|
|
57539
57592
|
}
|
|
57540
|
-
function getTypeOfVariableOrParameterOrPropertyWorker(symbol) {
|
|
57593
|
+
function getTypeOfVariableOrParameterOrPropertyWorker(symbol, checkMode) {
|
|
57541
57594
|
if (symbol.flags & 4194304 /* Prototype */) {
|
|
57542
57595
|
return getTypeOfPrototypeProperty(symbol);
|
|
57543
57596
|
}
|
|
@@ -57575,6 +57628,9 @@ function createTypeChecker(host) {
|
|
|
57575
57628
|
if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) {
|
|
57576
57629
|
return getTypeOfFuncClassEnumModule(symbol);
|
|
57577
57630
|
}
|
|
57631
|
+
if (isBindingElement(declaration) && checkMode === 1 /* Contextual */) {
|
|
57632
|
+
return errorType;
|
|
57633
|
+
}
|
|
57578
57634
|
return reportCircularityError(symbol);
|
|
57579
57635
|
}
|
|
57580
57636
|
let type;
|
|
@@ -57612,6 +57668,9 @@ function createTypeChecker(host) {
|
|
|
57612
57668
|
if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) {
|
|
57613
57669
|
return getTypeOfFuncClassEnumModule(symbol);
|
|
57614
57670
|
}
|
|
57671
|
+
if (isBindingElement(declaration) && checkMode === 1 /* Contextual */) {
|
|
57672
|
+
return type;
|
|
57673
|
+
}
|
|
57615
57674
|
return reportCircularityError(symbol);
|
|
57616
57675
|
}
|
|
57617
57676
|
return type;
|
|
@@ -57840,7 +57899,7 @@ function createTypeChecker(host) {
|
|
|
57840
57899
|
}
|
|
57841
57900
|
return getTypeOfSymbol(symbol);
|
|
57842
57901
|
}
|
|
57843
|
-
function getTypeOfSymbol(symbol) {
|
|
57902
|
+
function getTypeOfSymbol(symbol, checkMode) {
|
|
57844
57903
|
const checkFlags = getCheckFlags(symbol);
|
|
57845
57904
|
if (checkFlags & 65536 /* DeferredType */) {
|
|
57846
57905
|
return getTypeOfSymbolWithDeferredType(symbol);
|
|
@@ -57855,7 +57914,7 @@ function createTypeChecker(host) {
|
|
|
57855
57914
|
return getTypeOfReverseMappedSymbol(symbol);
|
|
57856
57915
|
}
|
|
57857
57916
|
if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) {
|
|
57858
|
-
return getTypeOfVariableOrParameterOrProperty(symbol);
|
|
57917
|
+
return getTypeOfVariableOrParameterOrProperty(symbol, checkMode);
|
|
57859
57918
|
}
|
|
57860
57919
|
if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) {
|
|
57861
57920
|
return getTypeOfFuncClassEnumModule(symbol);
|
|
@@ -59888,14 +59947,30 @@ function createTypeChecker(host) {
|
|
|
59888
59947
|
return !!(typeParameter.symbol && forEach(typeParameter.symbol.declarations, (decl) => isTypeParameterDeclaration(decl) && decl.default));
|
|
59889
59948
|
}
|
|
59890
59949
|
function getApparentTypeOfMappedType(type) {
|
|
59891
|
-
|
|
59950
|
+
if (type.resolvedApparentType) {
|
|
59951
|
+
if (type.resolvedApparentType === resolvingApparentMappedType) {
|
|
59952
|
+
return type.resolvedApparentType = type;
|
|
59953
|
+
}
|
|
59954
|
+
return type.resolvedApparentType;
|
|
59955
|
+
}
|
|
59956
|
+
type.resolvedApparentType = resolvingApparentMappedType;
|
|
59957
|
+
return type.resolvedApparentType = getResolvedApparentTypeOfMappedType(type);
|
|
59892
59958
|
}
|
|
59893
59959
|
function getResolvedApparentTypeOfMappedType(type) {
|
|
59894
|
-
const
|
|
59895
|
-
|
|
59896
|
-
|
|
59960
|
+
const mappedType = type.target || type;
|
|
59961
|
+
const typeVariable = getHomomorphicTypeVariable(mappedType);
|
|
59962
|
+
if (typeVariable && !mappedType.declaration.nameType) {
|
|
59963
|
+
let constraint;
|
|
59964
|
+
if (!type.target) {
|
|
59965
|
+
constraint = getConstraintOfTypeParameter(typeVariable);
|
|
59966
|
+
} else {
|
|
59967
|
+
const modifiersConstraint = getConstraintOfType(getModifiersTypeFromMappedType(type));
|
|
59968
|
+
if (modifiersConstraint) {
|
|
59969
|
+
constraint = getApparentType(modifiersConstraint);
|
|
59970
|
+
}
|
|
59971
|
+
}
|
|
59897
59972
|
if (constraint && everyType(constraint, isArrayOrTupleType)) {
|
|
59898
|
-
return instantiateType(
|
|
59973
|
+
return instantiateType(mappedType, prependTypeMapping(typeVariable, constraint, mappedType.mapper));
|
|
59899
59974
|
}
|
|
59900
59975
|
}
|
|
59901
59976
|
return type;
|
|
@@ -59986,6 +60061,7 @@ function createTypeChecker(host) {
|
|
|
59986
60061
|
clone2.parent = (_c = (_b = singleProp.valueDeclaration) == null ? void 0 : _b.symbol) == null ? void 0 : _c.parent;
|
|
59987
60062
|
clone2.links.containingType = containingType;
|
|
59988
60063
|
clone2.links.mapper = links == null ? void 0 : links.mapper;
|
|
60064
|
+
clone2.links.writeType = getWriteTypeOfSymbol(singleProp);
|
|
59989
60065
|
return clone2;
|
|
59990
60066
|
} else {
|
|
59991
60067
|
return singleProp;
|
|
@@ -61454,6 +61530,14 @@ function createTypeChecker(host) {
|
|
|
61454
61530
|
reportErrors2
|
|
61455
61531
|
)) || emptyObjectType;
|
|
61456
61532
|
}
|
|
61533
|
+
function getGlobalImportAttributesType(reportErrors2) {
|
|
61534
|
+
return deferredGlobalImportAttributesType || (deferredGlobalImportAttributesType = getGlobalType(
|
|
61535
|
+
"ImportAttributes",
|
|
61536
|
+
/*arity*/
|
|
61537
|
+
0,
|
|
61538
|
+
reportErrors2
|
|
61539
|
+
)) || emptyObjectType;
|
|
61540
|
+
}
|
|
61457
61541
|
function getGlobalESSymbolConstructorSymbol(reportErrors2) {
|
|
61458
61542
|
return deferredGlobalESSymbolConstructorSymbol || (deferredGlobalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol", reportErrors2));
|
|
61459
61543
|
}
|
|
@@ -66611,6 +66695,18 @@ function createTypeChecker(host) {
|
|
|
66611
66695
|
}
|
|
66612
66696
|
return result2;
|
|
66613
66697
|
}
|
|
66698
|
+
function getApparentMappedTypeKeys(nameType, targetType) {
|
|
66699
|
+
const modifiersType = getApparentType(getModifiersTypeFromMappedType(targetType));
|
|
66700
|
+
const mappedKeys = [];
|
|
66701
|
+
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(
|
|
66702
|
+
modifiersType,
|
|
66703
|
+
8576 /* StringOrNumberLiteralOrUnique */,
|
|
66704
|
+
/*stringsOnly*/
|
|
66705
|
+
false,
|
|
66706
|
+
(t) => void mappedKeys.push(instantiateType(nameType, appendTypeMapping(targetType.mapper, getTypeParameterFromMappedType(targetType), t)))
|
|
66707
|
+
);
|
|
66708
|
+
return getUnionType(mappedKeys);
|
|
66709
|
+
}
|
|
66614
66710
|
function structuredTypeRelatedToWorker(source2, target2, reportErrors2, intersectionState, saveErrorInfo) {
|
|
66615
66711
|
let result2;
|
|
66616
66712
|
let originalErrorInfo;
|
|
@@ -66793,16 +66889,8 @@ function createTypeChecker(host) {
|
|
|
66793
66889
|
const constraintType = getConstraintTypeFromMappedType(targetType);
|
|
66794
66890
|
let targetKeys;
|
|
66795
66891
|
if (nameType && isMappedTypeWithKeyofConstraintDeclaration(targetType)) {
|
|
66796
|
-
const
|
|
66797
|
-
|
|
66798
|
-
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(
|
|
66799
|
-
modifiersType,
|
|
66800
|
-
8576 /* StringOrNumberLiteralOrUnique */,
|
|
66801
|
-
/*stringsOnly*/
|
|
66802
|
-
false,
|
|
66803
|
-
(t) => void mappedKeys.push(instantiateType(nameType, appendTypeMapping(targetType.mapper, getTypeParameterFromMappedType(targetType), t)))
|
|
66804
|
-
);
|
|
66805
|
-
targetKeys = getUnionType([...mappedKeys, nameType]);
|
|
66892
|
+
const mappedKeys = getApparentMappedTypeKeys(nameType, targetType);
|
|
66893
|
+
targetKeys = getUnionType([mappedKeys, nameType]);
|
|
66806
66894
|
} else {
|
|
66807
66895
|
targetKeys = nameType || constraintType;
|
|
66808
66896
|
}
|
|
@@ -66973,9 +67061,18 @@ function createTypeChecker(host) {
|
|
|
66973
67061
|
}
|
|
66974
67062
|
}
|
|
66975
67063
|
} else if (sourceFlags & 4194304 /* Index */) {
|
|
66976
|
-
|
|
67064
|
+
const isDeferredMappedIndex = shouldDeferIndexType(source2.type, source2.indexFlags) && getObjectFlags(source2.type) & 32 /* Mapped */;
|
|
67065
|
+
if (result2 = isRelatedTo(keyofConstraintType, target2, 1 /* Source */, reportErrors2 && !isDeferredMappedIndex)) {
|
|
66977
67066
|
return result2;
|
|
66978
67067
|
}
|
|
67068
|
+
if (isDeferredMappedIndex) {
|
|
67069
|
+
const mappedType = source2.type;
|
|
67070
|
+
const nameType = getNameTypeFromMappedType(mappedType);
|
|
67071
|
+
const sourceMappedKeys = nameType && isMappedTypeWithKeyofConstraintDeclaration(mappedType) ? getApparentMappedTypeKeys(nameType, mappedType) : nameType || getConstraintTypeFromMappedType(mappedType);
|
|
67072
|
+
if (result2 = isRelatedTo(sourceMappedKeys, target2, 1 /* Source */, reportErrors2)) {
|
|
67073
|
+
return result2;
|
|
67074
|
+
}
|
|
67075
|
+
}
|
|
66979
67076
|
} else if (sourceFlags & 134217728 /* TemplateLiteral */ && !(targetFlags & 524288 /* Object */)) {
|
|
66980
67077
|
if (!(targetFlags & 134217728 /* TemplateLiteral */)) {
|
|
66981
67078
|
const constraint = getBaseConstraintOfType(source2);
|
|
@@ -72188,9 +72285,9 @@ function createTypeChecker(host) {
|
|
|
72188
72285
|
}
|
|
72189
72286
|
}
|
|
72190
72287
|
}
|
|
72191
|
-
function getNarrowedTypeOfSymbol(symbol, location) {
|
|
72288
|
+
function getNarrowedTypeOfSymbol(symbol, location, checkMode) {
|
|
72192
72289
|
var _a;
|
|
72193
|
-
const type = getTypeOfSymbol(symbol);
|
|
72290
|
+
const type = getTypeOfSymbol(symbol, checkMode);
|
|
72194
72291
|
const declaration = symbol.valueDeclaration;
|
|
72195
72292
|
if (declaration) {
|
|
72196
72293
|
if (isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && declaration.parent.elements.length >= 2) {
|
|
@@ -72317,7 +72414,7 @@ function createTypeChecker(host) {
|
|
|
72317
72414
|
}
|
|
72318
72415
|
}
|
|
72319
72416
|
checkNestedBlockScopedBinding(node, symbol);
|
|
72320
|
-
let type = getNarrowedTypeOfSymbol(localOrExportSymbol, node);
|
|
72417
|
+
let type = getNarrowedTypeOfSymbol(localOrExportSymbol, node, checkMode);
|
|
72321
72418
|
const assignmentKind = getAssignmentTargetKind(node);
|
|
72322
72419
|
if (assignmentKind) {
|
|
72323
72420
|
if (!(localOrExportSymbol.flags & 3 /* Variable */) && !(isInJSFile(node) && localOrExportSymbol.flags & 512 /* ValueModule */)) {
|
|
@@ -73627,6 +73724,8 @@ function createTypeChecker(host) {
|
|
|
73627
73724
|
case 286 /* JsxOpeningElement */:
|
|
73628
73725
|
case 285 /* JsxSelfClosingElement */:
|
|
73629
73726
|
return getContextualJsxElementAttributesType(parent2, contextFlags);
|
|
73727
|
+
case 301 /* ImportAttribute */:
|
|
73728
|
+
return getContextualImportAttributeType(parent2);
|
|
73630
73729
|
}
|
|
73631
73730
|
return void 0;
|
|
73632
73731
|
}
|
|
@@ -73674,6 +73773,12 @@ function createTypeChecker(host) {
|
|
|
73674
73773
|
}
|
|
73675
73774
|
}
|
|
73676
73775
|
}
|
|
73776
|
+
function getContextualImportAttributeType(node) {
|
|
73777
|
+
return getTypeOfPropertyOfContextualType(getGlobalImportAttributesType(
|
|
73778
|
+
/*reportErrors*/
|
|
73779
|
+
false
|
|
73780
|
+
), getNameFromImportAttribute(node));
|
|
73781
|
+
}
|
|
73677
73782
|
function getContextualJsxElementAttributesType(node, contextFlags) {
|
|
73678
73783
|
if (isJsxOpeningElement(node) && contextFlags !== 4 /* Completions */) {
|
|
73679
73784
|
const index = findContextualNode(
|
|
@@ -85759,6 +85864,13 @@ function createTypeChecker(host) {
|
|
|
85759
85864
|
var _a;
|
|
85760
85865
|
const node = declaration.attributes;
|
|
85761
85866
|
if (node) {
|
|
85867
|
+
const importAttributesType = getGlobalImportAttributesType(
|
|
85868
|
+
/*reportErrors*/
|
|
85869
|
+
true
|
|
85870
|
+
);
|
|
85871
|
+
if (importAttributesType !== emptyObjectType) {
|
|
85872
|
+
checkTypeAssignableTo(getTypeFromImportAttributes(node), getNullableType(importAttributesType, 32768 /* Undefined */), node);
|
|
85873
|
+
}
|
|
85762
85874
|
const validForTypeAttributes = isExclusivelyTypeOnlyImportOrExport(declaration);
|
|
85763
85875
|
const override = getResolutionModeOverride(node, validForTypeAttributes ? grammarErrorOnNode : void 0);
|
|
85764
85876
|
const isImportAttributes2 = declaration.attributes.token === 118 /* WithKeyword */;
|
|
@@ -85778,6 +85890,9 @@ function createTypeChecker(host) {
|
|
|
85778
85890
|
}
|
|
85779
85891
|
}
|
|
85780
85892
|
}
|
|
85893
|
+
function checkImportAttribute(node) {
|
|
85894
|
+
return getRegularTypeOfLiteralType(checkExpressionCached(node.value));
|
|
85895
|
+
}
|
|
85781
85896
|
function checkImportDeclaration(node) {
|
|
85782
85897
|
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)) {
|
|
85783
85898
|
return;
|
|
@@ -87193,6 +87308,12 @@ function createTypeChecker(host) {
|
|
|
87193
87308
|
if (isMetaProperty(node.parent) && node.parent.keywordToken === node.kind) {
|
|
87194
87309
|
return checkMetaPropertyKeyword(node.parent);
|
|
87195
87310
|
}
|
|
87311
|
+
if (isImportAttributes(node)) {
|
|
87312
|
+
return getGlobalImportAttributesType(
|
|
87313
|
+
/*reportErrors*/
|
|
87314
|
+
false
|
|
87315
|
+
);
|
|
87316
|
+
}
|
|
87196
87317
|
return errorType;
|
|
87197
87318
|
}
|
|
87198
87319
|
function getTypeOfAssignmentPattern(expr) {
|
|
@@ -118397,7 +118518,14 @@ function createPrinter(printerOptions = {}, handlers = {}) {
|
|
|
118397
118518
|
function willEmitLeadingNewLine(node) {
|
|
118398
118519
|
if (!currentSourceFile)
|
|
118399
118520
|
return false;
|
|
118400
|
-
|
|
118521
|
+
const leadingCommentRanges = getLeadingCommentRanges(currentSourceFile.text, node.pos);
|
|
118522
|
+
if (leadingCommentRanges) {
|
|
118523
|
+
const parseNode = getParseTreeNode(node);
|
|
118524
|
+
if (parseNode && isParenthesizedExpression(parseNode.parent)) {
|
|
118525
|
+
return true;
|
|
118526
|
+
}
|
|
118527
|
+
}
|
|
118528
|
+
if (some(leadingCommentRanges, commentWillEmitNewLine))
|
|
118401
118529
|
return true;
|
|
118402
118530
|
if (some(getSyntheticLeadingComments(node), commentWillEmitNewLine))
|
|
118403
118531
|
return true;
|
|
@@ -124498,7 +124626,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
124498
124626
|
}
|
|
124499
124627
|
const isFromNodeModulesSearch = resolution.isExternalLibraryImport;
|
|
124500
124628
|
const isJsFile = !resolutionExtensionIsTSOrJson(resolution.extension);
|
|
124501
|
-
const isJsFileFromNodeModules = isFromNodeModulesSearch && isJsFile;
|
|
124629
|
+
const isJsFileFromNodeModules = isFromNodeModulesSearch && isJsFile && (!resolution.originalPath || pathContainsNodeModules(resolution.resolvedFileName));
|
|
124502
124630
|
const resolvedFileName = resolution.resolvedFileName;
|
|
124503
124631
|
if (isFromNodeModulesSearch) {
|
|
124504
124632
|
currentNodeModulesDepth++;
|
|
@@ -152355,14 +152483,14 @@ function promoteFromTypeOnly(changes, aliasDeclaration, program, sourceFile, pre
|
|
|
152355
152483
|
aliasDeclaration.name
|
|
152356
152484
|
);
|
|
152357
152485
|
const comparer = ts_OrganizeImports_exports.getOrganizeImportsComparer(preferences, sortKind === 2 /* CaseInsensitive */);
|
|
152358
|
-
const insertionIndex = ts_OrganizeImports_exports.getImportSpecifierInsertionIndex(aliasDeclaration.parent.elements, newSpecifier, comparer);
|
|
152359
|
-
if (aliasDeclaration.parent.elements.indexOf(aliasDeclaration)
|
|
152486
|
+
const insertionIndex = ts_OrganizeImports_exports.getImportSpecifierInsertionIndex(aliasDeclaration.parent.elements, newSpecifier, comparer, preferences);
|
|
152487
|
+
if (insertionIndex !== aliasDeclaration.parent.elements.indexOf(aliasDeclaration)) {
|
|
152360
152488
|
changes.delete(sourceFile, aliasDeclaration);
|
|
152361
152489
|
changes.insertImportSpecifierAtIndex(sourceFile, newSpecifier, aliasDeclaration.parent, insertionIndex);
|
|
152362
152490
|
return aliasDeclaration;
|
|
152363
152491
|
}
|
|
152364
152492
|
}
|
|
152365
|
-
changes.deleteRange(sourceFile, aliasDeclaration.getFirstToken());
|
|
152493
|
+
changes.deleteRange(sourceFile, { pos: getTokenPosOfNode(aliasDeclaration.getFirstToken()), end: getTokenPosOfNode(aliasDeclaration.propertyName ?? aliasDeclaration.name) });
|
|
152366
152494
|
return aliasDeclaration;
|
|
152367
152495
|
} else {
|
|
152368
152496
|
Debug.assert(aliasDeclaration.parent.parent.isTypeOnly);
|
|
@@ -152458,7 +152586,7 @@ function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImpor
|
|
|
152458
152586
|
const specifierSort = (existingSpecifiers == null ? void 0 : existingSpecifiers.length) && ts_OrganizeImports_exports.detectImportSpecifierSorting(existingSpecifiers, preferences);
|
|
152459
152587
|
if (specifierSort && !(ignoreCaseForSorting && specifierSort === 1 /* CaseSensitive */)) {
|
|
152460
152588
|
for (const spec of newSpecifiers) {
|
|
152461
|
-
const insertionIndex = promoteFromTypeOnly2 && !spec.isTypeOnly ? 0 : ts_OrganizeImports_exports.getImportSpecifierInsertionIndex(existingSpecifiers, spec, comparer);
|
|
152589
|
+
const insertionIndex = promoteFromTypeOnly2 && !spec.isTypeOnly ? 0 : ts_OrganizeImports_exports.getImportSpecifierInsertionIndex(existingSpecifiers, spec, comparer, preferences);
|
|
152462
152590
|
changes.insertImportSpecifierAtIndex(sourceFile, spec, clause.namedBindings, insertionIndex);
|
|
152463
152591
|
}
|
|
152464
152592
|
} else if (existingSpecifiers == null ? void 0 : existingSpecifiers.length) {
|
|
@@ -160813,7 +160941,7 @@ function getCompletionData(program, log, sourceFile, compilerOptions, position,
|
|
|
160813
160941
|
return isIdentifier(e) ? e : isPropertyAccessExpression(e) ? getLeftMostName(e.expression) : void 0;
|
|
160814
160942
|
}
|
|
160815
160943
|
function tryGetGlobalSymbols() {
|
|
160816
|
-
const result = tryGetObjectTypeLiteralInTypeArgumentCompletionSymbols() || tryGetObjectLikeCompletionSymbols() || tryGetImportCompletionSymbols() || tryGetImportOrExportClauseCompletionSymbols() || tryGetLocalNamedExportCompletionSymbols() || tryGetConstructorCompletion() || tryGetClassLikeCompletionSymbols() || tryGetJsxCompletionSymbols() || (getGlobalCompletions(), 1 /* Success */);
|
|
160944
|
+
const result = tryGetObjectTypeLiteralInTypeArgumentCompletionSymbols() || tryGetObjectLikeCompletionSymbols() || tryGetImportCompletionSymbols() || tryGetImportOrExportClauseCompletionSymbols() || tryGetImportAttributesCompletionSymbols() || tryGetLocalNamedExportCompletionSymbols() || tryGetConstructorCompletion() || tryGetClassLikeCompletionSymbols() || tryGetJsxCompletionSymbols() || (getGlobalCompletions(), 1 /* Success */);
|
|
160817
160945
|
return result === 1 /* Success */;
|
|
160818
160946
|
}
|
|
160819
160947
|
function tryGetConstructorCompletion() {
|
|
@@ -161281,6 +161409,16 @@ function getCompletionData(program, log, sourceFile, compilerOptions, position,
|
|
|
161281
161409
|
}
|
|
161282
161410
|
return 1 /* Success */;
|
|
161283
161411
|
}
|
|
161412
|
+
function tryGetImportAttributesCompletionSymbols() {
|
|
161413
|
+
if (contextToken === void 0)
|
|
161414
|
+
return 0 /* Continue */;
|
|
161415
|
+
const importAttributes = contextToken.kind === 19 /* OpenBraceToken */ || contextToken.kind === 28 /* CommaToken */ ? tryCast(contextToken.parent, isImportAttributes) : contextToken.kind === 59 /* ColonToken */ ? tryCast(contextToken.parent.parent, isImportAttributes) : void 0;
|
|
161416
|
+
if (importAttributes === void 0)
|
|
161417
|
+
return 0 /* Continue */;
|
|
161418
|
+
const existing = new Set(importAttributes.elements.map(getNameFromImportAttribute));
|
|
161419
|
+
symbols = filter(typeChecker.getTypeAtLocation(importAttributes).getApparentProperties(), (attr) => !existing.has(attr.escapedName));
|
|
161420
|
+
return 1 /* Success */;
|
|
161421
|
+
}
|
|
161284
161422
|
function tryGetLocalNamedExportCompletionSymbols() {
|
|
161285
161423
|
var _a;
|
|
161286
161424
|
const namedExports = contextToken && (contextToken.kind === 19 /* OpenBraceToken */ || contextToken.kind === 28 /* CommaToken */) ? tryCast(contextToken.parent, isNamedExports) : void 0;
|
|
@@ -167323,14 +167461,14 @@ function organizeImports(sourceFile, formatContext, host, program, preferences,
|
|
|
167323
167461
|
if (shouldRemove)
|
|
167324
167462
|
importGroup = removeUnusedImports(importGroup, sourceFile, program);
|
|
167325
167463
|
if (shouldCombine)
|
|
167326
|
-
importGroup = coalesceImportsWorker(importGroup, comparer, sourceFile);
|
|
167464
|
+
importGroup = coalesceImportsWorker(importGroup, comparer, sourceFile, preferences);
|
|
167327
167465
|
if (shouldSort)
|
|
167328
167466
|
importGroup = stableSort(importGroup, (s1, s2) => compareImportsOrRequireStatements(s1, s2, comparer));
|
|
167329
167467
|
return importGroup;
|
|
167330
167468
|
};
|
|
167331
167469
|
topLevelImportGroupDecls.forEach((importGroupDecl) => organizeImportsWorker(importGroupDecl, processImportsOfSameModuleSpecifier));
|
|
167332
167470
|
if (mode !== "RemoveUnused" /* RemoveUnused */) {
|
|
167333
|
-
getTopLevelExportGroups(sourceFile).forEach((exportGroupDecl) => organizeImportsWorker(exportGroupDecl, (group2) => coalesceExportsWorker(group2, comparer)));
|
|
167471
|
+
getTopLevelExportGroups(sourceFile).forEach((exportGroupDecl) => organizeImportsWorker(exportGroupDecl, (group2) => coalesceExportsWorker(group2, comparer, preferences)));
|
|
167334
167472
|
}
|
|
167335
167473
|
for (const ambientModule of sourceFile.statements.filter(isAmbientModule)) {
|
|
167336
167474
|
if (!ambientModule.body)
|
|
@@ -167339,7 +167477,7 @@ function organizeImports(sourceFile, formatContext, host, program, preferences,
|
|
|
167339
167477
|
ambientModuleImportGroupDecls.forEach((importGroupDecl) => organizeImportsWorker(importGroupDecl, processImportsOfSameModuleSpecifier));
|
|
167340
167478
|
if (mode !== "RemoveUnused" /* RemoveUnused */) {
|
|
167341
167479
|
const ambientModuleExportDecls = ambientModule.body.statements.filter(isExportDeclaration);
|
|
167342
|
-
organizeImportsWorker(ambientModuleExportDecls, (group2) => coalesceExportsWorker(group2, comparer));
|
|
167480
|
+
organizeImportsWorker(ambientModuleExportDecls, (group2) => coalesceExportsWorker(group2, comparer, preferences));
|
|
167343
167481
|
}
|
|
167344
167482
|
}
|
|
167345
167483
|
return changeTracker.getChanges();
|
|
@@ -167471,11 +167609,11 @@ function hasModuleDeclarationMatchingSpecifier(sourceFile, moduleSpecifier) {
|
|
|
167471
167609
|
function getExternalModuleName2(specifier) {
|
|
167472
167610
|
return specifier !== void 0 && isStringLiteralLike(specifier) ? specifier.text : void 0;
|
|
167473
167611
|
}
|
|
167474
|
-
function coalesceImports(importGroup, ignoreCase, sourceFile) {
|
|
167612
|
+
function coalesceImports(importGroup, ignoreCase, sourceFile, preferences) {
|
|
167475
167613
|
const comparer = getOrganizeImportsOrdinalStringComparer(ignoreCase);
|
|
167476
|
-
return coalesceImportsWorker(importGroup, comparer, sourceFile);
|
|
167614
|
+
return coalesceImportsWorker(importGroup, comparer, sourceFile, preferences);
|
|
167477
167615
|
}
|
|
167478
|
-
function coalesceImportsWorker(importGroup, comparer, sourceFile) {
|
|
167616
|
+
function coalesceImportsWorker(importGroup, comparer, sourceFile, preferences) {
|
|
167479
167617
|
if (importGroup.length === 0) {
|
|
167480
167618
|
return importGroup;
|
|
167481
167619
|
}
|
|
@@ -167529,7 +167667,7 @@ function coalesceImportsWorker(importGroup, comparer, sourceFile) {
|
|
|
167529
167667
|
}
|
|
167530
167668
|
newImportSpecifiers.push(...getNewImportSpecifiers(namedImports));
|
|
167531
167669
|
const sortedImportSpecifiers = factory.createNodeArray(
|
|
167532
|
-
sortSpecifiers(newImportSpecifiers, comparer),
|
|
167670
|
+
sortSpecifiers(newImportSpecifiers, comparer, preferences),
|
|
167533
167671
|
firstNamedImport == null ? void 0 : firstNamedImport.importClause.namedBindings.elements.hasTrailingComma
|
|
167534
167672
|
);
|
|
167535
167673
|
const newNamedImports = sortedImportSpecifiers.length === 0 ? newDefaultImport ? void 0 : factory.createNamedImports(emptyArray) : firstNamedImport ? factory.updateNamedImports(firstNamedImport.importClause.namedBindings, sortedImportSpecifiers) : factory.createNamedImports(sortedImportSpecifiers);
|
|
@@ -167589,11 +167727,11 @@ function getCategorizedImports(importGroup) {
|
|
|
167589
167727
|
regularImports
|
|
167590
167728
|
};
|
|
167591
167729
|
}
|
|
167592
|
-
function coalesceExports(exportGroup, ignoreCase) {
|
|
167730
|
+
function coalesceExports(exportGroup, ignoreCase, preferences) {
|
|
167593
167731
|
const comparer = getOrganizeImportsOrdinalStringComparer(ignoreCase);
|
|
167594
|
-
return coalesceExportsWorker(exportGroup, comparer);
|
|
167732
|
+
return coalesceExportsWorker(exportGroup, comparer, preferences);
|
|
167595
167733
|
}
|
|
167596
|
-
function coalesceExportsWorker(exportGroup, comparer) {
|
|
167734
|
+
function coalesceExportsWorker(exportGroup, comparer, preferences) {
|
|
167597
167735
|
if (exportGroup.length === 0) {
|
|
167598
167736
|
return exportGroup;
|
|
167599
167737
|
}
|
|
@@ -167608,7 +167746,7 @@ function coalesceExportsWorker(exportGroup, comparer) {
|
|
|
167608
167746
|
}
|
|
167609
167747
|
const newExportSpecifiers = [];
|
|
167610
167748
|
newExportSpecifiers.push(...flatMap(exportGroup2, (i) => i.exportClause && isNamedExports(i.exportClause) ? i.exportClause.elements : emptyArray));
|
|
167611
|
-
const sortedExportSpecifiers = sortSpecifiers(newExportSpecifiers, comparer);
|
|
167749
|
+
const sortedExportSpecifiers = sortSpecifiers(newExportSpecifiers, comparer, preferences);
|
|
167612
167750
|
const exportDecl = exportGroup2[0];
|
|
167613
167751
|
coalescedExports.push(
|
|
167614
167752
|
factory.updateExportDeclaration(
|
|
@@ -167652,11 +167790,18 @@ function updateImportDeclarationAndClause(importDeclaration, name, namedBindings
|
|
|
167652
167790
|
importDeclaration.attributes
|
|
167653
167791
|
);
|
|
167654
167792
|
}
|
|
167655
|
-
function sortSpecifiers(specifiers, comparer) {
|
|
167656
|
-
return stableSort(specifiers, (s1, s2) => compareImportOrExportSpecifiers(s1, s2, comparer));
|
|
167793
|
+
function sortSpecifiers(specifiers, comparer, preferences) {
|
|
167794
|
+
return stableSort(specifiers, (s1, s2) => compareImportOrExportSpecifiers(s1, s2, comparer, preferences));
|
|
167657
167795
|
}
|
|
167658
|
-
function compareImportOrExportSpecifiers(s1, s2, comparer) {
|
|
167659
|
-
|
|
167796
|
+
function compareImportOrExportSpecifiers(s1, s2, comparer, preferences) {
|
|
167797
|
+
switch (preferences == null ? void 0 : preferences.organizeImportsTypeOrder) {
|
|
167798
|
+
case "first":
|
|
167799
|
+
return compareBooleans(s2.isTypeOnly, s1.isTypeOnly) || comparer(s1.name.text, s2.name.text);
|
|
167800
|
+
case "inline":
|
|
167801
|
+
return comparer(s1.name.text, s2.name.text);
|
|
167802
|
+
default:
|
|
167803
|
+
return compareBooleans(s1.isTypeOnly, s2.isTypeOnly) || comparer(s1.name.text, s2.name.text);
|
|
167804
|
+
}
|
|
167660
167805
|
}
|
|
167661
167806
|
function compareModuleSpecifiers2(m1, m2, ignoreCase) {
|
|
167662
167807
|
const comparer = getOrganizeImportsOrdinalStringComparer(!!ignoreCase);
|
|
@@ -167778,8 +167923,26 @@ var ImportSpecifierSortingCache = class {
|
|
|
167778
167923
|
}
|
|
167779
167924
|
};
|
|
167780
167925
|
var detectImportSpecifierSorting = memoizeCached((specifiers, preferences) => {
|
|
167781
|
-
|
|
167782
|
-
|
|
167926
|
+
switch (preferences.organizeImportsTypeOrder) {
|
|
167927
|
+
case "first":
|
|
167928
|
+
if (!arrayIsSorted(specifiers, (s1, s2) => compareBooleans(s2.isTypeOnly, s1.isTypeOnly)))
|
|
167929
|
+
return 0 /* None */;
|
|
167930
|
+
break;
|
|
167931
|
+
case "inline":
|
|
167932
|
+
if (!arrayIsSorted(specifiers, (s1, s2) => {
|
|
167933
|
+
const comparer = getStringComparer(
|
|
167934
|
+
/*ignoreCase*/
|
|
167935
|
+
true
|
|
167936
|
+
);
|
|
167937
|
+
return comparer(s1.name.text, s2.name.text);
|
|
167938
|
+
})) {
|
|
167939
|
+
return 0 /* None */;
|
|
167940
|
+
}
|
|
167941
|
+
break;
|
|
167942
|
+
default:
|
|
167943
|
+
if (!arrayIsSorted(specifiers, (s1, s2) => compareBooleans(s1.isTypeOnly, s2.isTypeOnly)))
|
|
167944
|
+
return 0 /* None */;
|
|
167945
|
+
break;
|
|
167783
167946
|
}
|
|
167784
167947
|
const collateCaseSensitive = getOrganizeImportsComparer(
|
|
167785
167948
|
preferences,
|
|
@@ -167791,14 +167954,29 @@ var detectImportSpecifierSorting = memoizeCached((specifiers, preferences) => {
|
|
|
167791
167954
|
/*ignoreCase*/
|
|
167792
167955
|
true
|
|
167793
167956
|
);
|
|
167957
|
+
if (preferences.organizeImportsTypeOrder !== "inline") {
|
|
167958
|
+
const { type: regularImports, regular: typeImports } = groupBy(specifiers, (s) => s.isTypeOnly ? "type" : "regular");
|
|
167959
|
+
const regularCaseSensitivity = (regularImports == null ? void 0 : regularImports.length) ? detectSortCaseSensitivity(regularImports, (specifier) => specifier.name.text, collateCaseSensitive, collateCaseInsensitive) : void 0;
|
|
167960
|
+
const typeCaseSensitivity = (typeImports == null ? void 0 : typeImports.length) ? detectSortCaseSensitivity(typeImports, (specifier) => specifier.name.text ?? "", collateCaseSensitive, collateCaseInsensitive) : void 0;
|
|
167961
|
+
if (regularCaseSensitivity === void 0) {
|
|
167962
|
+
return typeCaseSensitivity ?? 0 /* None */;
|
|
167963
|
+
}
|
|
167964
|
+
if (typeCaseSensitivity === void 0) {
|
|
167965
|
+
return regularCaseSensitivity;
|
|
167966
|
+
}
|
|
167967
|
+
if (regularCaseSensitivity === 0 /* None */ || typeCaseSensitivity === 0 /* None */) {
|
|
167968
|
+
return 0 /* None */;
|
|
167969
|
+
}
|
|
167970
|
+
return typeCaseSensitivity & regularCaseSensitivity;
|
|
167971
|
+
}
|
|
167794
167972
|
return detectSortCaseSensitivity(specifiers, (specifier) => specifier.name.text, collateCaseSensitive, collateCaseInsensitive);
|
|
167795
167973
|
}, new ImportSpecifierSortingCache());
|
|
167796
167974
|
function getImportDeclarationInsertionIndex(sortedImports, newImport, comparer) {
|
|
167797
167975
|
const index = binarySearch(sortedImports, newImport, identity, (a, b) => compareImportsOrRequireStatements(a, b, comparer));
|
|
167798
167976
|
return index < 0 ? ~index : index;
|
|
167799
167977
|
}
|
|
167800
|
-
function getImportSpecifierInsertionIndex(sortedImports, newImport, comparer) {
|
|
167801
|
-
const index = binarySearch(sortedImports, newImport, identity, (s1, s2) => compareImportOrExportSpecifiers(s1, s2, comparer));
|
|
167978
|
+
function getImportSpecifierInsertionIndex(sortedImports, newImport, comparer, preferences) {
|
|
167979
|
+
const index = binarySearch(sortedImports, newImport, identity, (s1, s2) => compareImportOrExportSpecifiers(s1, s2, comparer, preferences));
|
|
167802
167980
|
return index < 0 ? ~index : index;
|
|
167803
167981
|
}
|
|
167804
167982
|
function compareImportsOrRequireStatements(s1, s2, comparer) {
|
|
@@ -174787,6 +174965,7 @@ __export(ts_exports2, {
|
|
|
174787
174965
|
getModuleSpecifierEndingPreference: () => getModuleSpecifierEndingPreference,
|
|
174788
174966
|
getModuleSpecifierResolverHost: () => getModuleSpecifierResolverHost,
|
|
174789
174967
|
getNameForExportedSymbol: () => getNameForExportedSymbol,
|
|
174968
|
+
getNameFromImportAttribute: () => getNameFromImportAttribute,
|
|
174790
174969
|
getNameFromIndexInfo: () => getNameFromIndexInfo,
|
|
174791
174970
|
getNameFromPropertyName: () => getNameFromPropertyName,
|
|
174792
174971
|
getNameOfAccessExpression: () => getNameOfAccessExpression,
|
|
@@ -189587,6 +189766,7 @@ start(initializeNodeSystem(), require("os").platform());
|
|
|
189587
189766
|
getModuleSpecifierEndingPreference,
|
|
189588
189767
|
getModuleSpecifierResolverHost,
|
|
189589
189768
|
getNameForExportedSymbol,
|
|
189769
|
+
getNameFromImportAttribute,
|
|
189590
189770
|
getNameFromIndexInfo,
|
|
189591
189771
|
getNameFromPropertyName,
|
|
189592
189772
|
getNameOfAccessExpression,
|