typescript 5.4.0-dev.20240109 → 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/tsc.js +110 -44
- package/lib/tsserver.js +173 -67
- package/lib/typescript.d.ts +8 -0
- package/lib/typescript.js +173 -67
- package/lib/typingsInstaller.js +1 -1
- package/package.json +2 -2
package/lib/tsc.js
CHANGED
|
@@ -18,7 +18,7 @@ and limitations under the License.
|
|
|
18
18
|
|
|
19
19
|
// src/compiler/corePublic.ts
|
|
20
20
|
var versionMajorMinor = "5.4";
|
|
21
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
21
|
+
var version = `${versionMajorMinor}.0-dev.20240110`;
|
|
22
22
|
|
|
23
23
|
// src/compiler/core.ts
|
|
24
24
|
var emptyArray = [];
|
|
@@ -12673,7 +12673,7 @@ function isPartOfTypeNode(node) {
|
|
|
12673
12673
|
case 116 /* VoidKeyword */:
|
|
12674
12674
|
return node.parent.kind !== 222 /* VoidExpression */;
|
|
12675
12675
|
case 233 /* ExpressionWithTypeArguments */:
|
|
12676
|
-
return
|
|
12676
|
+
return isPartOfTypeExpressionWithTypeArguments(node);
|
|
12677
12677
|
case 168 /* TypeParameter */:
|
|
12678
12678
|
return node.parent.kind === 200 /* MappedType */ || node.parent.kind === 195 /* InferType */;
|
|
12679
12679
|
case 80 /* Identifier */:
|
|
@@ -12698,7 +12698,7 @@ function isPartOfTypeNode(node) {
|
|
|
12698
12698
|
}
|
|
12699
12699
|
switch (parent.kind) {
|
|
12700
12700
|
case 233 /* ExpressionWithTypeArguments */:
|
|
12701
|
-
return
|
|
12701
|
+
return isPartOfTypeExpressionWithTypeArguments(parent);
|
|
12702
12702
|
case 168 /* TypeParameter */:
|
|
12703
12703
|
return node === parent.constraint;
|
|
12704
12704
|
case 352 /* JSDocTemplateTag */:
|
|
@@ -12732,6 +12732,9 @@ function isPartOfTypeNode(node) {
|
|
|
12732
12732
|
}
|
|
12733
12733
|
return false;
|
|
12734
12734
|
}
|
|
12735
|
+
function isPartOfTypeExpressionWithTypeArguments(node) {
|
|
12736
|
+
return isJSDocImplementsTag(node.parent) || isJSDocAugmentsTag(node.parent) || isHeritageClause(node.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(node);
|
|
12737
|
+
}
|
|
12735
12738
|
function forEachReturnStatement(body, visitor) {
|
|
12736
12739
|
return traverse(body);
|
|
12737
12740
|
function traverse(node) {
|
|
@@ -44281,6 +44284,14 @@ function createTypeChecker(host) {
|
|
|
44281
44284
|
emptyArray,
|
|
44282
44285
|
emptyArray
|
|
44283
44286
|
);
|
|
44287
|
+
var resolvingApparentMappedType = createAnonymousType(
|
|
44288
|
+
/*symbol*/
|
|
44289
|
+
void 0,
|
|
44290
|
+
emptySymbols,
|
|
44291
|
+
emptyArray,
|
|
44292
|
+
emptyArray,
|
|
44293
|
+
emptyArray
|
|
44294
|
+
);
|
|
44284
44295
|
var markerSuperType = createTypeParameter();
|
|
44285
44296
|
var markerSubType = createTypeParameter();
|
|
44286
44297
|
markerSubType.constraint = markerSuperType;
|
|
@@ -47330,29 +47341,7 @@ function createTypeChecker(host) {
|
|
|
47330
47341
|
function getContainersOfSymbol(symbol, enclosingDeclaration, meaning) {
|
|
47331
47342
|
const container = getParentOfSymbol(symbol);
|
|
47332
47343
|
if (container && !(symbol.flags & 262144 /* TypeParameter */)) {
|
|
47333
|
-
|
|
47334
|
-
const reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration);
|
|
47335
|
-
const objectLiteralContainer = getVariableDeclarationOfObjectLiteral(container, meaning);
|
|
47336
|
-
if (enclosingDeclaration && container.flags & getQualifiedLeftMeaning(meaning) && getAccessibleSymbolChain(
|
|
47337
|
-
container,
|
|
47338
|
-
enclosingDeclaration,
|
|
47339
|
-
1920 /* Namespace */,
|
|
47340
|
-
/*useOnlyExternalAliasing*/
|
|
47341
|
-
false
|
|
47342
|
-
)) {
|
|
47343
|
-
return append(concatenate(concatenate([container], additionalContainers), reexportContainers), objectLiteralContainer);
|
|
47344
|
-
}
|
|
47345
|
-
const firstVariableMatch = !(container.flags & getQualifiedLeftMeaning(meaning)) && container.flags & 788968 /* Type */ && getDeclaredTypeOfSymbol(container).flags & 524288 /* Object */ && meaning === 111551 /* Value */ ? forEachSymbolTableInScope(enclosingDeclaration, (t) => {
|
|
47346
|
-
return forEachEntry(t, (s) => {
|
|
47347
|
-
if (s.flags & getQualifiedLeftMeaning(meaning) && getTypeOfSymbol(s) === getDeclaredTypeOfSymbol(container)) {
|
|
47348
|
-
return s;
|
|
47349
|
-
}
|
|
47350
|
-
});
|
|
47351
|
-
}) : void 0;
|
|
47352
|
-
let res = firstVariableMatch ? [firstVariableMatch, ...additionalContainers, container] : [...additionalContainers, container];
|
|
47353
|
-
res = append(res, objectLiteralContainer);
|
|
47354
|
-
res = addRange(res, reexportContainers);
|
|
47355
|
-
return res;
|
|
47344
|
+
return getWithAlternativeContainers(container);
|
|
47356
47345
|
}
|
|
47357
47346
|
const candidates = mapDefined(symbol.declarations, (d) => {
|
|
47358
47347
|
if (!isAmbientModule(d) && d.parent) {
|
|
@@ -47374,7 +47363,40 @@ function createTypeChecker(host) {
|
|
|
47374
47363
|
if (!length(candidates)) {
|
|
47375
47364
|
return void 0;
|
|
47376
47365
|
}
|
|
47377
|
-
|
|
47366
|
+
const containers = mapDefined(candidates, (candidate) => getAliasForSymbolInContainer(candidate, symbol) ? candidate : void 0);
|
|
47367
|
+
let bestContainers = [];
|
|
47368
|
+
let alternativeContainers = [];
|
|
47369
|
+
for (const container2 of containers) {
|
|
47370
|
+
const [bestMatch, ...rest] = getWithAlternativeContainers(container2);
|
|
47371
|
+
bestContainers = append(bestContainers, bestMatch);
|
|
47372
|
+
alternativeContainers = addRange(alternativeContainers, rest);
|
|
47373
|
+
}
|
|
47374
|
+
return concatenate(bestContainers, alternativeContainers);
|
|
47375
|
+
function getWithAlternativeContainers(container2) {
|
|
47376
|
+
const additionalContainers = mapDefined(container2.declarations, fileSymbolIfFileSymbolExportEqualsContainer);
|
|
47377
|
+
const reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration);
|
|
47378
|
+
const objectLiteralContainer = getVariableDeclarationOfObjectLiteral(container2, meaning);
|
|
47379
|
+
if (enclosingDeclaration && container2.flags & getQualifiedLeftMeaning(meaning) && getAccessibleSymbolChain(
|
|
47380
|
+
container2,
|
|
47381
|
+
enclosingDeclaration,
|
|
47382
|
+
1920 /* Namespace */,
|
|
47383
|
+
/*useOnlyExternalAliasing*/
|
|
47384
|
+
false
|
|
47385
|
+
)) {
|
|
47386
|
+
return append(concatenate(concatenate([container2], additionalContainers), reexportContainers), objectLiteralContainer);
|
|
47387
|
+
}
|
|
47388
|
+
const firstVariableMatch = !(container2.flags & getQualifiedLeftMeaning(meaning)) && container2.flags & 788968 /* Type */ && getDeclaredTypeOfSymbol(container2).flags & 524288 /* Object */ && meaning === 111551 /* Value */ ? forEachSymbolTableInScope(enclosingDeclaration, (t) => {
|
|
47389
|
+
return forEachEntry(t, (s) => {
|
|
47390
|
+
if (s.flags & getQualifiedLeftMeaning(meaning) && getTypeOfSymbol(s) === getDeclaredTypeOfSymbol(container2)) {
|
|
47391
|
+
return s;
|
|
47392
|
+
}
|
|
47393
|
+
});
|
|
47394
|
+
}) : void 0;
|
|
47395
|
+
let res = firstVariableMatch ? [firstVariableMatch, ...additionalContainers, container2] : [...additionalContainers, container2];
|
|
47396
|
+
res = append(res, objectLiteralContainer);
|
|
47397
|
+
res = addRange(res, reexportContainers);
|
|
47398
|
+
return res;
|
|
47399
|
+
}
|
|
47378
47400
|
function fileSymbolIfFileSymbolExportEqualsContainer(d) {
|
|
47379
47401
|
return container && getFileSymbolIfFileSymbolExportEqualsContainer(d, container);
|
|
47380
47402
|
}
|
|
@@ -47412,6 +47434,13 @@ function createTypeChecker(host) {
|
|
|
47412
47434
|
});
|
|
47413
47435
|
}
|
|
47414
47436
|
function getSymbolIfSameReference(s1, s2) {
|
|
47437
|
+
var _a, _b;
|
|
47438
|
+
if (s1.flags & 524288 /* TypeAlias */ && ((_a = s2.declarations) == null ? void 0 : _a.find(isTypeAlias))) {
|
|
47439
|
+
s2 = getDeclaredTypeOfTypeAlias(s2).aliasSymbol || s2;
|
|
47440
|
+
}
|
|
47441
|
+
if (s2.flags & 524288 /* TypeAlias */ && ((_b = s1.declarations) == null ? void 0 : _b.find(isTypeAlias))) {
|
|
47442
|
+
s1 = getDeclaredTypeOfTypeAlias(s1).aliasSymbol || s1;
|
|
47443
|
+
}
|
|
47415
47444
|
if (getMergedSymbol(resolveSymbol(getMergedSymbol(s1))) === getMergedSymbol(resolveSymbol(getMergedSymbol(s2)))) {
|
|
47416
47445
|
return s1;
|
|
47417
47446
|
}
|
|
@@ -55150,14 +55179,30 @@ function createTypeChecker(host) {
|
|
|
55150
55179
|
return !!(typeParameter.symbol && forEach(typeParameter.symbol.declarations, (decl) => isTypeParameterDeclaration(decl) && decl.default));
|
|
55151
55180
|
}
|
|
55152
55181
|
function getApparentTypeOfMappedType(type) {
|
|
55153
|
-
|
|
55182
|
+
if (type.resolvedApparentType) {
|
|
55183
|
+
if (type.resolvedApparentType === resolvingApparentMappedType) {
|
|
55184
|
+
return type.resolvedApparentType = type;
|
|
55185
|
+
}
|
|
55186
|
+
return type.resolvedApparentType;
|
|
55187
|
+
}
|
|
55188
|
+
type.resolvedApparentType = resolvingApparentMappedType;
|
|
55189
|
+
return type.resolvedApparentType = getResolvedApparentTypeOfMappedType(type);
|
|
55154
55190
|
}
|
|
55155
55191
|
function getResolvedApparentTypeOfMappedType(type) {
|
|
55156
|
-
const
|
|
55157
|
-
|
|
55158
|
-
|
|
55192
|
+
const mappedType = type.target || type;
|
|
55193
|
+
const typeVariable = getHomomorphicTypeVariable(mappedType);
|
|
55194
|
+
if (typeVariable && !mappedType.declaration.nameType) {
|
|
55195
|
+
let constraint;
|
|
55196
|
+
if (!type.target) {
|
|
55197
|
+
constraint = getConstraintOfTypeParameter(typeVariable);
|
|
55198
|
+
} else {
|
|
55199
|
+
const modifiersConstraint = getConstraintOfType(getModifiersTypeFromMappedType(type));
|
|
55200
|
+
if (modifiersConstraint) {
|
|
55201
|
+
constraint = getApparentType(modifiersConstraint);
|
|
55202
|
+
}
|
|
55203
|
+
}
|
|
55159
55204
|
if (constraint && everyType(constraint, isArrayOrTupleType)) {
|
|
55160
|
-
return instantiateType(
|
|
55205
|
+
return instantiateType(mappedType, prependTypeMapping(typeVariable, constraint, mappedType.mapper));
|
|
55161
55206
|
}
|
|
55162
55207
|
}
|
|
55163
55208
|
return type;
|
|
@@ -55248,6 +55293,7 @@ function createTypeChecker(host) {
|
|
|
55248
55293
|
clone2.parent = (_c = (_b = singleProp.valueDeclaration) == null ? void 0 : _b.symbol) == null ? void 0 : _c.parent;
|
|
55249
55294
|
clone2.links.containingType = containingType;
|
|
55250
55295
|
clone2.links.mapper = links == null ? void 0 : links.mapper;
|
|
55296
|
+
clone2.links.writeType = getWriteTypeOfSymbol(singleProp);
|
|
55251
55297
|
return clone2;
|
|
55252
55298
|
} else {
|
|
55253
55299
|
return singleProp;
|
|
@@ -61873,6 +61919,18 @@ function createTypeChecker(host) {
|
|
|
61873
61919
|
}
|
|
61874
61920
|
return result2;
|
|
61875
61921
|
}
|
|
61922
|
+
function getApparentMappedTypeKeys(nameType, targetType) {
|
|
61923
|
+
const modifiersType = getApparentType(getModifiersTypeFromMappedType(targetType));
|
|
61924
|
+
const mappedKeys = [];
|
|
61925
|
+
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(
|
|
61926
|
+
modifiersType,
|
|
61927
|
+
8576 /* StringOrNumberLiteralOrUnique */,
|
|
61928
|
+
/*stringsOnly*/
|
|
61929
|
+
false,
|
|
61930
|
+
(t) => void mappedKeys.push(instantiateType(nameType, appendTypeMapping(targetType.mapper, getTypeParameterFromMappedType(targetType), t)))
|
|
61931
|
+
);
|
|
61932
|
+
return getUnionType(mappedKeys);
|
|
61933
|
+
}
|
|
61876
61934
|
function structuredTypeRelatedToWorker(source2, target2, reportErrors2, intersectionState, saveErrorInfo) {
|
|
61877
61935
|
let result2;
|
|
61878
61936
|
let originalErrorInfo;
|
|
@@ -62055,16 +62113,8 @@ function createTypeChecker(host) {
|
|
|
62055
62113
|
const constraintType = getConstraintTypeFromMappedType(targetType);
|
|
62056
62114
|
let targetKeys;
|
|
62057
62115
|
if (nameType && isMappedTypeWithKeyofConstraintDeclaration(targetType)) {
|
|
62058
|
-
const
|
|
62059
|
-
|
|
62060
|
-
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(
|
|
62061
|
-
modifiersType,
|
|
62062
|
-
8576 /* StringOrNumberLiteralOrUnique */,
|
|
62063
|
-
/*stringsOnly*/
|
|
62064
|
-
false,
|
|
62065
|
-
(t) => void mappedKeys.push(instantiateType(nameType, appendTypeMapping(targetType.mapper, getTypeParameterFromMappedType(targetType), t)))
|
|
62066
|
-
);
|
|
62067
|
-
targetKeys = getUnionType([...mappedKeys, nameType]);
|
|
62116
|
+
const mappedKeys = getApparentMappedTypeKeys(nameType, targetType);
|
|
62117
|
+
targetKeys = getUnionType([mappedKeys, nameType]);
|
|
62068
62118
|
} else {
|
|
62069
62119
|
targetKeys = nameType || constraintType;
|
|
62070
62120
|
}
|
|
@@ -62235,9 +62285,18 @@ function createTypeChecker(host) {
|
|
|
62235
62285
|
}
|
|
62236
62286
|
}
|
|
62237
62287
|
} else if (sourceFlags & 4194304 /* Index */) {
|
|
62238
|
-
|
|
62288
|
+
const isDeferredMappedIndex = shouldDeferIndexType(source2.type, source2.indexFlags) && getObjectFlags(source2.type) & 32 /* Mapped */;
|
|
62289
|
+
if (result2 = isRelatedTo(keyofConstraintType, target2, 1 /* Source */, reportErrors2 && !isDeferredMappedIndex)) {
|
|
62239
62290
|
return result2;
|
|
62240
62291
|
}
|
|
62292
|
+
if (isDeferredMappedIndex) {
|
|
62293
|
+
const mappedType = source2.type;
|
|
62294
|
+
const nameType = getNameTypeFromMappedType(mappedType);
|
|
62295
|
+
const sourceMappedKeys = nameType && isMappedTypeWithKeyofConstraintDeclaration(mappedType) ? getApparentMappedTypeKeys(nameType, mappedType) : nameType || getConstraintTypeFromMappedType(mappedType);
|
|
62296
|
+
if (result2 = isRelatedTo(sourceMappedKeys, target2, 1 /* Source */, reportErrors2)) {
|
|
62297
|
+
return result2;
|
|
62298
|
+
}
|
|
62299
|
+
}
|
|
62241
62300
|
} else if (sourceFlags & 134217728 /* TemplateLiteral */ && !(targetFlags & 524288 /* Object */)) {
|
|
62242
62301
|
if (!(targetFlags & 134217728 /* TemplateLiteral */)) {
|
|
62243
62302
|
const constraint = getBaseConstraintOfType(source2);
|
|
@@ -113477,7 +113536,14 @@ function createPrinter(printerOptions = {}, handlers = {}) {
|
|
|
113477
113536
|
function willEmitLeadingNewLine(node) {
|
|
113478
113537
|
if (!currentSourceFile)
|
|
113479
113538
|
return false;
|
|
113480
|
-
|
|
113539
|
+
const leadingCommentRanges = getLeadingCommentRanges(currentSourceFile.text, node.pos);
|
|
113540
|
+
if (leadingCommentRanges) {
|
|
113541
|
+
const parseNode = getParseTreeNode(node);
|
|
113542
|
+
if (parseNode && isParenthesizedExpression(parseNode.parent)) {
|
|
113543
|
+
return true;
|
|
113544
|
+
}
|
|
113545
|
+
}
|
|
113546
|
+
if (some(leadingCommentRanges, commentWillEmitNewLine))
|
|
113481
113547
|
return true;
|
|
113482
113548
|
if (some(getSyntheticLeadingComments(node), commentWillEmitNewLine))
|
|
113483
113549
|
return true;
|
package/lib/tsserver.js
CHANGED
|
@@ -2340,7 +2340,7 @@ module.exports = __toCommonJS(server_exports);
|
|
|
2340
2340
|
|
|
2341
2341
|
// src/compiler/corePublic.ts
|
|
2342
2342
|
var versionMajorMinor = "5.4";
|
|
2343
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
2343
|
+
var version = `${versionMajorMinor}.0-dev.20240110`;
|
|
2344
2344
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2345
2345
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2346
2346
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -16546,7 +16546,7 @@ function isPartOfTypeNode(node) {
|
|
|
16546
16546
|
case 116 /* VoidKeyword */:
|
|
16547
16547
|
return node.parent.kind !== 222 /* VoidExpression */;
|
|
16548
16548
|
case 233 /* ExpressionWithTypeArguments */:
|
|
16549
|
-
return
|
|
16549
|
+
return isPartOfTypeExpressionWithTypeArguments(node);
|
|
16550
16550
|
case 168 /* TypeParameter */:
|
|
16551
16551
|
return node.parent.kind === 200 /* MappedType */ || node.parent.kind === 195 /* InferType */;
|
|
16552
16552
|
case 80 /* Identifier */:
|
|
@@ -16571,7 +16571,7 @@ function isPartOfTypeNode(node) {
|
|
|
16571
16571
|
}
|
|
16572
16572
|
switch (parent2.kind) {
|
|
16573
16573
|
case 233 /* ExpressionWithTypeArguments */:
|
|
16574
|
-
return
|
|
16574
|
+
return isPartOfTypeExpressionWithTypeArguments(parent2);
|
|
16575
16575
|
case 168 /* TypeParameter */:
|
|
16576
16576
|
return node === parent2.constraint;
|
|
16577
16577
|
case 352 /* JSDocTemplateTag */:
|
|
@@ -16605,6 +16605,9 @@ function isPartOfTypeNode(node) {
|
|
|
16605
16605
|
}
|
|
16606
16606
|
return false;
|
|
16607
16607
|
}
|
|
16608
|
+
function isPartOfTypeExpressionWithTypeArguments(node) {
|
|
16609
|
+
return isJSDocImplementsTag(node.parent) || isJSDocAugmentsTag(node.parent) || isHeritageClause(node.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(node);
|
|
16610
|
+
}
|
|
16608
16611
|
function isChildOfNodeWithKind(node, kind) {
|
|
16609
16612
|
while (node) {
|
|
16610
16613
|
if (node.kind === kind) {
|
|
@@ -49019,6 +49022,14 @@ function createTypeChecker(host) {
|
|
|
49019
49022
|
emptyArray,
|
|
49020
49023
|
emptyArray
|
|
49021
49024
|
);
|
|
49025
|
+
var resolvingApparentMappedType = createAnonymousType(
|
|
49026
|
+
/*symbol*/
|
|
49027
|
+
void 0,
|
|
49028
|
+
emptySymbols,
|
|
49029
|
+
emptyArray,
|
|
49030
|
+
emptyArray,
|
|
49031
|
+
emptyArray
|
|
49032
|
+
);
|
|
49022
49033
|
var markerSuperType = createTypeParameter();
|
|
49023
49034
|
var markerSubType = createTypeParameter();
|
|
49024
49035
|
markerSubType.constraint = markerSuperType;
|
|
@@ -52068,29 +52079,7 @@ function createTypeChecker(host) {
|
|
|
52068
52079
|
function getContainersOfSymbol(symbol, enclosingDeclaration, meaning) {
|
|
52069
52080
|
const container = getParentOfSymbol(symbol);
|
|
52070
52081
|
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;
|
|
52082
|
+
return getWithAlternativeContainers(container);
|
|
52094
52083
|
}
|
|
52095
52084
|
const candidates = mapDefined(symbol.declarations, (d) => {
|
|
52096
52085
|
if (!isAmbientModule(d) && d.parent) {
|
|
@@ -52112,7 +52101,40 @@ function createTypeChecker(host) {
|
|
|
52112
52101
|
if (!length(candidates)) {
|
|
52113
52102
|
return void 0;
|
|
52114
52103
|
}
|
|
52115
|
-
|
|
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
|
+
}
|
|
52116
52138
|
function fileSymbolIfFileSymbolExportEqualsContainer(d) {
|
|
52117
52139
|
return container && getFileSymbolIfFileSymbolExportEqualsContainer(d, container);
|
|
52118
52140
|
}
|
|
@@ -52150,6 +52172,13 @@ function createTypeChecker(host) {
|
|
|
52150
52172
|
});
|
|
52151
52173
|
}
|
|
52152
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
|
+
}
|
|
52153
52182
|
if (getMergedSymbol(resolveSymbol(getMergedSymbol(s1))) === getMergedSymbol(resolveSymbol(getMergedSymbol(s2)))) {
|
|
52154
52183
|
return s1;
|
|
52155
52184
|
}
|
|
@@ -59888,14 +59917,30 @@ function createTypeChecker(host) {
|
|
|
59888
59917
|
return !!(typeParameter.symbol && forEach(typeParameter.symbol.declarations, (decl) => isTypeParameterDeclaration(decl) && decl.default));
|
|
59889
59918
|
}
|
|
59890
59919
|
function getApparentTypeOfMappedType(type) {
|
|
59891
|
-
|
|
59920
|
+
if (type.resolvedApparentType) {
|
|
59921
|
+
if (type.resolvedApparentType === resolvingApparentMappedType) {
|
|
59922
|
+
return type.resolvedApparentType = type;
|
|
59923
|
+
}
|
|
59924
|
+
return type.resolvedApparentType;
|
|
59925
|
+
}
|
|
59926
|
+
type.resolvedApparentType = resolvingApparentMappedType;
|
|
59927
|
+
return type.resolvedApparentType = getResolvedApparentTypeOfMappedType(type);
|
|
59892
59928
|
}
|
|
59893
59929
|
function getResolvedApparentTypeOfMappedType(type) {
|
|
59894
|
-
const
|
|
59895
|
-
|
|
59896
|
-
|
|
59930
|
+
const mappedType = type.target || type;
|
|
59931
|
+
const typeVariable = getHomomorphicTypeVariable(mappedType);
|
|
59932
|
+
if (typeVariable && !mappedType.declaration.nameType) {
|
|
59933
|
+
let constraint;
|
|
59934
|
+
if (!type.target) {
|
|
59935
|
+
constraint = getConstraintOfTypeParameter(typeVariable);
|
|
59936
|
+
} else {
|
|
59937
|
+
const modifiersConstraint = getConstraintOfType(getModifiersTypeFromMappedType(type));
|
|
59938
|
+
if (modifiersConstraint) {
|
|
59939
|
+
constraint = getApparentType(modifiersConstraint);
|
|
59940
|
+
}
|
|
59941
|
+
}
|
|
59897
59942
|
if (constraint && everyType(constraint, isArrayOrTupleType)) {
|
|
59898
|
-
return instantiateType(
|
|
59943
|
+
return instantiateType(mappedType, prependTypeMapping(typeVariable, constraint, mappedType.mapper));
|
|
59899
59944
|
}
|
|
59900
59945
|
}
|
|
59901
59946
|
return type;
|
|
@@ -59986,6 +60031,7 @@ function createTypeChecker(host) {
|
|
|
59986
60031
|
clone2.parent = (_c = (_b = singleProp.valueDeclaration) == null ? void 0 : _b.symbol) == null ? void 0 : _c.parent;
|
|
59987
60032
|
clone2.links.containingType = containingType;
|
|
59988
60033
|
clone2.links.mapper = links == null ? void 0 : links.mapper;
|
|
60034
|
+
clone2.links.writeType = getWriteTypeOfSymbol(singleProp);
|
|
59989
60035
|
return clone2;
|
|
59990
60036
|
} else {
|
|
59991
60037
|
return singleProp;
|
|
@@ -66611,6 +66657,18 @@ function createTypeChecker(host) {
|
|
|
66611
66657
|
}
|
|
66612
66658
|
return result2;
|
|
66613
66659
|
}
|
|
66660
|
+
function getApparentMappedTypeKeys(nameType, targetType) {
|
|
66661
|
+
const modifiersType = getApparentType(getModifiersTypeFromMappedType(targetType));
|
|
66662
|
+
const mappedKeys = [];
|
|
66663
|
+
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(
|
|
66664
|
+
modifiersType,
|
|
66665
|
+
8576 /* StringOrNumberLiteralOrUnique */,
|
|
66666
|
+
/*stringsOnly*/
|
|
66667
|
+
false,
|
|
66668
|
+
(t) => void mappedKeys.push(instantiateType(nameType, appendTypeMapping(targetType.mapper, getTypeParameterFromMappedType(targetType), t)))
|
|
66669
|
+
);
|
|
66670
|
+
return getUnionType(mappedKeys);
|
|
66671
|
+
}
|
|
66614
66672
|
function structuredTypeRelatedToWorker(source2, target2, reportErrors2, intersectionState, saveErrorInfo) {
|
|
66615
66673
|
let result2;
|
|
66616
66674
|
let originalErrorInfo;
|
|
@@ -66793,16 +66851,8 @@ function createTypeChecker(host) {
|
|
|
66793
66851
|
const constraintType = getConstraintTypeFromMappedType(targetType);
|
|
66794
66852
|
let targetKeys;
|
|
66795
66853
|
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]);
|
|
66854
|
+
const mappedKeys = getApparentMappedTypeKeys(nameType, targetType);
|
|
66855
|
+
targetKeys = getUnionType([mappedKeys, nameType]);
|
|
66806
66856
|
} else {
|
|
66807
66857
|
targetKeys = nameType || constraintType;
|
|
66808
66858
|
}
|
|
@@ -66973,9 +67023,18 @@ function createTypeChecker(host) {
|
|
|
66973
67023
|
}
|
|
66974
67024
|
}
|
|
66975
67025
|
} else if (sourceFlags & 4194304 /* Index */) {
|
|
66976
|
-
|
|
67026
|
+
const isDeferredMappedIndex = shouldDeferIndexType(source2.type, source2.indexFlags) && getObjectFlags(source2.type) & 32 /* Mapped */;
|
|
67027
|
+
if (result2 = isRelatedTo(keyofConstraintType, target2, 1 /* Source */, reportErrors2 && !isDeferredMappedIndex)) {
|
|
66977
67028
|
return result2;
|
|
66978
67029
|
}
|
|
67030
|
+
if (isDeferredMappedIndex) {
|
|
67031
|
+
const mappedType = source2.type;
|
|
67032
|
+
const nameType = getNameTypeFromMappedType(mappedType);
|
|
67033
|
+
const sourceMappedKeys = nameType && isMappedTypeWithKeyofConstraintDeclaration(mappedType) ? getApparentMappedTypeKeys(nameType, mappedType) : nameType || getConstraintTypeFromMappedType(mappedType);
|
|
67034
|
+
if (result2 = isRelatedTo(sourceMappedKeys, target2, 1 /* Source */, reportErrors2)) {
|
|
67035
|
+
return result2;
|
|
67036
|
+
}
|
|
67037
|
+
}
|
|
66979
67038
|
} else if (sourceFlags & 134217728 /* TemplateLiteral */ && !(targetFlags & 524288 /* Object */)) {
|
|
66980
67039
|
if (!(targetFlags & 134217728 /* TemplateLiteral */)) {
|
|
66981
67040
|
const constraint = getBaseConstraintOfType(source2);
|
|
@@ -118397,7 +118456,14 @@ function createPrinter(printerOptions = {}, handlers = {}) {
|
|
|
118397
118456
|
function willEmitLeadingNewLine(node) {
|
|
118398
118457
|
if (!currentSourceFile)
|
|
118399
118458
|
return false;
|
|
118400
|
-
|
|
118459
|
+
const leadingCommentRanges = getLeadingCommentRanges(currentSourceFile.text, node.pos);
|
|
118460
|
+
if (leadingCommentRanges) {
|
|
118461
|
+
const parseNode = getParseTreeNode(node);
|
|
118462
|
+
if (parseNode && isParenthesizedExpression(parseNode.parent)) {
|
|
118463
|
+
return true;
|
|
118464
|
+
}
|
|
118465
|
+
}
|
|
118466
|
+
if (some(leadingCommentRanges, commentWillEmitNewLine))
|
|
118401
118467
|
return true;
|
|
118402
118468
|
if (some(getSyntheticLeadingComments(node), commentWillEmitNewLine))
|
|
118403
118469
|
return true;
|
|
@@ -152355,14 +152421,14 @@ function promoteFromTypeOnly(changes, aliasDeclaration, program, sourceFile, pre
|
|
|
152355
152421
|
aliasDeclaration.name
|
|
152356
152422
|
);
|
|
152357
152423
|
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)
|
|
152424
|
+
const insertionIndex = ts_OrganizeImports_exports.getImportSpecifierInsertionIndex(aliasDeclaration.parent.elements, newSpecifier, comparer, preferences);
|
|
152425
|
+
if (insertionIndex !== aliasDeclaration.parent.elements.indexOf(aliasDeclaration)) {
|
|
152360
152426
|
changes.delete(sourceFile, aliasDeclaration);
|
|
152361
152427
|
changes.insertImportSpecifierAtIndex(sourceFile, newSpecifier, aliasDeclaration.parent, insertionIndex);
|
|
152362
152428
|
return aliasDeclaration;
|
|
152363
152429
|
}
|
|
152364
152430
|
}
|
|
152365
|
-
changes.deleteRange(sourceFile, aliasDeclaration.getFirstToken());
|
|
152431
|
+
changes.deleteRange(sourceFile, { pos: getTokenPosOfNode(aliasDeclaration.getFirstToken()), end: getTokenPosOfNode(aliasDeclaration.propertyName ?? aliasDeclaration.name) });
|
|
152366
152432
|
return aliasDeclaration;
|
|
152367
152433
|
} else {
|
|
152368
152434
|
Debug.assert(aliasDeclaration.parent.parent.isTypeOnly);
|
|
@@ -152458,7 +152524,7 @@ function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImpor
|
|
|
152458
152524
|
const specifierSort = (existingSpecifiers == null ? void 0 : existingSpecifiers.length) && ts_OrganizeImports_exports.detectImportSpecifierSorting(existingSpecifiers, preferences);
|
|
152459
152525
|
if (specifierSort && !(ignoreCaseForSorting && specifierSort === 1 /* CaseSensitive */)) {
|
|
152460
152526
|
for (const spec of newSpecifiers) {
|
|
152461
|
-
const insertionIndex = promoteFromTypeOnly2 && !spec.isTypeOnly ? 0 : ts_OrganizeImports_exports.getImportSpecifierInsertionIndex(existingSpecifiers, spec, comparer);
|
|
152527
|
+
const insertionIndex = promoteFromTypeOnly2 && !spec.isTypeOnly ? 0 : ts_OrganizeImports_exports.getImportSpecifierInsertionIndex(existingSpecifiers, spec, comparer, preferences);
|
|
152462
152528
|
changes.insertImportSpecifierAtIndex(sourceFile, spec, clause.namedBindings, insertionIndex);
|
|
152463
152529
|
}
|
|
152464
152530
|
} else if (existingSpecifiers == null ? void 0 : existingSpecifiers.length) {
|
|
@@ -167323,14 +167389,14 @@ function organizeImports(sourceFile, formatContext, host, program, preferences,
|
|
|
167323
167389
|
if (shouldRemove)
|
|
167324
167390
|
importGroup = removeUnusedImports(importGroup, sourceFile, program);
|
|
167325
167391
|
if (shouldCombine)
|
|
167326
|
-
importGroup = coalesceImportsWorker(importGroup, comparer, sourceFile);
|
|
167392
|
+
importGroup = coalesceImportsWorker(importGroup, comparer, sourceFile, preferences);
|
|
167327
167393
|
if (shouldSort)
|
|
167328
167394
|
importGroup = stableSort(importGroup, (s1, s2) => compareImportsOrRequireStatements(s1, s2, comparer));
|
|
167329
167395
|
return importGroup;
|
|
167330
167396
|
};
|
|
167331
167397
|
topLevelImportGroupDecls.forEach((importGroupDecl) => organizeImportsWorker(importGroupDecl, processImportsOfSameModuleSpecifier));
|
|
167332
167398
|
if (mode !== "RemoveUnused" /* RemoveUnused */) {
|
|
167333
|
-
getTopLevelExportGroups(sourceFile).forEach((exportGroupDecl) => organizeImportsWorker(exportGroupDecl, (group2) => coalesceExportsWorker(group2, comparer)));
|
|
167399
|
+
getTopLevelExportGroups(sourceFile).forEach((exportGroupDecl) => organizeImportsWorker(exportGroupDecl, (group2) => coalesceExportsWorker(group2, comparer, preferences)));
|
|
167334
167400
|
}
|
|
167335
167401
|
for (const ambientModule of sourceFile.statements.filter(isAmbientModule)) {
|
|
167336
167402
|
if (!ambientModule.body)
|
|
@@ -167339,7 +167405,7 @@ function organizeImports(sourceFile, formatContext, host, program, preferences,
|
|
|
167339
167405
|
ambientModuleImportGroupDecls.forEach((importGroupDecl) => organizeImportsWorker(importGroupDecl, processImportsOfSameModuleSpecifier));
|
|
167340
167406
|
if (mode !== "RemoveUnused" /* RemoveUnused */) {
|
|
167341
167407
|
const ambientModuleExportDecls = ambientModule.body.statements.filter(isExportDeclaration);
|
|
167342
|
-
organizeImportsWorker(ambientModuleExportDecls, (group2) => coalesceExportsWorker(group2, comparer));
|
|
167408
|
+
organizeImportsWorker(ambientModuleExportDecls, (group2) => coalesceExportsWorker(group2, comparer, preferences));
|
|
167343
167409
|
}
|
|
167344
167410
|
}
|
|
167345
167411
|
return changeTracker.getChanges();
|
|
@@ -167471,11 +167537,11 @@ function hasModuleDeclarationMatchingSpecifier(sourceFile, moduleSpecifier) {
|
|
|
167471
167537
|
function getExternalModuleName2(specifier) {
|
|
167472
167538
|
return specifier !== void 0 && isStringLiteralLike(specifier) ? specifier.text : void 0;
|
|
167473
167539
|
}
|
|
167474
|
-
function coalesceImports(importGroup, ignoreCase, sourceFile) {
|
|
167540
|
+
function coalesceImports(importGroup, ignoreCase, sourceFile, preferences) {
|
|
167475
167541
|
const comparer = getOrganizeImportsOrdinalStringComparer(ignoreCase);
|
|
167476
|
-
return coalesceImportsWorker(importGroup, comparer, sourceFile);
|
|
167542
|
+
return coalesceImportsWorker(importGroup, comparer, sourceFile, preferences);
|
|
167477
167543
|
}
|
|
167478
|
-
function coalesceImportsWorker(importGroup, comparer, sourceFile) {
|
|
167544
|
+
function coalesceImportsWorker(importGroup, comparer, sourceFile, preferences) {
|
|
167479
167545
|
if (importGroup.length === 0) {
|
|
167480
167546
|
return importGroup;
|
|
167481
167547
|
}
|
|
@@ -167529,7 +167595,7 @@ function coalesceImportsWorker(importGroup, comparer, sourceFile) {
|
|
|
167529
167595
|
}
|
|
167530
167596
|
newImportSpecifiers.push(...getNewImportSpecifiers(namedImports));
|
|
167531
167597
|
const sortedImportSpecifiers = factory.createNodeArray(
|
|
167532
|
-
sortSpecifiers(newImportSpecifiers, comparer),
|
|
167598
|
+
sortSpecifiers(newImportSpecifiers, comparer, preferences),
|
|
167533
167599
|
firstNamedImport == null ? void 0 : firstNamedImport.importClause.namedBindings.elements.hasTrailingComma
|
|
167534
167600
|
);
|
|
167535
167601
|
const newNamedImports = sortedImportSpecifiers.length === 0 ? newDefaultImport ? void 0 : factory.createNamedImports(emptyArray) : firstNamedImport ? factory.updateNamedImports(firstNamedImport.importClause.namedBindings, sortedImportSpecifiers) : factory.createNamedImports(sortedImportSpecifiers);
|
|
@@ -167589,11 +167655,11 @@ function getCategorizedImports(importGroup) {
|
|
|
167589
167655
|
regularImports
|
|
167590
167656
|
};
|
|
167591
167657
|
}
|
|
167592
|
-
function coalesceExports(exportGroup, ignoreCase) {
|
|
167658
|
+
function coalesceExports(exportGroup, ignoreCase, preferences) {
|
|
167593
167659
|
const comparer = getOrganizeImportsOrdinalStringComparer(ignoreCase);
|
|
167594
|
-
return coalesceExportsWorker(exportGroup, comparer);
|
|
167660
|
+
return coalesceExportsWorker(exportGroup, comparer, preferences);
|
|
167595
167661
|
}
|
|
167596
|
-
function coalesceExportsWorker(exportGroup, comparer) {
|
|
167662
|
+
function coalesceExportsWorker(exportGroup, comparer, preferences) {
|
|
167597
167663
|
if (exportGroup.length === 0) {
|
|
167598
167664
|
return exportGroup;
|
|
167599
167665
|
}
|
|
@@ -167608,7 +167674,7 @@ function coalesceExportsWorker(exportGroup, comparer) {
|
|
|
167608
167674
|
}
|
|
167609
167675
|
const newExportSpecifiers = [];
|
|
167610
167676
|
newExportSpecifiers.push(...flatMap(exportGroup2, (i) => i.exportClause && isNamedExports(i.exportClause) ? i.exportClause.elements : emptyArray));
|
|
167611
|
-
const sortedExportSpecifiers = sortSpecifiers(newExportSpecifiers, comparer);
|
|
167677
|
+
const sortedExportSpecifiers = sortSpecifiers(newExportSpecifiers, comparer, preferences);
|
|
167612
167678
|
const exportDecl = exportGroup2[0];
|
|
167613
167679
|
coalescedExports.push(
|
|
167614
167680
|
factory.updateExportDeclaration(
|
|
@@ -167652,11 +167718,18 @@ function updateImportDeclarationAndClause(importDeclaration, name, namedBindings
|
|
|
167652
167718
|
importDeclaration.attributes
|
|
167653
167719
|
);
|
|
167654
167720
|
}
|
|
167655
|
-
function sortSpecifiers(specifiers, comparer) {
|
|
167656
|
-
return stableSort(specifiers, (s1, s2) => compareImportOrExportSpecifiers(s1, s2, comparer));
|
|
167721
|
+
function sortSpecifiers(specifiers, comparer, preferences) {
|
|
167722
|
+
return stableSort(specifiers, (s1, s2) => compareImportOrExportSpecifiers(s1, s2, comparer, preferences));
|
|
167657
167723
|
}
|
|
167658
|
-
function compareImportOrExportSpecifiers(s1, s2, comparer) {
|
|
167659
|
-
|
|
167724
|
+
function compareImportOrExportSpecifiers(s1, s2, comparer, preferences) {
|
|
167725
|
+
switch (preferences == null ? void 0 : preferences.organizeImportsTypeOrder) {
|
|
167726
|
+
case "first":
|
|
167727
|
+
return compareBooleans(s2.isTypeOnly, s1.isTypeOnly) || comparer(s1.name.text, s2.name.text);
|
|
167728
|
+
case "inline":
|
|
167729
|
+
return comparer(s1.name.text, s2.name.text);
|
|
167730
|
+
default:
|
|
167731
|
+
return compareBooleans(s1.isTypeOnly, s2.isTypeOnly) || comparer(s1.name.text, s2.name.text);
|
|
167732
|
+
}
|
|
167660
167733
|
}
|
|
167661
167734
|
function compareModuleSpecifiers2(m1, m2, ignoreCase) {
|
|
167662
167735
|
const comparer = getOrganizeImportsOrdinalStringComparer(!!ignoreCase);
|
|
@@ -167778,8 +167851,26 @@ var ImportSpecifierSortingCache = class {
|
|
|
167778
167851
|
}
|
|
167779
167852
|
};
|
|
167780
167853
|
var detectImportSpecifierSorting = memoizeCached((specifiers, preferences) => {
|
|
167781
|
-
|
|
167782
|
-
|
|
167854
|
+
switch (preferences.organizeImportsTypeOrder) {
|
|
167855
|
+
case "first":
|
|
167856
|
+
if (!arrayIsSorted(specifiers, (s1, s2) => compareBooleans(s2.isTypeOnly, s1.isTypeOnly)))
|
|
167857
|
+
return 0 /* None */;
|
|
167858
|
+
break;
|
|
167859
|
+
case "inline":
|
|
167860
|
+
if (!arrayIsSorted(specifiers, (s1, s2) => {
|
|
167861
|
+
const comparer = getStringComparer(
|
|
167862
|
+
/*ignoreCase*/
|
|
167863
|
+
true
|
|
167864
|
+
);
|
|
167865
|
+
return comparer(s1.name.text, s2.name.text);
|
|
167866
|
+
})) {
|
|
167867
|
+
return 0 /* None */;
|
|
167868
|
+
}
|
|
167869
|
+
break;
|
|
167870
|
+
default:
|
|
167871
|
+
if (!arrayIsSorted(specifiers, (s1, s2) => compareBooleans(s1.isTypeOnly, s2.isTypeOnly)))
|
|
167872
|
+
return 0 /* None */;
|
|
167873
|
+
break;
|
|
167783
167874
|
}
|
|
167784
167875
|
const collateCaseSensitive = getOrganizeImportsComparer(
|
|
167785
167876
|
preferences,
|
|
@@ -167791,14 +167882,29 @@ var detectImportSpecifierSorting = memoizeCached((specifiers, preferences) => {
|
|
|
167791
167882
|
/*ignoreCase*/
|
|
167792
167883
|
true
|
|
167793
167884
|
);
|
|
167885
|
+
if (preferences.organizeImportsTypeOrder !== "inline") {
|
|
167886
|
+
const { type: regularImports, regular: typeImports } = groupBy(specifiers, (s) => s.isTypeOnly ? "type" : "regular");
|
|
167887
|
+
const regularCaseSensitivity = (regularImports == null ? void 0 : regularImports.length) ? detectSortCaseSensitivity(regularImports, (specifier) => specifier.name.text, collateCaseSensitive, collateCaseInsensitive) : void 0;
|
|
167888
|
+
const typeCaseSensitivity = (typeImports == null ? void 0 : typeImports.length) ? detectSortCaseSensitivity(typeImports, (specifier) => specifier.name.text ?? "", collateCaseSensitive, collateCaseInsensitive) : void 0;
|
|
167889
|
+
if (regularCaseSensitivity === void 0) {
|
|
167890
|
+
return typeCaseSensitivity ?? 0 /* None */;
|
|
167891
|
+
}
|
|
167892
|
+
if (typeCaseSensitivity === void 0) {
|
|
167893
|
+
return regularCaseSensitivity;
|
|
167894
|
+
}
|
|
167895
|
+
if (regularCaseSensitivity === 0 /* None */ || typeCaseSensitivity === 0 /* None */) {
|
|
167896
|
+
return 0 /* None */;
|
|
167897
|
+
}
|
|
167898
|
+
return typeCaseSensitivity & regularCaseSensitivity;
|
|
167899
|
+
}
|
|
167794
167900
|
return detectSortCaseSensitivity(specifiers, (specifier) => specifier.name.text, collateCaseSensitive, collateCaseInsensitive);
|
|
167795
167901
|
}, new ImportSpecifierSortingCache());
|
|
167796
167902
|
function getImportDeclarationInsertionIndex(sortedImports, newImport, comparer) {
|
|
167797
167903
|
const index = binarySearch(sortedImports, newImport, identity, (a, b) => compareImportsOrRequireStatements(a, b, comparer));
|
|
167798
167904
|
return index < 0 ? ~index : index;
|
|
167799
167905
|
}
|
|
167800
|
-
function getImportSpecifierInsertionIndex(sortedImports, newImport, comparer) {
|
|
167801
|
-
const index = binarySearch(sortedImports, newImport, identity, (s1, s2) => compareImportOrExportSpecifiers(s1, s2, comparer));
|
|
167906
|
+
function getImportSpecifierInsertionIndex(sortedImports, newImport, comparer, preferences) {
|
|
167907
|
+
const index = binarySearch(sortedImports, newImport, identity, (s1, s2) => compareImportOrExportSpecifiers(s1, s2, comparer, preferences));
|
|
167802
167908
|
return index < 0 ? ~index : index;
|
|
167803
167909
|
}
|
|
167804
167910
|
function compareImportsOrRequireStatements(s1, s2, comparer) {
|
package/lib/typescript.d.ts
CHANGED
|
@@ -2933,6 +2933,13 @@ declare namespace ts {
|
|
|
2933
2933
|
* Default: `false`
|
|
2934
2934
|
*/
|
|
2935
2935
|
readonly organizeImportsCaseFirst?: "upper" | "lower" | false;
|
|
2936
|
+
/**
|
|
2937
|
+
* Indicates where named type-only imports should sort. "inline" sorts named imports without regard to if the import is
|
|
2938
|
+
* type-only.
|
|
2939
|
+
*
|
|
2940
|
+
* Default: `last`
|
|
2941
|
+
*/
|
|
2942
|
+
readonly organizeImportsTypeOrder?: "last" | "first" | "inline";
|
|
2936
2943
|
/**
|
|
2937
2944
|
* Indicates whether {@link ReferencesResponseItem.lineText} is supported.
|
|
2938
2945
|
*/
|
|
@@ -8784,6 +8791,7 @@ declare namespace ts {
|
|
|
8784
8791
|
readonly organizeImportsNumericCollation?: boolean;
|
|
8785
8792
|
readonly organizeImportsAccentCollation?: boolean;
|
|
8786
8793
|
readonly organizeImportsCaseFirst?: "upper" | "lower" | false;
|
|
8794
|
+
readonly organizeImportsTypeOrder?: "first" | "last" | "inline";
|
|
8787
8795
|
readonly excludeLibrarySymbolsInNavTo?: boolean;
|
|
8788
8796
|
}
|
|
8789
8797
|
/** Represents a bigint literal value without requiring bigint support */
|
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.
|
|
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
|
|
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
|
|
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) {
|
|
@@ -46774,6 +46777,14 @@ ${lanes.join("\n")}
|
|
|
46774
46777
|
emptyArray,
|
|
46775
46778
|
emptyArray
|
|
46776
46779
|
);
|
|
46780
|
+
var resolvingApparentMappedType = createAnonymousType(
|
|
46781
|
+
/*symbol*/
|
|
46782
|
+
void 0,
|
|
46783
|
+
emptySymbols,
|
|
46784
|
+
emptyArray,
|
|
46785
|
+
emptyArray,
|
|
46786
|
+
emptyArray
|
|
46787
|
+
);
|
|
46777
46788
|
var markerSuperType = createTypeParameter();
|
|
46778
46789
|
var markerSubType = createTypeParameter();
|
|
46779
46790
|
markerSubType.constraint = markerSuperType;
|
|
@@ -49823,29 +49834,7 @@ ${lanes.join("\n")}
|
|
|
49823
49834
|
function getContainersOfSymbol(symbol, enclosingDeclaration, meaning) {
|
|
49824
49835
|
const container = getParentOfSymbol(symbol);
|
|
49825
49836
|
if (container && !(symbol.flags & 262144 /* TypeParameter */)) {
|
|
49826
|
-
|
|
49827
|
-
const reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration);
|
|
49828
|
-
const objectLiteralContainer = getVariableDeclarationOfObjectLiteral(container, meaning);
|
|
49829
|
-
if (enclosingDeclaration && container.flags & getQualifiedLeftMeaning(meaning) && getAccessibleSymbolChain(
|
|
49830
|
-
container,
|
|
49831
|
-
enclosingDeclaration,
|
|
49832
|
-
1920 /* Namespace */,
|
|
49833
|
-
/*useOnlyExternalAliasing*/
|
|
49834
|
-
false
|
|
49835
|
-
)) {
|
|
49836
|
-
return append(concatenate(concatenate([container], additionalContainers), reexportContainers), objectLiteralContainer);
|
|
49837
|
-
}
|
|
49838
|
-
const firstVariableMatch = !(container.flags & getQualifiedLeftMeaning(meaning)) && container.flags & 788968 /* Type */ && getDeclaredTypeOfSymbol(container).flags & 524288 /* Object */ && meaning === 111551 /* Value */ ? forEachSymbolTableInScope(enclosingDeclaration, (t) => {
|
|
49839
|
-
return forEachEntry(t, (s) => {
|
|
49840
|
-
if (s.flags & getQualifiedLeftMeaning(meaning) && getTypeOfSymbol(s) === getDeclaredTypeOfSymbol(container)) {
|
|
49841
|
-
return s;
|
|
49842
|
-
}
|
|
49843
|
-
});
|
|
49844
|
-
}) : void 0;
|
|
49845
|
-
let res = firstVariableMatch ? [firstVariableMatch, ...additionalContainers, container] : [...additionalContainers, container];
|
|
49846
|
-
res = append(res, objectLiteralContainer);
|
|
49847
|
-
res = addRange(res, reexportContainers);
|
|
49848
|
-
return res;
|
|
49837
|
+
return getWithAlternativeContainers(container);
|
|
49849
49838
|
}
|
|
49850
49839
|
const candidates = mapDefined(symbol.declarations, (d) => {
|
|
49851
49840
|
if (!isAmbientModule(d) && d.parent) {
|
|
@@ -49867,7 +49856,40 @@ ${lanes.join("\n")}
|
|
|
49867
49856
|
if (!length(candidates)) {
|
|
49868
49857
|
return void 0;
|
|
49869
49858
|
}
|
|
49870
|
-
|
|
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
|
+
}
|
|
49871
49893
|
function fileSymbolIfFileSymbolExportEqualsContainer(d) {
|
|
49872
49894
|
return container && getFileSymbolIfFileSymbolExportEqualsContainer(d, container);
|
|
49873
49895
|
}
|
|
@@ -49905,6 +49927,13 @@ ${lanes.join("\n")}
|
|
|
49905
49927
|
});
|
|
49906
49928
|
}
|
|
49907
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
|
+
}
|
|
49908
49937
|
if (getMergedSymbol(resolveSymbol(getMergedSymbol(s1))) === getMergedSymbol(resolveSymbol(getMergedSymbol(s2)))) {
|
|
49909
49938
|
return s1;
|
|
49910
49939
|
}
|
|
@@ -57643,14 +57672,30 @@ ${lanes.join("\n")}
|
|
|
57643
57672
|
return !!(typeParameter.symbol && forEach(typeParameter.symbol.declarations, (decl) => isTypeParameterDeclaration(decl) && decl.default));
|
|
57644
57673
|
}
|
|
57645
57674
|
function getApparentTypeOfMappedType(type) {
|
|
57646
|
-
|
|
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);
|
|
57647
57683
|
}
|
|
57648
57684
|
function getResolvedApparentTypeOfMappedType(type) {
|
|
57649
|
-
const
|
|
57650
|
-
|
|
57651
|
-
|
|
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
|
+
}
|
|
57652
57697
|
if (constraint && everyType(constraint, isArrayOrTupleType)) {
|
|
57653
|
-
return instantiateType(
|
|
57698
|
+
return instantiateType(mappedType, prependTypeMapping(typeVariable, constraint, mappedType.mapper));
|
|
57654
57699
|
}
|
|
57655
57700
|
}
|
|
57656
57701
|
return type;
|
|
@@ -57741,6 +57786,7 @@ ${lanes.join("\n")}
|
|
|
57741
57786
|
clone2.parent = (_c = (_b = singleProp.valueDeclaration) == null ? void 0 : _b.symbol) == null ? void 0 : _c.parent;
|
|
57742
57787
|
clone2.links.containingType = containingType;
|
|
57743
57788
|
clone2.links.mapper = links == null ? void 0 : links.mapper;
|
|
57789
|
+
clone2.links.writeType = getWriteTypeOfSymbol(singleProp);
|
|
57744
57790
|
return clone2;
|
|
57745
57791
|
} else {
|
|
57746
57792
|
return singleProp;
|
|
@@ -64366,6 +64412,18 @@ ${lanes.join("\n")}
|
|
|
64366
64412
|
}
|
|
64367
64413
|
return result2;
|
|
64368
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
|
+
}
|
|
64369
64427
|
function structuredTypeRelatedToWorker(source2, target2, reportErrors2, intersectionState, saveErrorInfo) {
|
|
64370
64428
|
let result2;
|
|
64371
64429
|
let originalErrorInfo;
|
|
@@ -64548,16 +64606,8 @@ ${lanes.join("\n")}
|
|
|
64548
64606
|
const constraintType = getConstraintTypeFromMappedType(targetType);
|
|
64549
64607
|
let targetKeys;
|
|
64550
64608
|
if (nameType && isMappedTypeWithKeyofConstraintDeclaration(targetType)) {
|
|
64551
|
-
const
|
|
64552
|
-
|
|
64553
|
-
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(
|
|
64554
|
-
modifiersType,
|
|
64555
|
-
8576 /* StringOrNumberLiteralOrUnique */,
|
|
64556
|
-
/*stringsOnly*/
|
|
64557
|
-
false,
|
|
64558
|
-
(t) => void mappedKeys.push(instantiateType(nameType, appendTypeMapping(targetType.mapper, getTypeParameterFromMappedType(targetType), t)))
|
|
64559
|
-
);
|
|
64560
|
-
targetKeys = getUnionType([...mappedKeys, nameType]);
|
|
64609
|
+
const mappedKeys = getApparentMappedTypeKeys(nameType, targetType);
|
|
64610
|
+
targetKeys = getUnionType([mappedKeys, nameType]);
|
|
64561
64611
|
} else {
|
|
64562
64612
|
targetKeys = nameType || constraintType;
|
|
64563
64613
|
}
|
|
@@ -64728,9 +64778,18 @@ ${lanes.join("\n")}
|
|
|
64728
64778
|
}
|
|
64729
64779
|
}
|
|
64730
64780
|
} else if (sourceFlags & 4194304 /* Index */) {
|
|
64731
|
-
|
|
64781
|
+
const isDeferredMappedIndex = shouldDeferIndexType(source2.type, source2.indexFlags) && getObjectFlags(source2.type) & 32 /* Mapped */;
|
|
64782
|
+
if (result2 = isRelatedTo(keyofConstraintType, target2, 1 /* Source */, reportErrors2 && !isDeferredMappedIndex)) {
|
|
64732
64783
|
return result2;
|
|
64733
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
|
+
}
|
|
64734
64793
|
} else if (sourceFlags & 134217728 /* TemplateLiteral */ && !(targetFlags & 524288 /* Object */)) {
|
|
64735
64794
|
if (!(targetFlags & 134217728 /* TemplateLiteral */)) {
|
|
64736
64795
|
const constraint = getBaseConstraintOfType(source2);
|
|
@@ -116428,7 +116487,14 @@ ${lanes.join("\n")}
|
|
|
116428
116487
|
function willEmitLeadingNewLine(node) {
|
|
116429
116488
|
if (!currentSourceFile)
|
|
116430
116489
|
return false;
|
|
116431
|
-
|
|
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))
|
|
116432
116498
|
return true;
|
|
116433
116499
|
if (some(getSyntheticLeadingComments(node), commentWillEmitNewLine))
|
|
116434
116500
|
return true;
|
|
@@ -151054,14 +151120,14 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
151054
151120
|
aliasDeclaration.name
|
|
151055
151121
|
);
|
|
151056
151122
|
const comparer = ts_OrganizeImports_exports.getOrganizeImportsComparer(preferences, sortKind === 2 /* CaseInsensitive */);
|
|
151057
|
-
const insertionIndex = ts_OrganizeImports_exports.getImportSpecifierInsertionIndex(aliasDeclaration.parent.elements, newSpecifier, comparer);
|
|
151058
|
-
if (aliasDeclaration.parent.elements.indexOf(aliasDeclaration)
|
|
151123
|
+
const insertionIndex = ts_OrganizeImports_exports.getImportSpecifierInsertionIndex(aliasDeclaration.parent.elements, newSpecifier, comparer, preferences);
|
|
151124
|
+
if (insertionIndex !== aliasDeclaration.parent.elements.indexOf(aliasDeclaration)) {
|
|
151059
151125
|
changes.delete(sourceFile, aliasDeclaration);
|
|
151060
151126
|
changes.insertImportSpecifierAtIndex(sourceFile, newSpecifier, aliasDeclaration.parent, insertionIndex);
|
|
151061
151127
|
return aliasDeclaration;
|
|
151062
151128
|
}
|
|
151063
151129
|
}
|
|
151064
|
-
changes.deleteRange(sourceFile, aliasDeclaration.getFirstToken());
|
|
151130
|
+
changes.deleteRange(sourceFile, { pos: getTokenPosOfNode(aliasDeclaration.getFirstToken()), end: getTokenPosOfNode(aliasDeclaration.propertyName ?? aliasDeclaration.name) });
|
|
151065
151131
|
return aliasDeclaration;
|
|
151066
151132
|
} else {
|
|
151067
151133
|
Debug.assert(aliasDeclaration.parent.parent.isTypeOnly);
|
|
@@ -151157,7 +151223,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
151157
151223
|
const specifierSort = (existingSpecifiers == null ? void 0 : existingSpecifiers.length) && ts_OrganizeImports_exports.detectImportSpecifierSorting(existingSpecifiers, preferences);
|
|
151158
151224
|
if (specifierSort && !(ignoreCaseForSorting && specifierSort === 1 /* CaseSensitive */)) {
|
|
151159
151225
|
for (const spec of newSpecifiers) {
|
|
151160
|
-
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);
|
|
151161
151227
|
changes.insertImportSpecifierAtIndex(sourceFile, spec, clause.namedBindings, insertionIndex);
|
|
151162
151228
|
}
|
|
151163
151229
|
} else if (existingSpecifiers == null ? void 0 : existingSpecifiers.length) {
|
|
@@ -166673,14 +166739,14 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
166673
166739
|
if (shouldRemove)
|
|
166674
166740
|
importGroup = removeUnusedImports(importGroup, sourceFile, program);
|
|
166675
166741
|
if (shouldCombine)
|
|
166676
|
-
importGroup = coalesceImportsWorker(importGroup, comparer, sourceFile);
|
|
166742
|
+
importGroup = coalesceImportsWorker(importGroup, comparer, sourceFile, preferences);
|
|
166677
166743
|
if (shouldSort)
|
|
166678
166744
|
importGroup = stableSort(importGroup, (s1, s2) => compareImportsOrRequireStatements(s1, s2, comparer));
|
|
166679
166745
|
return importGroup;
|
|
166680
166746
|
};
|
|
166681
166747
|
topLevelImportGroupDecls.forEach((importGroupDecl) => organizeImportsWorker(importGroupDecl, processImportsOfSameModuleSpecifier));
|
|
166682
166748
|
if (mode !== "RemoveUnused" /* RemoveUnused */) {
|
|
166683
|
-
getTopLevelExportGroups(sourceFile).forEach((exportGroupDecl) => organizeImportsWorker(exportGroupDecl, (group2) => coalesceExportsWorker(group2, comparer)));
|
|
166749
|
+
getTopLevelExportGroups(sourceFile).forEach((exportGroupDecl) => organizeImportsWorker(exportGroupDecl, (group2) => coalesceExportsWorker(group2, comparer, preferences)));
|
|
166684
166750
|
}
|
|
166685
166751
|
for (const ambientModule of sourceFile.statements.filter(isAmbientModule)) {
|
|
166686
166752
|
if (!ambientModule.body)
|
|
@@ -166689,7 +166755,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
166689
166755
|
ambientModuleImportGroupDecls.forEach((importGroupDecl) => organizeImportsWorker(importGroupDecl, processImportsOfSameModuleSpecifier));
|
|
166690
166756
|
if (mode !== "RemoveUnused" /* RemoveUnused */) {
|
|
166691
166757
|
const ambientModuleExportDecls = ambientModule.body.statements.filter(isExportDeclaration);
|
|
166692
|
-
organizeImportsWorker(ambientModuleExportDecls, (group2) => coalesceExportsWorker(group2, comparer));
|
|
166758
|
+
organizeImportsWorker(ambientModuleExportDecls, (group2) => coalesceExportsWorker(group2, comparer, preferences));
|
|
166693
166759
|
}
|
|
166694
166760
|
}
|
|
166695
166761
|
return changeTracker.getChanges();
|
|
@@ -166821,11 +166887,11 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
166821
166887
|
function getExternalModuleName2(specifier) {
|
|
166822
166888
|
return specifier !== void 0 && isStringLiteralLike(specifier) ? specifier.text : void 0;
|
|
166823
166889
|
}
|
|
166824
|
-
function coalesceImports(importGroup, ignoreCase, sourceFile) {
|
|
166890
|
+
function coalesceImports(importGroup, ignoreCase, sourceFile, preferences) {
|
|
166825
166891
|
const comparer = getOrganizeImportsOrdinalStringComparer(ignoreCase);
|
|
166826
|
-
return coalesceImportsWorker(importGroup, comparer, sourceFile);
|
|
166892
|
+
return coalesceImportsWorker(importGroup, comparer, sourceFile, preferences);
|
|
166827
166893
|
}
|
|
166828
|
-
function coalesceImportsWorker(importGroup, comparer, sourceFile) {
|
|
166894
|
+
function coalesceImportsWorker(importGroup, comparer, sourceFile, preferences) {
|
|
166829
166895
|
if (importGroup.length === 0) {
|
|
166830
166896
|
return importGroup;
|
|
166831
166897
|
}
|
|
@@ -166879,7 +166945,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
166879
166945
|
}
|
|
166880
166946
|
newImportSpecifiers.push(...getNewImportSpecifiers(namedImports));
|
|
166881
166947
|
const sortedImportSpecifiers = factory.createNodeArray(
|
|
166882
|
-
sortSpecifiers(newImportSpecifiers, comparer),
|
|
166948
|
+
sortSpecifiers(newImportSpecifiers, comparer, preferences),
|
|
166883
166949
|
firstNamedImport == null ? void 0 : firstNamedImport.importClause.namedBindings.elements.hasTrailingComma
|
|
166884
166950
|
);
|
|
166885
166951
|
const newNamedImports = sortedImportSpecifiers.length === 0 ? newDefaultImport ? void 0 : factory.createNamedImports(emptyArray) : firstNamedImport ? factory.updateNamedImports(firstNamedImport.importClause.namedBindings, sortedImportSpecifiers) : factory.createNamedImports(sortedImportSpecifiers);
|
|
@@ -166939,11 +167005,11 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
166939
167005
|
regularImports
|
|
166940
167006
|
};
|
|
166941
167007
|
}
|
|
166942
|
-
function coalesceExports(exportGroup, ignoreCase) {
|
|
167008
|
+
function coalesceExports(exportGroup, ignoreCase, preferences) {
|
|
166943
167009
|
const comparer = getOrganizeImportsOrdinalStringComparer(ignoreCase);
|
|
166944
|
-
return coalesceExportsWorker(exportGroup, comparer);
|
|
167010
|
+
return coalesceExportsWorker(exportGroup, comparer, preferences);
|
|
166945
167011
|
}
|
|
166946
|
-
function coalesceExportsWorker(exportGroup, comparer) {
|
|
167012
|
+
function coalesceExportsWorker(exportGroup, comparer, preferences) {
|
|
166947
167013
|
if (exportGroup.length === 0) {
|
|
166948
167014
|
return exportGroup;
|
|
166949
167015
|
}
|
|
@@ -166958,7 +167024,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
166958
167024
|
}
|
|
166959
167025
|
const newExportSpecifiers = [];
|
|
166960
167026
|
newExportSpecifiers.push(...flatMap(exportGroup2, (i) => i.exportClause && isNamedExports(i.exportClause) ? i.exportClause.elements : emptyArray));
|
|
166961
|
-
const sortedExportSpecifiers = sortSpecifiers(newExportSpecifiers, comparer);
|
|
167027
|
+
const sortedExportSpecifiers = sortSpecifiers(newExportSpecifiers, comparer, preferences);
|
|
166962
167028
|
const exportDecl = exportGroup2[0];
|
|
166963
167029
|
coalescedExports.push(
|
|
166964
167030
|
factory.updateExportDeclaration(
|
|
@@ -167002,11 +167068,18 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
167002
167068
|
importDeclaration.attributes
|
|
167003
167069
|
);
|
|
167004
167070
|
}
|
|
167005
|
-
function sortSpecifiers(specifiers, comparer) {
|
|
167006
|
-
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));
|
|
167007
167073
|
}
|
|
167008
|
-
function compareImportOrExportSpecifiers(s1, s2, comparer) {
|
|
167009
|
-
|
|
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
|
+
}
|
|
167010
167083
|
}
|
|
167011
167084
|
function compareModuleSpecifiers2(m1, m2, ignoreCase) {
|
|
167012
167085
|
const comparer = getOrganizeImportsOrdinalStringComparer(!!ignoreCase);
|
|
@@ -167111,8 +167184,8 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
167111
167184
|
const index = binarySearch(sortedImports, newImport, identity, (a, b) => compareImportsOrRequireStatements(a, b, comparer));
|
|
167112
167185
|
return index < 0 ? ~index : index;
|
|
167113
167186
|
}
|
|
167114
|
-
function getImportSpecifierInsertionIndex(sortedImports, newImport, comparer) {
|
|
167115
|
-
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));
|
|
167116
167189
|
return index < 0 ? ~index : index;
|
|
167117
167190
|
}
|
|
167118
167191
|
function compareImportsOrRequireStatements(s1, s2, comparer) {
|
|
@@ -167241,8 +167314,26 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
167241
167314
|
}
|
|
167242
167315
|
};
|
|
167243
167316
|
detectImportSpecifierSorting = memoizeCached((specifiers, preferences) => {
|
|
167244
|
-
|
|
167245
|
-
|
|
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;
|
|
167246
167337
|
}
|
|
167247
167338
|
const collateCaseSensitive = getOrganizeImportsComparer(
|
|
167248
167339
|
preferences,
|
|
@@ -167254,6 +167345,21 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
167254
167345
|
/*ignoreCase*/
|
|
167255
167346
|
true
|
|
167256
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
|
+
}
|
|
167257
167363
|
return detectSortCaseSensitivity(specifiers, (specifier) => specifier.name.text, collateCaseSensitive, collateCaseInsensitive);
|
|
167258
167364
|
}, new ImportSpecifierSortingCache());
|
|
167259
167365
|
}
|
package/lib/typingsInstaller.js
CHANGED
|
@@ -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.
|
|
57
|
+
var version = `${versionMajorMinor}.0-dev.20240110`;
|
|
58
58
|
|
|
59
59
|
// src/compiler/core.ts
|
|
60
60
|
var emptyArray = [];
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "typescript",
|
|
3
3
|
"author": "Microsoft Corp.",
|
|
4
4
|
"homepage": "https://www.typescriptlang.org/",
|
|
5
|
-
"version": "5.4.0-dev.
|
|
5
|
+
"version": "5.4.0-dev.20240110",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"description": "TypeScript is a language for application scale JavaScript development",
|
|
8
8
|
"keywords": [
|
|
@@ -113,5 +113,5 @@
|
|
|
113
113
|
"node": "20.1.0",
|
|
114
114
|
"npm": "8.19.4"
|
|
115
115
|
},
|
|
116
|
-
"gitHead": "
|
|
116
|
+
"gitHead": "81793210e6337ad8d20f2b7e44e9489687c2d29c"
|
|
117
117
|
}
|