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/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.20240111`;
|
|
39
39
|
Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
40
40
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
41
41
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -4352,6 +4352,7 @@ ${lanes.join("\n")}
|
|
|
4352
4352
|
InternalSymbolName2["Default"] = "default";
|
|
4353
4353
|
InternalSymbolName2["This"] = "this";
|
|
4354
4354
|
InternalSymbolName2["InstantiationExpression"] = "__instantiationExpression";
|
|
4355
|
+
InternalSymbolName2["ImportAttributes"] = "__importAttributes";
|
|
4355
4356
|
return InternalSymbolName2;
|
|
4356
4357
|
})(InternalSymbolName || {});
|
|
4357
4358
|
NodeCheckFlags = /* @__PURE__ */ ((NodeCheckFlags2) => {
|
|
@@ -13917,7 +13918,7 @@ ${lanes.join("\n")}
|
|
|
13917
13918
|
case 116 /* VoidKeyword */:
|
|
13918
13919
|
return node.parent.kind !== 222 /* VoidExpression */;
|
|
13919
13920
|
case 233 /* ExpressionWithTypeArguments */:
|
|
13920
|
-
return
|
|
13921
|
+
return isPartOfTypeExpressionWithTypeArguments(node);
|
|
13921
13922
|
case 168 /* TypeParameter */:
|
|
13922
13923
|
return node.parent.kind === 200 /* MappedType */ || node.parent.kind === 195 /* InferType */;
|
|
13923
13924
|
case 80 /* Identifier */:
|
|
@@ -13942,7 +13943,7 @@ ${lanes.join("\n")}
|
|
|
13942
13943
|
}
|
|
13943
13944
|
switch (parent2.kind) {
|
|
13944
13945
|
case 233 /* ExpressionWithTypeArguments */:
|
|
13945
|
-
return
|
|
13946
|
+
return isPartOfTypeExpressionWithTypeArguments(parent2);
|
|
13946
13947
|
case 168 /* TypeParameter */:
|
|
13947
13948
|
return node === parent2.constraint;
|
|
13948
13949
|
case 352 /* JSDocTemplateTag */:
|
|
@@ -13976,6 +13977,9 @@ ${lanes.join("\n")}
|
|
|
13976
13977
|
}
|
|
13977
13978
|
return false;
|
|
13978
13979
|
}
|
|
13980
|
+
function isPartOfTypeExpressionWithTypeArguments(node) {
|
|
13981
|
+
return isJSDocImplementsTag(node.parent) || isJSDocAugmentsTag(node.parent) || isHeritageClause(node.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(node);
|
|
13982
|
+
}
|
|
13979
13983
|
function isChildOfNodeWithKind(node, kind) {
|
|
13980
13984
|
while (node) {
|
|
13981
13985
|
if (node.kind === kind) {
|
|
@@ -18894,6 +18898,9 @@ ${lanes.join("\n")}
|
|
|
18894
18898
|
function replaceFirstStar(s, replacement) {
|
|
18895
18899
|
return stringReplace.call(s, "*", replacement);
|
|
18896
18900
|
}
|
|
18901
|
+
function getNameFromImportAttribute(node) {
|
|
18902
|
+
return isIdentifier(node.name) ? node.name.escapedText : escapeLeadingUnderscores(node.name.text);
|
|
18903
|
+
}
|
|
18897
18904
|
var resolvingEmptyArray, externalHelpersModuleNameText, defaultMaximumTruncationLength, noTruncationMaximumTruncationLength, stringWriter, getScriptTargetFeatures, GetLiteralTextFlags, fullTripleSlashReferencePathRegEx, fullTripleSlashReferenceTypeReferenceDirectiveRegEx, fullTripleSlashLibReferenceRegEx, fullTripleSlashAMDReferencePathRegEx, fullTripleSlashAMDModuleRegEx, defaultLibReferenceRegEx, AssignmentKind, FunctionFlags, Associativity, OperatorPrecedence, templateSubstitutionRegExp, doubleQuoteEscapedCharsRegExp, singleQuoteEscapedCharsRegExp, backtickQuoteEscapedCharsRegExp, escapedCharsMap, nonAsciiCharacters, jsxDoubleQuoteEscapedCharsRegExp, jsxSingleQuoteEscapedCharsRegExp, jsxEscapedCharsMap, indentStrings, base64Digits, carriageReturnLineFeed, lineFeed, objectAllocator, objectAllocatorPatchers, localizedDiagnosticMessages, computedOptions, getEmitScriptTarget, getEmitModuleKind, getEmitModuleResolutionKind, getEmitModuleDetectionKind, getIsolatedModules, getESModuleInterop, getAllowSyntheticDefaultImports, getResolvePackageJsonExports, getResolvePackageJsonImports, getResolveJsonModule, getEmitDeclarations, shouldPreserveConstEnums, isIncrementalCompilation, getAreDeclarationMapsEnabled, getAllowJSCompilerOption, getUseDefineForClassFields, reservedCharacterPattern, wildcardCharCodes, commonPackageFolders, implicitExcludePathRegexPattern, filesMatcher, directoriesMatcher, excludeMatcher, wildcardMatchers, supportedTSExtensions, supportedTSExtensionsFlat, supportedTSExtensionsWithJson, supportedTSExtensionsForExtractExtension, supportedJSExtensions, supportedJSExtensionsFlat, allSupportedExtensions, allSupportedExtensionsWithJson, supportedDeclarationExtensions, supportedTSImplementationExtensions, extensionsNotSupportingExtensionlessResolution, ModuleSpecifierEnding, extensionsToRemove, emptyFileSystemEntries, stringReplace;
|
|
18898
18905
|
var init_utilities = __esm({
|
|
18899
18906
|
"src/compiler/utilities.ts"() {
|
|
@@ -46774,6 +46781,14 @@ ${lanes.join("\n")}
|
|
|
46774
46781
|
emptyArray,
|
|
46775
46782
|
emptyArray
|
|
46776
46783
|
);
|
|
46784
|
+
var resolvingApparentMappedType = createAnonymousType(
|
|
46785
|
+
/*symbol*/
|
|
46786
|
+
void 0,
|
|
46787
|
+
emptySymbols,
|
|
46788
|
+
emptyArray,
|
|
46789
|
+
emptyArray,
|
|
46790
|
+
emptyArray
|
|
46791
|
+
);
|
|
46777
46792
|
var markerSuperType = createTypeParameter();
|
|
46778
46793
|
var markerSubType = createTypeParameter();
|
|
46779
46794
|
markerSubType.constraint = markerSuperType;
|
|
@@ -46928,6 +46943,7 @@ ${lanes.join("\n")}
|
|
|
46928
46943
|
var deferredGlobalImportMetaType;
|
|
46929
46944
|
var deferredGlobalImportMetaExpressionType;
|
|
46930
46945
|
var deferredGlobalImportCallOptionsType;
|
|
46946
|
+
var deferredGlobalImportAttributesType;
|
|
46931
46947
|
var deferredGlobalDisposableType;
|
|
46932
46948
|
var deferredGlobalAsyncDisposableType;
|
|
46933
46949
|
var deferredGlobalExtractSymbol;
|
|
@@ -49823,29 +49839,7 @@ ${lanes.join("\n")}
|
|
|
49823
49839
|
function getContainersOfSymbol(symbol, enclosingDeclaration, meaning) {
|
|
49824
49840
|
const container = getParentOfSymbol(symbol);
|
|
49825
49841
|
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;
|
|
49842
|
+
return getWithAlternativeContainers(container);
|
|
49849
49843
|
}
|
|
49850
49844
|
const candidates = mapDefined(symbol.declarations, (d) => {
|
|
49851
49845
|
if (!isAmbientModule(d) && d.parent) {
|
|
@@ -49867,7 +49861,40 @@ ${lanes.join("\n")}
|
|
|
49867
49861
|
if (!length(candidates)) {
|
|
49868
49862
|
return void 0;
|
|
49869
49863
|
}
|
|
49870
|
-
|
|
49864
|
+
const containers = mapDefined(candidates, (candidate) => getAliasForSymbolInContainer(candidate, symbol) ? candidate : void 0);
|
|
49865
|
+
let bestContainers = [];
|
|
49866
|
+
let alternativeContainers = [];
|
|
49867
|
+
for (const container2 of containers) {
|
|
49868
|
+
const [bestMatch, ...rest] = getWithAlternativeContainers(container2);
|
|
49869
|
+
bestContainers = append(bestContainers, bestMatch);
|
|
49870
|
+
alternativeContainers = addRange(alternativeContainers, rest);
|
|
49871
|
+
}
|
|
49872
|
+
return concatenate(bestContainers, alternativeContainers);
|
|
49873
|
+
function getWithAlternativeContainers(container2) {
|
|
49874
|
+
const additionalContainers = mapDefined(container2.declarations, fileSymbolIfFileSymbolExportEqualsContainer);
|
|
49875
|
+
const reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration);
|
|
49876
|
+
const objectLiteralContainer = getVariableDeclarationOfObjectLiteral(container2, meaning);
|
|
49877
|
+
if (enclosingDeclaration && container2.flags & getQualifiedLeftMeaning(meaning) && getAccessibleSymbolChain(
|
|
49878
|
+
container2,
|
|
49879
|
+
enclosingDeclaration,
|
|
49880
|
+
1920 /* Namespace */,
|
|
49881
|
+
/*useOnlyExternalAliasing*/
|
|
49882
|
+
false
|
|
49883
|
+
)) {
|
|
49884
|
+
return append(concatenate(concatenate([container2], additionalContainers), reexportContainers), objectLiteralContainer);
|
|
49885
|
+
}
|
|
49886
|
+
const firstVariableMatch = !(container2.flags & getQualifiedLeftMeaning(meaning)) && container2.flags & 788968 /* Type */ && getDeclaredTypeOfSymbol(container2).flags & 524288 /* Object */ && meaning === 111551 /* Value */ ? forEachSymbolTableInScope(enclosingDeclaration, (t) => {
|
|
49887
|
+
return forEachEntry(t, (s) => {
|
|
49888
|
+
if (s.flags & getQualifiedLeftMeaning(meaning) && getTypeOfSymbol(s) === getDeclaredTypeOfSymbol(container2)) {
|
|
49889
|
+
return s;
|
|
49890
|
+
}
|
|
49891
|
+
});
|
|
49892
|
+
}) : void 0;
|
|
49893
|
+
let res = firstVariableMatch ? [firstVariableMatch, ...additionalContainers, container2] : [...additionalContainers, container2];
|
|
49894
|
+
res = append(res, objectLiteralContainer);
|
|
49895
|
+
res = addRange(res, reexportContainers);
|
|
49896
|
+
return res;
|
|
49897
|
+
}
|
|
49871
49898
|
function fileSymbolIfFileSymbolExportEqualsContainer(d) {
|
|
49872
49899
|
return container && getFileSymbolIfFileSymbolExportEqualsContainer(d, container);
|
|
49873
49900
|
}
|
|
@@ -49905,6 +49932,13 @@ ${lanes.join("\n")}
|
|
|
49905
49932
|
});
|
|
49906
49933
|
}
|
|
49907
49934
|
function getSymbolIfSameReference(s1, s2) {
|
|
49935
|
+
var _a, _b;
|
|
49936
|
+
if (s1.flags & 524288 /* TypeAlias */ && ((_a = s2.declarations) == null ? void 0 : _a.find(isTypeAlias))) {
|
|
49937
|
+
s2 = getDeclaredTypeOfTypeAlias(s2).aliasSymbol || s2;
|
|
49938
|
+
}
|
|
49939
|
+
if (s2.flags & 524288 /* TypeAlias */ && ((_b = s1.declarations) == null ? void 0 : _b.find(isTypeAlias))) {
|
|
49940
|
+
s1 = getDeclaredTypeOfTypeAlias(s1).aliasSymbol || s1;
|
|
49941
|
+
}
|
|
49908
49942
|
if (getMergedSymbol(resolveSymbol(getMergedSymbol(s1))) === getMergedSymbol(resolveSymbol(getMergedSymbol(s2)))) {
|
|
49909
49943
|
return s1;
|
|
49910
49944
|
}
|
|
@@ -55147,7 +55181,7 @@ ${lanes.join("\n")}
|
|
|
55147
55181
|
/*reportErrors*/
|
|
55148
55182
|
false
|
|
55149
55183
|
) : unknownType;
|
|
55150
|
-
return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0 /* Normal */, contextualType)));
|
|
55184
|
+
return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, reportErrors2 ? 0 /* Normal */ : 1 /* Contextual */, contextualType)));
|
|
55151
55185
|
}
|
|
55152
55186
|
if (isBindingPattern(element.name)) {
|
|
55153
55187
|
return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors2);
|
|
@@ -55228,6 +55262,24 @@ ${lanes.join("\n")}
|
|
|
55228
55262
|
0 /* Normal */
|
|
55229
55263
|
), declaration, reportErrors2);
|
|
55230
55264
|
}
|
|
55265
|
+
function getTypeFromImportAttributes(node) {
|
|
55266
|
+
const links = getNodeLinks(node);
|
|
55267
|
+
if (!links.resolvedType) {
|
|
55268
|
+
const symbol = createSymbol(4096 /* ObjectLiteral */, "__importAttributes" /* ImportAttributes */);
|
|
55269
|
+
const members = createSymbolTable();
|
|
55270
|
+
forEach(node.elements, (attr) => {
|
|
55271
|
+
const member = createSymbol(4 /* Property */, getNameFromImportAttribute(attr));
|
|
55272
|
+
member.parent = symbol;
|
|
55273
|
+
member.links.type = checkImportAttribute(attr);
|
|
55274
|
+
member.links.target = member;
|
|
55275
|
+
members.set(member.escapedName, member);
|
|
55276
|
+
});
|
|
55277
|
+
const type = createAnonymousType(symbol, members, emptyArray, emptyArray, emptyArray);
|
|
55278
|
+
type.objectFlags |= 128 /* ObjectLiteral */ | 262144 /* NonInferrableType */;
|
|
55279
|
+
links.resolvedType = type;
|
|
55280
|
+
}
|
|
55281
|
+
return links.resolvedType;
|
|
55282
|
+
}
|
|
55231
55283
|
function isGlobalSymbolConstructor(node) {
|
|
55232
55284
|
const symbol = getSymbolOfNode(node);
|
|
55233
55285
|
const globalSymbol = getGlobalESSymbolConstructorTypeSymbol(
|
|
@@ -55281,18 +55333,18 @@ ${lanes.join("\n")}
|
|
|
55281
55333
|
}
|
|
55282
55334
|
return false;
|
|
55283
55335
|
}
|
|
55284
|
-
function getTypeOfVariableOrParameterOrProperty(symbol) {
|
|
55336
|
+
function getTypeOfVariableOrParameterOrProperty(symbol, checkMode) {
|
|
55285
55337
|
const links = getSymbolLinks(symbol);
|
|
55286
55338
|
if (!links.type) {
|
|
55287
|
-
const type = getTypeOfVariableOrParameterOrPropertyWorker(symbol);
|
|
55288
|
-
if (!links.type && !isParameterOfContextSensitiveSignature(symbol)) {
|
|
55339
|
+
const type = getTypeOfVariableOrParameterOrPropertyWorker(symbol, checkMode);
|
|
55340
|
+
if (!links.type && !isParameterOfContextSensitiveSignature(symbol) && !checkMode) {
|
|
55289
55341
|
links.type = type;
|
|
55290
55342
|
}
|
|
55291
55343
|
return type;
|
|
55292
55344
|
}
|
|
55293
55345
|
return links.type;
|
|
55294
55346
|
}
|
|
55295
|
-
function getTypeOfVariableOrParameterOrPropertyWorker(symbol) {
|
|
55347
|
+
function getTypeOfVariableOrParameterOrPropertyWorker(symbol, checkMode) {
|
|
55296
55348
|
if (symbol.flags & 4194304 /* Prototype */) {
|
|
55297
55349
|
return getTypeOfPrototypeProperty(symbol);
|
|
55298
55350
|
}
|
|
@@ -55330,6 +55382,9 @@ ${lanes.join("\n")}
|
|
|
55330
55382
|
if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) {
|
|
55331
55383
|
return getTypeOfFuncClassEnumModule(symbol);
|
|
55332
55384
|
}
|
|
55385
|
+
if (isBindingElement(declaration) && checkMode === 1 /* Contextual */) {
|
|
55386
|
+
return errorType;
|
|
55387
|
+
}
|
|
55333
55388
|
return reportCircularityError(symbol);
|
|
55334
55389
|
}
|
|
55335
55390
|
let type;
|
|
@@ -55367,6 +55422,9 @@ ${lanes.join("\n")}
|
|
|
55367
55422
|
if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) {
|
|
55368
55423
|
return getTypeOfFuncClassEnumModule(symbol);
|
|
55369
55424
|
}
|
|
55425
|
+
if (isBindingElement(declaration) && checkMode === 1 /* Contextual */) {
|
|
55426
|
+
return type;
|
|
55427
|
+
}
|
|
55370
55428
|
return reportCircularityError(symbol);
|
|
55371
55429
|
}
|
|
55372
55430
|
return type;
|
|
@@ -55595,7 +55653,7 @@ ${lanes.join("\n")}
|
|
|
55595
55653
|
}
|
|
55596
55654
|
return getTypeOfSymbol(symbol);
|
|
55597
55655
|
}
|
|
55598
|
-
function getTypeOfSymbol(symbol) {
|
|
55656
|
+
function getTypeOfSymbol(symbol, checkMode) {
|
|
55599
55657
|
const checkFlags = getCheckFlags(symbol);
|
|
55600
55658
|
if (checkFlags & 65536 /* DeferredType */) {
|
|
55601
55659
|
return getTypeOfSymbolWithDeferredType(symbol);
|
|
@@ -55610,7 +55668,7 @@ ${lanes.join("\n")}
|
|
|
55610
55668
|
return getTypeOfReverseMappedSymbol(symbol);
|
|
55611
55669
|
}
|
|
55612
55670
|
if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) {
|
|
55613
|
-
return getTypeOfVariableOrParameterOrProperty(symbol);
|
|
55671
|
+
return getTypeOfVariableOrParameterOrProperty(symbol, checkMode);
|
|
55614
55672
|
}
|
|
55615
55673
|
if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) {
|
|
55616
55674
|
return getTypeOfFuncClassEnumModule(symbol);
|
|
@@ -57643,14 +57701,30 @@ ${lanes.join("\n")}
|
|
|
57643
57701
|
return !!(typeParameter.symbol && forEach(typeParameter.symbol.declarations, (decl) => isTypeParameterDeclaration(decl) && decl.default));
|
|
57644
57702
|
}
|
|
57645
57703
|
function getApparentTypeOfMappedType(type) {
|
|
57646
|
-
|
|
57704
|
+
if (type.resolvedApparentType) {
|
|
57705
|
+
if (type.resolvedApparentType === resolvingApparentMappedType) {
|
|
57706
|
+
return type.resolvedApparentType = type;
|
|
57707
|
+
}
|
|
57708
|
+
return type.resolvedApparentType;
|
|
57709
|
+
}
|
|
57710
|
+
type.resolvedApparentType = resolvingApparentMappedType;
|
|
57711
|
+
return type.resolvedApparentType = getResolvedApparentTypeOfMappedType(type);
|
|
57647
57712
|
}
|
|
57648
57713
|
function getResolvedApparentTypeOfMappedType(type) {
|
|
57649
|
-
const
|
|
57650
|
-
|
|
57651
|
-
|
|
57714
|
+
const mappedType = type.target || type;
|
|
57715
|
+
const typeVariable = getHomomorphicTypeVariable(mappedType);
|
|
57716
|
+
if (typeVariable && !mappedType.declaration.nameType) {
|
|
57717
|
+
let constraint;
|
|
57718
|
+
if (!type.target) {
|
|
57719
|
+
constraint = getConstraintOfTypeParameter(typeVariable);
|
|
57720
|
+
} else {
|
|
57721
|
+
const modifiersConstraint = getConstraintOfType(getModifiersTypeFromMappedType(type));
|
|
57722
|
+
if (modifiersConstraint) {
|
|
57723
|
+
constraint = getApparentType(modifiersConstraint);
|
|
57724
|
+
}
|
|
57725
|
+
}
|
|
57652
57726
|
if (constraint && everyType(constraint, isArrayOrTupleType)) {
|
|
57653
|
-
return instantiateType(
|
|
57727
|
+
return instantiateType(mappedType, prependTypeMapping(typeVariable, constraint, mappedType.mapper));
|
|
57654
57728
|
}
|
|
57655
57729
|
}
|
|
57656
57730
|
return type;
|
|
@@ -57741,6 +57815,7 @@ ${lanes.join("\n")}
|
|
|
57741
57815
|
clone2.parent = (_c = (_b = singleProp.valueDeclaration) == null ? void 0 : _b.symbol) == null ? void 0 : _c.parent;
|
|
57742
57816
|
clone2.links.containingType = containingType;
|
|
57743
57817
|
clone2.links.mapper = links == null ? void 0 : links.mapper;
|
|
57818
|
+
clone2.links.writeType = getWriteTypeOfSymbol(singleProp);
|
|
57744
57819
|
return clone2;
|
|
57745
57820
|
} else {
|
|
57746
57821
|
return singleProp;
|
|
@@ -59209,6 +59284,14 @@ ${lanes.join("\n")}
|
|
|
59209
59284
|
reportErrors2
|
|
59210
59285
|
)) || emptyObjectType;
|
|
59211
59286
|
}
|
|
59287
|
+
function getGlobalImportAttributesType(reportErrors2) {
|
|
59288
|
+
return deferredGlobalImportAttributesType || (deferredGlobalImportAttributesType = getGlobalType(
|
|
59289
|
+
"ImportAttributes",
|
|
59290
|
+
/*arity*/
|
|
59291
|
+
0,
|
|
59292
|
+
reportErrors2
|
|
59293
|
+
)) || emptyObjectType;
|
|
59294
|
+
}
|
|
59212
59295
|
function getGlobalESSymbolConstructorSymbol(reportErrors2) {
|
|
59213
59296
|
return deferredGlobalESSymbolConstructorSymbol || (deferredGlobalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol", reportErrors2));
|
|
59214
59297
|
}
|
|
@@ -64366,6 +64449,18 @@ ${lanes.join("\n")}
|
|
|
64366
64449
|
}
|
|
64367
64450
|
return result2;
|
|
64368
64451
|
}
|
|
64452
|
+
function getApparentMappedTypeKeys(nameType, targetType) {
|
|
64453
|
+
const modifiersType = getApparentType(getModifiersTypeFromMappedType(targetType));
|
|
64454
|
+
const mappedKeys = [];
|
|
64455
|
+
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(
|
|
64456
|
+
modifiersType,
|
|
64457
|
+
8576 /* StringOrNumberLiteralOrUnique */,
|
|
64458
|
+
/*stringsOnly*/
|
|
64459
|
+
false,
|
|
64460
|
+
(t) => void mappedKeys.push(instantiateType(nameType, appendTypeMapping(targetType.mapper, getTypeParameterFromMappedType(targetType), t)))
|
|
64461
|
+
);
|
|
64462
|
+
return getUnionType(mappedKeys);
|
|
64463
|
+
}
|
|
64369
64464
|
function structuredTypeRelatedToWorker(source2, target2, reportErrors2, intersectionState, saveErrorInfo) {
|
|
64370
64465
|
let result2;
|
|
64371
64466
|
let originalErrorInfo;
|
|
@@ -64548,16 +64643,8 @@ ${lanes.join("\n")}
|
|
|
64548
64643
|
const constraintType = getConstraintTypeFromMappedType(targetType);
|
|
64549
64644
|
let targetKeys;
|
|
64550
64645
|
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]);
|
|
64646
|
+
const mappedKeys = getApparentMappedTypeKeys(nameType, targetType);
|
|
64647
|
+
targetKeys = getUnionType([mappedKeys, nameType]);
|
|
64561
64648
|
} else {
|
|
64562
64649
|
targetKeys = nameType || constraintType;
|
|
64563
64650
|
}
|
|
@@ -64728,9 +64815,18 @@ ${lanes.join("\n")}
|
|
|
64728
64815
|
}
|
|
64729
64816
|
}
|
|
64730
64817
|
} else if (sourceFlags & 4194304 /* Index */) {
|
|
64731
|
-
|
|
64818
|
+
const isDeferredMappedIndex = shouldDeferIndexType(source2.type, source2.indexFlags) && getObjectFlags(source2.type) & 32 /* Mapped */;
|
|
64819
|
+
if (result2 = isRelatedTo(keyofConstraintType, target2, 1 /* Source */, reportErrors2 && !isDeferredMappedIndex)) {
|
|
64732
64820
|
return result2;
|
|
64733
64821
|
}
|
|
64822
|
+
if (isDeferredMappedIndex) {
|
|
64823
|
+
const mappedType = source2.type;
|
|
64824
|
+
const nameType = getNameTypeFromMappedType(mappedType);
|
|
64825
|
+
const sourceMappedKeys = nameType && isMappedTypeWithKeyofConstraintDeclaration(mappedType) ? getApparentMappedTypeKeys(nameType, mappedType) : nameType || getConstraintTypeFromMappedType(mappedType);
|
|
64826
|
+
if (result2 = isRelatedTo(sourceMappedKeys, target2, 1 /* Source */, reportErrors2)) {
|
|
64827
|
+
return result2;
|
|
64828
|
+
}
|
|
64829
|
+
}
|
|
64734
64830
|
} else if (sourceFlags & 134217728 /* TemplateLiteral */ && !(targetFlags & 524288 /* Object */)) {
|
|
64735
64831
|
if (!(targetFlags & 134217728 /* TemplateLiteral */)) {
|
|
64736
64832
|
const constraint = getBaseConstraintOfType(source2);
|
|
@@ -69943,9 +70039,9 @@ ${lanes.join("\n")}
|
|
|
69943
70039
|
}
|
|
69944
70040
|
}
|
|
69945
70041
|
}
|
|
69946
|
-
function getNarrowedTypeOfSymbol(symbol, location) {
|
|
70042
|
+
function getNarrowedTypeOfSymbol(symbol, location, checkMode) {
|
|
69947
70043
|
var _a;
|
|
69948
|
-
const type = getTypeOfSymbol(symbol);
|
|
70044
|
+
const type = getTypeOfSymbol(symbol, checkMode);
|
|
69949
70045
|
const declaration = symbol.valueDeclaration;
|
|
69950
70046
|
if (declaration) {
|
|
69951
70047
|
if (isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && declaration.parent.elements.length >= 2) {
|
|
@@ -70072,7 +70168,7 @@ ${lanes.join("\n")}
|
|
|
70072
70168
|
}
|
|
70073
70169
|
}
|
|
70074
70170
|
checkNestedBlockScopedBinding(node, symbol);
|
|
70075
|
-
let type = getNarrowedTypeOfSymbol(localOrExportSymbol, node);
|
|
70171
|
+
let type = getNarrowedTypeOfSymbol(localOrExportSymbol, node, checkMode);
|
|
70076
70172
|
const assignmentKind = getAssignmentTargetKind(node);
|
|
70077
70173
|
if (assignmentKind) {
|
|
70078
70174
|
if (!(localOrExportSymbol.flags & 3 /* Variable */) && !(isInJSFile(node) && localOrExportSymbol.flags & 512 /* ValueModule */)) {
|
|
@@ -71382,6 +71478,8 @@ ${lanes.join("\n")}
|
|
|
71382
71478
|
case 286 /* JsxOpeningElement */:
|
|
71383
71479
|
case 285 /* JsxSelfClosingElement */:
|
|
71384
71480
|
return getContextualJsxElementAttributesType(parent2, contextFlags);
|
|
71481
|
+
case 301 /* ImportAttribute */:
|
|
71482
|
+
return getContextualImportAttributeType(parent2);
|
|
71385
71483
|
}
|
|
71386
71484
|
return void 0;
|
|
71387
71485
|
}
|
|
@@ -71429,6 +71527,12 @@ ${lanes.join("\n")}
|
|
|
71429
71527
|
}
|
|
71430
71528
|
}
|
|
71431
71529
|
}
|
|
71530
|
+
function getContextualImportAttributeType(node) {
|
|
71531
|
+
return getTypeOfPropertyOfContextualType(getGlobalImportAttributesType(
|
|
71532
|
+
/*reportErrors*/
|
|
71533
|
+
false
|
|
71534
|
+
), getNameFromImportAttribute(node));
|
|
71535
|
+
}
|
|
71432
71536
|
function getContextualJsxElementAttributesType(node, contextFlags) {
|
|
71433
71537
|
if (isJsxOpeningElement(node) && contextFlags !== 4 /* Completions */) {
|
|
71434
71538
|
const index = findContextualNode(
|
|
@@ -83514,6 +83618,13 @@ ${lanes.join("\n")}
|
|
|
83514
83618
|
var _a;
|
|
83515
83619
|
const node = declaration.attributes;
|
|
83516
83620
|
if (node) {
|
|
83621
|
+
const importAttributesType = getGlobalImportAttributesType(
|
|
83622
|
+
/*reportErrors*/
|
|
83623
|
+
true
|
|
83624
|
+
);
|
|
83625
|
+
if (importAttributesType !== emptyObjectType) {
|
|
83626
|
+
checkTypeAssignableTo(getTypeFromImportAttributes(node), getNullableType(importAttributesType, 32768 /* Undefined */), node);
|
|
83627
|
+
}
|
|
83517
83628
|
const validForTypeAttributes = isExclusivelyTypeOnlyImportOrExport(declaration);
|
|
83518
83629
|
const override = getResolutionModeOverride(node, validForTypeAttributes ? grammarErrorOnNode : void 0);
|
|
83519
83630
|
const isImportAttributes2 = declaration.attributes.token === 118 /* WithKeyword */;
|
|
@@ -83533,6 +83644,9 @@ ${lanes.join("\n")}
|
|
|
83533
83644
|
}
|
|
83534
83645
|
}
|
|
83535
83646
|
}
|
|
83647
|
+
function checkImportAttribute(node) {
|
|
83648
|
+
return getRegularTypeOfLiteralType(checkExpressionCached(node.value));
|
|
83649
|
+
}
|
|
83536
83650
|
function checkImportDeclaration(node) {
|
|
83537
83651
|
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)) {
|
|
83538
83652
|
return;
|
|
@@ -84948,6 +85062,12 @@ ${lanes.join("\n")}
|
|
|
84948
85062
|
if (isMetaProperty(node.parent) && node.parent.keywordToken === node.kind) {
|
|
84949
85063
|
return checkMetaPropertyKeyword(node.parent);
|
|
84950
85064
|
}
|
|
85065
|
+
if (isImportAttributes(node)) {
|
|
85066
|
+
return getGlobalImportAttributesType(
|
|
85067
|
+
/*reportErrors*/
|
|
85068
|
+
false
|
|
85069
|
+
);
|
|
85070
|
+
}
|
|
84951
85071
|
return errorType;
|
|
84952
85072
|
}
|
|
84953
85073
|
function getTypeOfAssignmentPattern(expr) {
|
|
@@ -116428,7 +116548,14 @@ ${lanes.join("\n")}
|
|
|
116428
116548
|
function willEmitLeadingNewLine(node) {
|
|
116429
116549
|
if (!currentSourceFile)
|
|
116430
116550
|
return false;
|
|
116431
|
-
|
|
116551
|
+
const leadingCommentRanges = getLeadingCommentRanges(currentSourceFile.text, node.pos);
|
|
116552
|
+
if (leadingCommentRanges) {
|
|
116553
|
+
const parseNode = getParseTreeNode(node);
|
|
116554
|
+
if (parseNode && isParenthesizedExpression(parseNode.parent)) {
|
|
116555
|
+
return true;
|
|
116556
|
+
}
|
|
116557
|
+
}
|
|
116558
|
+
if (some(leadingCommentRanges, commentWillEmitNewLine))
|
|
116432
116559
|
return true;
|
|
116433
116560
|
if (some(getSyntheticLeadingComments(node), commentWillEmitNewLine))
|
|
116434
116561
|
return true;
|
|
@@ -122471,7 +122598,7 @@ ${lanes.join("\n")}
|
|
|
122471
122598
|
}
|
|
122472
122599
|
const isFromNodeModulesSearch = resolution.isExternalLibraryImport;
|
|
122473
122600
|
const isJsFile = !resolutionExtensionIsTSOrJson(resolution.extension);
|
|
122474
|
-
const isJsFileFromNodeModules = isFromNodeModulesSearch && isJsFile;
|
|
122601
|
+
const isJsFileFromNodeModules = isFromNodeModulesSearch && isJsFile && (!resolution.originalPath || pathContainsNodeModules(resolution.resolvedFileName));
|
|
122475
122602
|
const resolvedFileName = resolution.resolvedFileName;
|
|
122476
122603
|
if (isFromNodeModulesSearch) {
|
|
122477
122604
|
currentNodeModulesDepth++;
|
|
@@ -151054,14 +151181,14 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
151054
151181
|
aliasDeclaration.name
|
|
151055
151182
|
);
|
|
151056
151183
|
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)
|
|
151184
|
+
const insertionIndex = ts_OrganizeImports_exports.getImportSpecifierInsertionIndex(aliasDeclaration.parent.elements, newSpecifier, comparer, preferences);
|
|
151185
|
+
if (insertionIndex !== aliasDeclaration.parent.elements.indexOf(aliasDeclaration)) {
|
|
151059
151186
|
changes.delete(sourceFile, aliasDeclaration);
|
|
151060
151187
|
changes.insertImportSpecifierAtIndex(sourceFile, newSpecifier, aliasDeclaration.parent, insertionIndex);
|
|
151061
151188
|
return aliasDeclaration;
|
|
151062
151189
|
}
|
|
151063
151190
|
}
|
|
151064
|
-
changes.deleteRange(sourceFile, aliasDeclaration.getFirstToken());
|
|
151191
|
+
changes.deleteRange(sourceFile, { pos: getTokenPosOfNode(aliasDeclaration.getFirstToken()), end: getTokenPosOfNode(aliasDeclaration.propertyName ?? aliasDeclaration.name) });
|
|
151065
151192
|
return aliasDeclaration;
|
|
151066
151193
|
} else {
|
|
151067
151194
|
Debug.assert(aliasDeclaration.parent.parent.isTypeOnly);
|
|
@@ -151157,7 +151284,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
151157
151284
|
const specifierSort = (existingSpecifiers == null ? void 0 : existingSpecifiers.length) && ts_OrganizeImports_exports.detectImportSpecifierSorting(existingSpecifiers, preferences);
|
|
151158
151285
|
if (specifierSort && !(ignoreCaseForSorting && specifierSort === 1 /* CaseSensitive */)) {
|
|
151159
151286
|
for (const spec of newSpecifiers) {
|
|
151160
|
-
const insertionIndex = promoteFromTypeOnly2 && !spec.isTypeOnly ? 0 : ts_OrganizeImports_exports.getImportSpecifierInsertionIndex(existingSpecifiers, spec, comparer);
|
|
151287
|
+
const insertionIndex = promoteFromTypeOnly2 && !spec.isTypeOnly ? 0 : ts_OrganizeImports_exports.getImportSpecifierInsertionIndex(existingSpecifiers, spec, comparer, preferences);
|
|
151161
151288
|
changes.insertImportSpecifierAtIndex(sourceFile, spec, clause.namedBindings, insertionIndex);
|
|
151162
151289
|
}
|
|
151163
151290
|
} else if (existingSpecifiers == null ? void 0 : existingSpecifiers.length) {
|
|
@@ -160017,7 +160144,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
160017
160144
|
return isIdentifier(e) ? e : isPropertyAccessExpression(e) ? getLeftMostName(e.expression) : void 0;
|
|
160018
160145
|
}
|
|
160019
160146
|
function tryGetGlobalSymbols() {
|
|
160020
|
-
const result = tryGetObjectTypeLiteralInTypeArgumentCompletionSymbols() || tryGetObjectLikeCompletionSymbols() || tryGetImportCompletionSymbols() || tryGetImportOrExportClauseCompletionSymbols() || tryGetLocalNamedExportCompletionSymbols() || tryGetConstructorCompletion() || tryGetClassLikeCompletionSymbols() || tryGetJsxCompletionSymbols() || (getGlobalCompletions(), 1 /* Success */);
|
|
160147
|
+
const result = tryGetObjectTypeLiteralInTypeArgumentCompletionSymbols() || tryGetObjectLikeCompletionSymbols() || tryGetImportCompletionSymbols() || tryGetImportOrExportClauseCompletionSymbols() || tryGetImportAttributesCompletionSymbols() || tryGetLocalNamedExportCompletionSymbols() || tryGetConstructorCompletion() || tryGetClassLikeCompletionSymbols() || tryGetJsxCompletionSymbols() || (getGlobalCompletions(), 1 /* Success */);
|
|
160021
160148
|
return result === 1 /* Success */;
|
|
160022
160149
|
}
|
|
160023
160150
|
function tryGetConstructorCompletion() {
|
|
@@ -160485,6 +160612,16 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
160485
160612
|
}
|
|
160486
160613
|
return 1 /* Success */;
|
|
160487
160614
|
}
|
|
160615
|
+
function tryGetImportAttributesCompletionSymbols() {
|
|
160616
|
+
if (contextToken === void 0)
|
|
160617
|
+
return 0 /* Continue */;
|
|
160618
|
+
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;
|
|
160619
|
+
if (importAttributes === void 0)
|
|
160620
|
+
return 0 /* Continue */;
|
|
160621
|
+
const existing = new Set(importAttributes.elements.map(getNameFromImportAttribute));
|
|
160622
|
+
symbols = filter(typeChecker.getTypeAtLocation(importAttributes).getApparentProperties(), (attr) => !existing.has(attr.escapedName));
|
|
160623
|
+
return 1 /* Success */;
|
|
160624
|
+
}
|
|
160488
160625
|
function tryGetLocalNamedExportCompletionSymbols() {
|
|
160489
160626
|
var _a;
|
|
160490
160627
|
const namedExports = contextToken && (contextToken.kind === 19 /* OpenBraceToken */ || contextToken.kind === 28 /* CommaToken */) ? tryCast(contextToken.parent, isNamedExports) : void 0;
|
|
@@ -166673,14 +166810,14 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
166673
166810
|
if (shouldRemove)
|
|
166674
166811
|
importGroup = removeUnusedImports(importGroup, sourceFile, program);
|
|
166675
166812
|
if (shouldCombine)
|
|
166676
|
-
importGroup = coalesceImportsWorker(importGroup, comparer, sourceFile);
|
|
166813
|
+
importGroup = coalesceImportsWorker(importGroup, comparer, sourceFile, preferences);
|
|
166677
166814
|
if (shouldSort)
|
|
166678
166815
|
importGroup = stableSort(importGroup, (s1, s2) => compareImportsOrRequireStatements(s1, s2, comparer));
|
|
166679
166816
|
return importGroup;
|
|
166680
166817
|
};
|
|
166681
166818
|
topLevelImportGroupDecls.forEach((importGroupDecl) => organizeImportsWorker(importGroupDecl, processImportsOfSameModuleSpecifier));
|
|
166682
166819
|
if (mode !== "RemoveUnused" /* RemoveUnused */) {
|
|
166683
|
-
getTopLevelExportGroups(sourceFile).forEach((exportGroupDecl) => organizeImportsWorker(exportGroupDecl, (group2) => coalesceExportsWorker(group2, comparer)));
|
|
166820
|
+
getTopLevelExportGroups(sourceFile).forEach((exportGroupDecl) => organizeImportsWorker(exportGroupDecl, (group2) => coalesceExportsWorker(group2, comparer, preferences)));
|
|
166684
166821
|
}
|
|
166685
166822
|
for (const ambientModule of sourceFile.statements.filter(isAmbientModule)) {
|
|
166686
166823
|
if (!ambientModule.body)
|
|
@@ -166689,7 +166826,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
166689
166826
|
ambientModuleImportGroupDecls.forEach((importGroupDecl) => organizeImportsWorker(importGroupDecl, processImportsOfSameModuleSpecifier));
|
|
166690
166827
|
if (mode !== "RemoveUnused" /* RemoveUnused */) {
|
|
166691
166828
|
const ambientModuleExportDecls = ambientModule.body.statements.filter(isExportDeclaration);
|
|
166692
|
-
organizeImportsWorker(ambientModuleExportDecls, (group2) => coalesceExportsWorker(group2, comparer));
|
|
166829
|
+
organizeImportsWorker(ambientModuleExportDecls, (group2) => coalesceExportsWorker(group2, comparer, preferences));
|
|
166693
166830
|
}
|
|
166694
166831
|
}
|
|
166695
166832
|
return changeTracker.getChanges();
|
|
@@ -166821,11 +166958,11 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
166821
166958
|
function getExternalModuleName2(specifier) {
|
|
166822
166959
|
return specifier !== void 0 && isStringLiteralLike(specifier) ? specifier.text : void 0;
|
|
166823
166960
|
}
|
|
166824
|
-
function coalesceImports(importGroup, ignoreCase, sourceFile) {
|
|
166961
|
+
function coalesceImports(importGroup, ignoreCase, sourceFile, preferences) {
|
|
166825
166962
|
const comparer = getOrganizeImportsOrdinalStringComparer(ignoreCase);
|
|
166826
|
-
return coalesceImportsWorker(importGroup, comparer, sourceFile);
|
|
166963
|
+
return coalesceImportsWorker(importGroup, comparer, sourceFile, preferences);
|
|
166827
166964
|
}
|
|
166828
|
-
function coalesceImportsWorker(importGroup, comparer, sourceFile) {
|
|
166965
|
+
function coalesceImportsWorker(importGroup, comparer, sourceFile, preferences) {
|
|
166829
166966
|
if (importGroup.length === 0) {
|
|
166830
166967
|
return importGroup;
|
|
166831
166968
|
}
|
|
@@ -166879,7 +167016,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
166879
167016
|
}
|
|
166880
167017
|
newImportSpecifiers.push(...getNewImportSpecifiers(namedImports));
|
|
166881
167018
|
const sortedImportSpecifiers = factory.createNodeArray(
|
|
166882
|
-
sortSpecifiers(newImportSpecifiers, comparer),
|
|
167019
|
+
sortSpecifiers(newImportSpecifiers, comparer, preferences),
|
|
166883
167020
|
firstNamedImport == null ? void 0 : firstNamedImport.importClause.namedBindings.elements.hasTrailingComma
|
|
166884
167021
|
);
|
|
166885
167022
|
const newNamedImports = sortedImportSpecifiers.length === 0 ? newDefaultImport ? void 0 : factory.createNamedImports(emptyArray) : firstNamedImport ? factory.updateNamedImports(firstNamedImport.importClause.namedBindings, sortedImportSpecifiers) : factory.createNamedImports(sortedImportSpecifiers);
|
|
@@ -166939,11 +167076,11 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
166939
167076
|
regularImports
|
|
166940
167077
|
};
|
|
166941
167078
|
}
|
|
166942
|
-
function coalesceExports(exportGroup, ignoreCase) {
|
|
167079
|
+
function coalesceExports(exportGroup, ignoreCase, preferences) {
|
|
166943
167080
|
const comparer = getOrganizeImportsOrdinalStringComparer(ignoreCase);
|
|
166944
|
-
return coalesceExportsWorker(exportGroup, comparer);
|
|
167081
|
+
return coalesceExportsWorker(exportGroup, comparer, preferences);
|
|
166945
167082
|
}
|
|
166946
|
-
function coalesceExportsWorker(exportGroup, comparer) {
|
|
167083
|
+
function coalesceExportsWorker(exportGroup, comparer, preferences) {
|
|
166947
167084
|
if (exportGroup.length === 0) {
|
|
166948
167085
|
return exportGroup;
|
|
166949
167086
|
}
|
|
@@ -166958,7 +167095,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
166958
167095
|
}
|
|
166959
167096
|
const newExportSpecifiers = [];
|
|
166960
167097
|
newExportSpecifiers.push(...flatMap(exportGroup2, (i) => i.exportClause && isNamedExports(i.exportClause) ? i.exportClause.elements : emptyArray));
|
|
166961
|
-
const sortedExportSpecifiers = sortSpecifiers(newExportSpecifiers, comparer);
|
|
167098
|
+
const sortedExportSpecifiers = sortSpecifiers(newExportSpecifiers, comparer, preferences);
|
|
166962
167099
|
const exportDecl = exportGroup2[0];
|
|
166963
167100
|
coalescedExports.push(
|
|
166964
167101
|
factory.updateExportDeclaration(
|
|
@@ -167002,11 +167139,18 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
167002
167139
|
importDeclaration.attributes
|
|
167003
167140
|
);
|
|
167004
167141
|
}
|
|
167005
|
-
function sortSpecifiers(specifiers, comparer) {
|
|
167006
|
-
return stableSort(specifiers, (s1, s2) => compareImportOrExportSpecifiers(s1, s2, comparer));
|
|
167142
|
+
function sortSpecifiers(specifiers, comparer, preferences) {
|
|
167143
|
+
return stableSort(specifiers, (s1, s2) => compareImportOrExportSpecifiers(s1, s2, comparer, preferences));
|
|
167007
167144
|
}
|
|
167008
|
-
function compareImportOrExportSpecifiers(s1, s2, comparer) {
|
|
167009
|
-
|
|
167145
|
+
function compareImportOrExportSpecifiers(s1, s2, comparer, preferences) {
|
|
167146
|
+
switch (preferences == null ? void 0 : preferences.organizeImportsTypeOrder) {
|
|
167147
|
+
case "first":
|
|
167148
|
+
return compareBooleans(s2.isTypeOnly, s1.isTypeOnly) || comparer(s1.name.text, s2.name.text);
|
|
167149
|
+
case "inline":
|
|
167150
|
+
return comparer(s1.name.text, s2.name.text);
|
|
167151
|
+
default:
|
|
167152
|
+
return compareBooleans(s1.isTypeOnly, s2.isTypeOnly) || comparer(s1.name.text, s2.name.text);
|
|
167153
|
+
}
|
|
167010
167154
|
}
|
|
167011
167155
|
function compareModuleSpecifiers2(m1, m2, ignoreCase) {
|
|
167012
167156
|
const comparer = getOrganizeImportsOrdinalStringComparer(!!ignoreCase);
|
|
@@ -167111,8 +167255,8 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
167111
167255
|
const index = binarySearch(sortedImports, newImport, identity, (a, b) => compareImportsOrRequireStatements(a, b, comparer));
|
|
167112
167256
|
return index < 0 ? ~index : index;
|
|
167113
167257
|
}
|
|
167114
|
-
function getImportSpecifierInsertionIndex(sortedImports, newImport, comparer) {
|
|
167115
|
-
const index = binarySearch(sortedImports, newImport, identity, (s1, s2) => compareImportOrExportSpecifiers(s1, s2, comparer));
|
|
167258
|
+
function getImportSpecifierInsertionIndex(sortedImports, newImport, comparer, preferences) {
|
|
167259
|
+
const index = binarySearch(sortedImports, newImport, identity, (s1, s2) => compareImportOrExportSpecifiers(s1, s2, comparer, preferences));
|
|
167116
167260
|
return index < 0 ? ~index : index;
|
|
167117
167261
|
}
|
|
167118
167262
|
function compareImportsOrRequireStatements(s1, s2, comparer) {
|
|
@@ -167241,8 +167385,26 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
167241
167385
|
}
|
|
167242
167386
|
};
|
|
167243
167387
|
detectImportSpecifierSorting = memoizeCached((specifiers, preferences) => {
|
|
167244
|
-
|
|
167245
|
-
|
|
167388
|
+
switch (preferences.organizeImportsTypeOrder) {
|
|
167389
|
+
case "first":
|
|
167390
|
+
if (!arrayIsSorted(specifiers, (s1, s2) => compareBooleans(s2.isTypeOnly, s1.isTypeOnly)))
|
|
167391
|
+
return 0 /* None */;
|
|
167392
|
+
break;
|
|
167393
|
+
case "inline":
|
|
167394
|
+
if (!arrayIsSorted(specifiers, (s1, s2) => {
|
|
167395
|
+
const comparer = getStringComparer(
|
|
167396
|
+
/*ignoreCase*/
|
|
167397
|
+
true
|
|
167398
|
+
);
|
|
167399
|
+
return comparer(s1.name.text, s2.name.text);
|
|
167400
|
+
})) {
|
|
167401
|
+
return 0 /* None */;
|
|
167402
|
+
}
|
|
167403
|
+
break;
|
|
167404
|
+
default:
|
|
167405
|
+
if (!arrayIsSorted(specifiers, (s1, s2) => compareBooleans(s1.isTypeOnly, s2.isTypeOnly)))
|
|
167406
|
+
return 0 /* None */;
|
|
167407
|
+
break;
|
|
167246
167408
|
}
|
|
167247
167409
|
const collateCaseSensitive = getOrganizeImportsComparer(
|
|
167248
167410
|
preferences,
|
|
@@ -167254,6 +167416,21 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
167254
167416
|
/*ignoreCase*/
|
|
167255
167417
|
true
|
|
167256
167418
|
);
|
|
167419
|
+
if (preferences.organizeImportsTypeOrder !== "inline") {
|
|
167420
|
+
const { type: regularImports, regular: typeImports } = groupBy(specifiers, (s) => s.isTypeOnly ? "type" : "regular");
|
|
167421
|
+
const regularCaseSensitivity = (regularImports == null ? void 0 : regularImports.length) ? detectSortCaseSensitivity(regularImports, (specifier) => specifier.name.text, collateCaseSensitive, collateCaseInsensitive) : void 0;
|
|
167422
|
+
const typeCaseSensitivity = (typeImports == null ? void 0 : typeImports.length) ? detectSortCaseSensitivity(typeImports, (specifier) => specifier.name.text ?? "", collateCaseSensitive, collateCaseInsensitive) : void 0;
|
|
167423
|
+
if (regularCaseSensitivity === void 0) {
|
|
167424
|
+
return typeCaseSensitivity ?? 0 /* None */;
|
|
167425
|
+
}
|
|
167426
|
+
if (typeCaseSensitivity === void 0) {
|
|
167427
|
+
return regularCaseSensitivity;
|
|
167428
|
+
}
|
|
167429
|
+
if (regularCaseSensitivity === 0 /* None */ || typeCaseSensitivity === 0 /* None */) {
|
|
167430
|
+
return 0 /* None */;
|
|
167431
|
+
}
|
|
167432
|
+
return typeCaseSensitivity & regularCaseSensitivity;
|
|
167433
|
+
}
|
|
167257
167434
|
return detectSortCaseSensitivity(specifiers, (specifier) => specifier.name.text, collateCaseSensitive, collateCaseInsensitive);
|
|
167258
167435
|
}, new ImportSpecifierSortingCache());
|
|
167259
167436
|
}
|
|
@@ -186337,6 +186514,7 @@ ${e.message}`;
|
|
|
186337
186514
|
getModuleSpecifierEndingPreference: () => getModuleSpecifierEndingPreference,
|
|
186338
186515
|
getModuleSpecifierResolverHost: () => getModuleSpecifierResolverHost,
|
|
186339
186516
|
getNameForExportedSymbol: () => getNameForExportedSymbol,
|
|
186517
|
+
getNameFromImportAttribute: () => getNameFromImportAttribute,
|
|
186340
186518
|
getNameFromIndexInfo: () => getNameFromIndexInfo,
|
|
186341
186519
|
getNameFromPropertyName: () => getNameFromPropertyName,
|
|
186342
186520
|
getNameOfAccessExpression: () => getNameOfAccessExpression,
|
|
@@ -188758,6 +188936,7 @@ ${e.message}`;
|
|
|
188758
188936
|
getModuleSpecifierEndingPreference: () => getModuleSpecifierEndingPreference,
|
|
188759
188937
|
getModuleSpecifierResolverHost: () => getModuleSpecifierResolverHost,
|
|
188760
188938
|
getNameForExportedSymbol: () => getNameForExportedSymbol,
|
|
188939
|
+
getNameFromImportAttribute: () => getNameFromImportAttribute,
|
|
188761
188940
|
getNameFromIndexInfo: () => getNameFromIndexInfo,
|
|
188762
188941
|
getNameFromPropertyName: () => getNameFromPropertyName,
|
|
188763
188942
|
getNameOfAccessExpression: () => getNameOfAccessExpression,
|