@typescript-deploys/pr-build 5.9.0-pr-61359-4 → 5.9.0-pr-61535-10
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 +784 -596
- package/lib/typescript.d.ts +12 -0
- package/lib/typescript.js +975 -714
- package/package.json +1 -1
package/lib/typescript.js
CHANGED
|
@@ -2285,7 +2285,7 @@ module.exports = __toCommonJS(typescript_exports);
|
|
|
2285
2285
|
|
|
2286
2286
|
// src/compiler/corePublic.ts
|
|
2287
2287
|
var versionMajorMinor = "5.9";
|
|
2288
|
-
var version = `${versionMajorMinor}.0-insiders.
|
|
2288
|
+
var version = `${versionMajorMinor}.0-insiders.20250416`;
|
|
2289
2289
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2290
2290
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2291
2291
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -6538,7 +6538,6 @@ var ObjectFlags = /* @__PURE__ */ ((ObjectFlags3) => {
|
|
|
6538
6538
|
ObjectFlags3[ObjectFlags3["IsGenericObjectType"] = 4194304] = "IsGenericObjectType";
|
|
6539
6539
|
ObjectFlags3[ObjectFlags3["IsGenericIndexType"] = 8388608] = "IsGenericIndexType";
|
|
6540
6540
|
ObjectFlags3[ObjectFlags3["IsGenericType"] = 12582912] = "IsGenericType";
|
|
6541
|
-
ObjectFlags3[ObjectFlags3["IsNarrowingType"] = 16777216] = "IsNarrowingType";
|
|
6542
6541
|
ObjectFlags3[ObjectFlags3["ContainsIntersections"] = 16777216] = "ContainsIntersections";
|
|
6543
6542
|
ObjectFlags3[ObjectFlags3["IsUnknownLikeUnionComputed"] = 33554432] = "IsUnknownLikeUnionComputed";
|
|
6544
6543
|
ObjectFlags3[ObjectFlags3["IsUnknownLikeUnion"] = 67108864] = "IsUnknownLikeUnion";
|
|
@@ -24110,6 +24109,82 @@ function getOptionsSyntaxByValue(optionsObject, name, value) {
|
|
|
24110
24109
|
function forEachOptionsSyntaxByName(optionsObject, name, callback) {
|
|
24111
24110
|
return forEachPropertyAssignment(optionsObject, name, callback);
|
|
24112
24111
|
}
|
|
24112
|
+
function getSynthesizedDeepClone(node, includeTrivia = true) {
|
|
24113
|
+
const clone2 = node && getSynthesizedDeepCloneWorker(node);
|
|
24114
|
+
if (clone2 && !includeTrivia) suppressLeadingAndTrailingTrivia(clone2);
|
|
24115
|
+
return setParentRecursive(
|
|
24116
|
+
clone2,
|
|
24117
|
+
/*incremental*/
|
|
24118
|
+
false
|
|
24119
|
+
);
|
|
24120
|
+
}
|
|
24121
|
+
function getSynthesizedDeepCloneWithReplacements(node, includeTrivia, replaceNode) {
|
|
24122
|
+
let clone2 = replaceNode(node);
|
|
24123
|
+
if (clone2) {
|
|
24124
|
+
setOriginalNode(clone2, node);
|
|
24125
|
+
} else {
|
|
24126
|
+
clone2 = getSynthesizedDeepCloneWorker(node, replaceNode);
|
|
24127
|
+
}
|
|
24128
|
+
if (clone2 && !includeTrivia) suppressLeadingAndTrailingTrivia(clone2);
|
|
24129
|
+
return clone2;
|
|
24130
|
+
}
|
|
24131
|
+
function getSynthesizedDeepCloneWorker(node, replaceNode) {
|
|
24132
|
+
const nodeClone = replaceNode ? (n) => getSynthesizedDeepCloneWithReplacements(
|
|
24133
|
+
n,
|
|
24134
|
+
/*includeTrivia*/
|
|
24135
|
+
true,
|
|
24136
|
+
replaceNode
|
|
24137
|
+
) : getSynthesizedDeepClone;
|
|
24138
|
+
const nodesClone = replaceNode ? (ns) => ns && getSynthesizedDeepClonesWithReplacements(
|
|
24139
|
+
ns,
|
|
24140
|
+
/*includeTrivia*/
|
|
24141
|
+
true,
|
|
24142
|
+
replaceNode
|
|
24143
|
+
) : (ns) => ns && getSynthesizedDeepClones(ns);
|
|
24144
|
+
const visited = visitEachChild(
|
|
24145
|
+
node,
|
|
24146
|
+
nodeClone,
|
|
24147
|
+
/*context*/
|
|
24148
|
+
void 0,
|
|
24149
|
+
nodesClone,
|
|
24150
|
+
nodeClone
|
|
24151
|
+
);
|
|
24152
|
+
if (visited === node) {
|
|
24153
|
+
const clone2 = isStringLiteral(node) ? setOriginalNode(factory.createStringLiteralFromNode(node), node) : isNumericLiteral(node) ? setOriginalNode(factory.createNumericLiteral(node.text, node.numericLiteralFlags), node) : factory.cloneNode(node);
|
|
24154
|
+
return setTextRange(clone2, node);
|
|
24155
|
+
}
|
|
24156
|
+
visited.parent = void 0;
|
|
24157
|
+
return visited;
|
|
24158
|
+
}
|
|
24159
|
+
function getSynthesizedDeepClones(nodes, includeTrivia = true) {
|
|
24160
|
+
if (nodes) {
|
|
24161
|
+
const cloned = factory.createNodeArray(nodes.map((n) => getSynthesizedDeepClone(n, includeTrivia)), nodes.hasTrailingComma);
|
|
24162
|
+
setTextRange(cloned, nodes);
|
|
24163
|
+
return cloned;
|
|
24164
|
+
}
|
|
24165
|
+
return nodes;
|
|
24166
|
+
}
|
|
24167
|
+
function getSynthesizedDeepClonesWithReplacements(nodes, includeTrivia, replaceNode) {
|
|
24168
|
+
return factory.createNodeArray(nodes.map((n) => getSynthesizedDeepCloneWithReplacements(n, includeTrivia, replaceNode)), nodes.hasTrailingComma);
|
|
24169
|
+
}
|
|
24170
|
+
function suppressLeadingAndTrailingTrivia(node) {
|
|
24171
|
+
suppressLeadingTrivia(node);
|
|
24172
|
+
suppressTrailingTrivia(node);
|
|
24173
|
+
}
|
|
24174
|
+
function suppressLeadingTrivia(node) {
|
|
24175
|
+
addEmitFlagsRecursively(node, 1024 /* NoLeadingComments */, getFirstChild);
|
|
24176
|
+
}
|
|
24177
|
+
function suppressTrailingTrivia(node) {
|
|
24178
|
+
addEmitFlagsRecursively(node, 2048 /* NoTrailingComments */, getLastChild);
|
|
24179
|
+
}
|
|
24180
|
+
function addEmitFlagsRecursively(node, flag, getChild) {
|
|
24181
|
+
addEmitFlags(node, flag);
|
|
24182
|
+
const child = getChild(node);
|
|
24183
|
+
if (child) addEmitFlagsRecursively(child, flag, getChild);
|
|
24184
|
+
}
|
|
24185
|
+
function getFirstChild(node) {
|
|
24186
|
+
return forEachChild(node, (child) => child);
|
|
24187
|
+
}
|
|
24113
24188
|
|
|
24114
24189
|
// src/compiler/factory/baseNodeFactory.ts
|
|
24115
24190
|
function createBaseNodeFactory() {
|
|
@@ -50987,11 +51062,11 @@ function createTypeChecker(host) {
|
|
|
50987
51062
|
typePredicateToString: (predicate, enclosingDeclaration, flags) => {
|
|
50988
51063
|
return typePredicateToString(predicate, getParseTreeNode(enclosingDeclaration), flags);
|
|
50989
51064
|
},
|
|
50990
|
-
writeSignature: (signature, enclosingDeclaration, flags, kind, writer) => {
|
|
50991
|
-
return signatureToString(signature, getParseTreeNode(enclosingDeclaration), flags, kind, writer);
|
|
51065
|
+
writeSignature: (signature, enclosingDeclaration, flags, kind, writer, verbosityLevel, out) => {
|
|
51066
|
+
return signatureToString(signature, getParseTreeNode(enclosingDeclaration), flags, kind, writer, verbosityLevel, out);
|
|
50992
51067
|
},
|
|
50993
|
-
writeType: (type, enclosingDeclaration, flags, writer) => {
|
|
50994
|
-
return typeToString(type, getParseTreeNode(enclosingDeclaration), flags, writer);
|
|
51068
|
+
writeType: (type, enclosingDeclaration, flags, writer, verbosityLevel, out) => {
|
|
51069
|
+
return typeToString(type, getParseTreeNode(enclosingDeclaration), flags, writer, verbosityLevel, out);
|
|
50995
51070
|
},
|
|
50996
51071
|
writeSymbol: (symbol, enclosingDeclaration, meaning, flags, writer) => {
|
|
50997
51072
|
return symbolToString(symbol, getParseTreeNode(enclosingDeclaration), meaning, flags, writer);
|
|
@@ -51225,7 +51300,8 @@ function createTypeChecker(host) {
|
|
|
51225
51300
|
isTypeParameterPossiblyReferenced,
|
|
51226
51301
|
typeHasCallOrConstructSignatures,
|
|
51227
51302
|
getSymbolFlags,
|
|
51228
|
-
getTypeArgumentsForResolvedSignature
|
|
51303
|
+
getTypeArgumentsForResolvedSignature,
|
|
51304
|
+
isLibType
|
|
51229
51305
|
};
|
|
51230
51306
|
function getTypeArgumentsForResolvedSignature(signature) {
|
|
51231
51307
|
if (signature.mapper === void 0) return void 0;
|
|
@@ -51737,6 +51813,9 @@ function createTypeChecker(host) {
|
|
|
51737
51813
|
var inferenceContextNodes = [];
|
|
51738
51814
|
var inferenceContexts = [];
|
|
51739
51815
|
var inferenceContextCount = 0;
|
|
51816
|
+
var activeTypeMappers = [];
|
|
51817
|
+
var activeTypeMappersCaches = [];
|
|
51818
|
+
var activeTypeMappersCount = 0;
|
|
51740
51819
|
var emptyStringType = getStringLiteralType("");
|
|
51741
51820
|
var zeroType = getNumberLiteralType(0);
|
|
51742
51821
|
var zeroBigIntType = getBigIntLiteralType({ negative: false, base10Value: "0" });
|
|
@@ -51789,7 +51868,6 @@ function createTypeChecker(host) {
|
|
|
51789
51868
|
[".jsx", ".jsx"],
|
|
51790
51869
|
[".json", ".json"]
|
|
51791
51870
|
];
|
|
51792
|
-
var narrowableReturnTypeCache = /* @__PURE__ */ new Map();
|
|
51793
51871
|
initializeTypeChecker();
|
|
51794
51872
|
return checker;
|
|
51795
51873
|
function isDefinitelyReferenceToGlobalSymbolObject(node) {
|
|
@@ -54903,7 +54981,7 @@ function createTypeChecker(host) {
|
|
|
54903
54981
|
return writer2;
|
|
54904
54982
|
}
|
|
54905
54983
|
}
|
|
54906
|
-
function signatureToString(signature, enclosingDeclaration, flags = 0 /* None */, kind, writer) {
|
|
54984
|
+
function signatureToString(signature, enclosingDeclaration, flags = 0 /* None */, kind, writer, verbosityLevel, out) {
|
|
54907
54985
|
return writer ? signatureToStringWorker(writer).getText() : usingSingleLineStringWriter(signatureToStringWorker);
|
|
54908
54986
|
function signatureToStringWorker(writer2) {
|
|
54909
54987
|
let sigOutput;
|
|
@@ -54912,7 +54990,18 @@ function createTypeChecker(host) {
|
|
|
54912
54990
|
} else {
|
|
54913
54991
|
sigOutput = kind === 1 /* Construct */ ? 180 /* ConstructSignature */ : 179 /* CallSignature */;
|
|
54914
54992
|
}
|
|
54915
|
-
const sig = nodeBuilder.signatureToSignatureDeclaration(
|
|
54993
|
+
const sig = nodeBuilder.signatureToSignatureDeclaration(
|
|
54994
|
+
signature,
|
|
54995
|
+
sigOutput,
|
|
54996
|
+
enclosingDeclaration,
|
|
54997
|
+
toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */,
|
|
54998
|
+
/*internalFlags*/
|
|
54999
|
+
void 0,
|
|
55000
|
+
/*tracker*/
|
|
55001
|
+
void 0,
|
|
55002
|
+
verbosityLevel,
|
|
55003
|
+
out
|
|
55004
|
+
);
|
|
54916
55005
|
const printer = createPrinterWithRemoveCommentsOmitTrailingSemicolon();
|
|
54917
55006
|
const sourceFile = enclosingDeclaration && getSourceFileOfNode(enclosingDeclaration);
|
|
54918
55007
|
printer.writeNode(
|
|
@@ -54925,14 +55014,18 @@ function createTypeChecker(host) {
|
|
|
54925
55014
|
return writer2;
|
|
54926
55015
|
}
|
|
54927
55016
|
}
|
|
54928
|
-
function typeToString(type, enclosingDeclaration, flags = 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */, writer = createTextWriter("")) {
|
|
55017
|
+
function typeToString(type, enclosingDeclaration, flags = 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */, writer = createTextWriter(""), verbosityLevel, out) {
|
|
54929
55018
|
const noTruncation = compilerOptions.noErrorTruncation || flags & 1 /* NoTruncation */;
|
|
54930
55019
|
const typeNode = nodeBuilder.typeToTypeNode(
|
|
54931
55020
|
type,
|
|
54932
55021
|
enclosingDeclaration,
|
|
54933
|
-
toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | (noTruncation ? 1 /* NoTruncation */ : 0
|
|
55022
|
+
toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | (noTruncation ? 1 /* NoTruncation */ : 0),
|
|
54934
55023
|
/*internalFlags*/
|
|
54935
|
-
void 0
|
|
55024
|
+
void 0,
|
|
55025
|
+
/*tracker*/
|
|
55026
|
+
void 0,
|
|
55027
|
+
verbosityLevel,
|
|
55028
|
+
out
|
|
54936
55029
|
);
|
|
54937
55030
|
if (typeNode === void 0) return Debug.fail("should always get typenode");
|
|
54938
55031
|
const printer = type !== unresolvedType ? createPrinterWithRemoveComments() : createPrinterWithDefaults();
|
|
@@ -55011,7 +55104,6 @@ function createTypeChecker(host) {
|
|
|
55011
55104
|
},
|
|
55012
55105
|
isOptionalParameter,
|
|
55013
55106
|
isUndefinedIdentifierExpression(node) {
|
|
55014
|
-
Debug.assert(isExpressionNode(node));
|
|
55015
55107
|
return getSymbolAtLocation(node) === undefinedSymbol;
|
|
55016
55108
|
},
|
|
55017
55109
|
isEntityNameVisible(context, entityName, shouldComputeAliasToMakeVisible) {
|
|
@@ -55163,31 +55255,120 @@ function createTypeChecker(host) {
|
|
|
55163
55255
|
};
|
|
55164
55256
|
return {
|
|
55165
55257
|
syntacticBuilderResolver,
|
|
55166
|
-
typeToTypeNode: (type, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(enclosingDeclaration, flags, internalFlags, tracker, (context) => typeToTypeNodeHelper(type, context)),
|
|
55167
|
-
typePredicateToTypePredicateNode: (typePredicate, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(
|
|
55168
|
-
|
|
55169
|
-
|
|
55170
|
-
|
|
55171
|
-
|
|
55172
|
-
|
|
55173
|
-
|
|
55174
|
-
|
|
55175
|
-
|
|
55176
|
-
)
|
|
55177
|
-
|
|
55178
|
-
|
|
55179
|
-
|
|
55180
|
-
|
|
55181
|
-
|
|
55182
|
-
|
|
55183
|
-
|
|
55184
|
-
)
|
|
55185
|
-
|
|
55186
|
-
|
|
55187
|
-
|
|
55188
|
-
|
|
55189
|
-
|
|
55190
|
-
|
|
55258
|
+
typeToTypeNode: (type, enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, out) => withContext2(enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, (context) => typeToTypeNodeHelper(type, context), out),
|
|
55259
|
+
typePredicateToTypePredicateNode: (typePredicate, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(
|
|
55260
|
+
enclosingDeclaration,
|
|
55261
|
+
flags,
|
|
55262
|
+
internalFlags,
|
|
55263
|
+
tracker,
|
|
55264
|
+
/*verbosityLevel*/
|
|
55265
|
+
void 0,
|
|
55266
|
+
(context) => typePredicateToTypePredicateNodeHelper(typePredicate, context)
|
|
55267
|
+
),
|
|
55268
|
+
serializeTypeForDeclaration: (declaration, symbol, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(
|
|
55269
|
+
enclosingDeclaration,
|
|
55270
|
+
flags,
|
|
55271
|
+
internalFlags,
|
|
55272
|
+
tracker,
|
|
55273
|
+
/*verbosityLevel*/
|
|
55274
|
+
void 0,
|
|
55275
|
+
(context) => syntacticNodeBuilder.serializeTypeOfDeclaration(declaration, symbol, context)
|
|
55276
|
+
),
|
|
55277
|
+
serializeReturnTypeForSignature: (signature, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(
|
|
55278
|
+
enclosingDeclaration,
|
|
55279
|
+
flags,
|
|
55280
|
+
internalFlags,
|
|
55281
|
+
tracker,
|
|
55282
|
+
/*verbosityLevel*/
|
|
55283
|
+
void 0,
|
|
55284
|
+
(context) => syntacticNodeBuilder.serializeReturnTypeForSignature(signature, getSymbolOfDeclaration(signature), context)
|
|
55285
|
+
),
|
|
55286
|
+
serializeTypeForExpression: (expr, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(
|
|
55287
|
+
enclosingDeclaration,
|
|
55288
|
+
flags,
|
|
55289
|
+
internalFlags,
|
|
55290
|
+
tracker,
|
|
55291
|
+
/*verbosityLevel*/
|
|
55292
|
+
void 0,
|
|
55293
|
+
(context) => syntacticNodeBuilder.serializeTypeOfExpression(expr, context)
|
|
55294
|
+
),
|
|
55295
|
+
indexInfoToIndexSignatureDeclaration: (indexInfo, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(
|
|
55296
|
+
enclosingDeclaration,
|
|
55297
|
+
flags,
|
|
55298
|
+
internalFlags,
|
|
55299
|
+
tracker,
|
|
55300
|
+
/*verbosityLevel*/
|
|
55301
|
+
void 0,
|
|
55302
|
+
(context) => indexInfoToIndexSignatureDeclarationHelper(
|
|
55303
|
+
indexInfo,
|
|
55304
|
+
context,
|
|
55305
|
+
/*typeNode*/
|
|
55306
|
+
void 0
|
|
55307
|
+
)
|
|
55308
|
+
),
|
|
55309
|
+
signatureToSignatureDeclaration: (signature, kind, enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, out) => withContext2(enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, (context) => signatureToSignatureDeclarationHelper(signature, kind, context), out),
|
|
55310
|
+
symbolToEntityName: (symbol, meaning, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(
|
|
55311
|
+
enclosingDeclaration,
|
|
55312
|
+
flags,
|
|
55313
|
+
internalFlags,
|
|
55314
|
+
tracker,
|
|
55315
|
+
/*verbosityLevel*/
|
|
55316
|
+
void 0,
|
|
55317
|
+
(context) => symbolToName(
|
|
55318
|
+
symbol,
|
|
55319
|
+
context,
|
|
55320
|
+
meaning,
|
|
55321
|
+
/*expectsIdentifier*/
|
|
55322
|
+
false
|
|
55323
|
+
)
|
|
55324
|
+
),
|
|
55325
|
+
symbolToExpression: (symbol, meaning, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(
|
|
55326
|
+
enclosingDeclaration,
|
|
55327
|
+
flags,
|
|
55328
|
+
internalFlags,
|
|
55329
|
+
tracker,
|
|
55330
|
+
/*verbosityLevel*/
|
|
55331
|
+
void 0,
|
|
55332
|
+
(context) => symbolToExpression(symbol, context, meaning)
|
|
55333
|
+
),
|
|
55334
|
+
symbolToTypeParameterDeclarations: (symbol, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(
|
|
55335
|
+
enclosingDeclaration,
|
|
55336
|
+
flags,
|
|
55337
|
+
internalFlags,
|
|
55338
|
+
tracker,
|
|
55339
|
+
/*verbosityLevel*/
|
|
55340
|
+
void 0,
|
|
55341
|
+
(context) => typeParametersToTypeParameterDeclarations(symbol, context)
|
|
55342
|
+
),
|
|
55343
|
+
symbolToParameterDeclaration: (symbol, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(
|
|
55344
|
+
enclosingDeclaration,
|
|
55345
|
+
flags,
|
|
55346
|
+
internalFlags,
|
|
55347
|
+
tracker,
|
|
55348
|
+
/*verbosityLevel*/
|
|
55349
|
+
void 0,
|
|
55350
|
+
(context) => symbolToParameterDeclaration(symbol, context)
|
|
55351
|
+
),
|
|
55352
|
+
typeParameterToDeclaration: (parameter, enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, out) => withContext2(enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, (context) => typeParameterToDeclaration(parameter, context), out),
|
|
55353
|
+
symbolTableToDeclarationStatements: (symbolTable, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(
|
|
55354
|
+
enclosingDeclaration,
|
|
55355
|
+
flags,
|
|
55356
|
+
internalFlags,
|
|
55357
|
+
tracker,
|
|
55358
|
+
/*verbosityLevel*/
|
|
55359
|
+
void 0,
|
|
55360
|
+
(context) => symbolTableToDeclarationStatements(symbolTable, context)
|
|
55361
|
+
),
|
|
55362
|
+
symbolToNode: (symbol, meaning, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(
|
|
55363
|
+
enclosingDeclaration,
|
|
55364
|
+
flags,
|
|
55365
|
+
internalFlags,
|
|
55366
|
+
tracker,
|
|
55367
|
+
/*verbosityLevel*/
|
|
55368
|
+
void 0,
|
|
55369
|
+
(context) => symbolToNode(symbol, context, meaning)
|
|
55370
|
+
),
|
|
55371
|
+
symbolToDeclarations
|
|
55191
55372
|
};
|
|
55192
55373
|
function getTypeFromTypeNode2(context, node, noMappedTypes) {
|
|
55193
55374
|
const type = getTypeFromTypeNodeWithoutContext(node);
|
|
@@ -55229,7 +55410,75 @@ function createTypeChecker(host) {
|
|
|
55229
55410
|
}
|
|
55230
55411
|
return symbolToExpression(symbol, context, meaning);
|
|
55231
55412
|
}
|
|
55232
|
-
function
|
|
55413
|
+
function symbolToDeclarations(symbol, meaning, flags, verbosityLevel, out) {
|
|
55414
|
+
const nodes = withContext2(
|
|
55415
|
+
/*enclosingDeclaration*/
|
|
55416
|
+
void 0,
|
|
55417
|
+
flags,
|
|
55418
|
+
/*internalFlags*/
|
|
55419
|
+
void 0,
|
|
55420
|
+
/*tracker*/
|
|
55421
|
+
void 0,
|
|
55422
|
+
verbosityLevel,
|
|
55423
|
+
(context) => symbolToDeclarationsWorker(symbol, context),
|
|
55424
|
+
out
|
|
55425
|
+
);
|
|
55426
|
+
return mapDefined(nodes, (node) => {
|
|
55427
|
+
switch (node.kind) {
|
|
55428
|
+
case 263 /* ClassDeclaration */:
|
|
55429
|
+
return simplifyClassDeclaration(node, symbol);
|
|
55430
|
+
case 266 /* EnumDeclaration */:
|
|
55431
|
+
return simplifyModifiers(node, isEnumDeclaration, symbol);
|
|
55432
|
+
case 264 /* InterfaceDeclaration */:
|
|
55433
|
+
return simplifyInterfaceDeclaration(node, symbol, meaning);
|
|
55434
|
+
case 267 /* ModuleDeclaration */:
|
|
55435
|
+
return simplifyModifiers(node, isModuleDeclaration, symbol);
|
|
55436
|
+
default:
|
|
55437
|
+
return void 0;
|
|
55438
|
+
}
|
|
55439
|
+
});
|
|
55440
|
+
}
|
|
55441
|
+
function simplifyClassDeclaration(classDecl, symbol) {
|
|
55442
|
+
const classDeclarations = filter(symbol.declarations, isClassLike);
|
|
55443
|
+
const originalClassDecl = classDeclarations && classDeclarations.length > 0 ? classDeclarations[0] : classDecl;
|
|
55444
|
+
const modifiers = getEffectiveModifierFlags(originalClassDecl) & ~(32 /* Export */ | 128 /* Ambient */);
|
|
55445
|
+
const isAnonymous = isClassExpression(originalClassDecl);
|
|
55446
|
+
if (isAnonymous) {
|
|
55447
|
+
classDecl = factory.updateClassDeclaration(
|
|
55448
|
+
classDecl,
|
|
55449
|
+
classDecl.modifiers,
|
|
55450
|
+
/*name*/
|
|
55451
|
+
void 0,
|
|
55452
|
+
classDecl.typeParameters,
|
|
55453
|
+
classDecl.heritageClauses,
|
|
55454
|
+
classDecl.members
|
|
55455
|
+
);
|
|
55456
|
+
}
|
|
55457
|
+
return factory.replaceModifiers(classDecl, modifiers);
|
|
55458
|
+
}
|
|
55459
|
+
function simplifyModifiers(newDecl, isDeclKind, symbol) {
|
|
55460
|
+
const decls = filter(symbol.declarations, isDeclKind);
|
|
55461
|
+
const declWithModifiers = decls && decls.length > 0 ? decls[0] : newDecl;
|
|
55462
|
+
const modifiers = getEffectiveModifierFlags(declWithModifiers) & ~(32 /* Export */ | 128 /* Ambient */);
|
|
55463
|
+
return factory.replaceModifiers(newDecl, modifiers);
|
|
55464
|
+
}
|
|
55465
|
+
function simplifyInterfaceDeclaration(interfaceDecl, symbol, meaning) {
|
|
55466
|
+
if (!(meaning & 64 /* Interface */)) {
|
|
55467
|
+
return void 0;
|
|
55468
|
+
}
|
|
55469
|
+
return simplifyModifiers(interfaceDecl, isInterfaceDeclaration, symbol);
|
|
55470
|
+
}
|
|
55471
|
+
function symbolToDeclarationsWorker(symbol, context) {
|
|
55472
|
+
const type = getDeclaredTypeOfSymbol(symbol);
|
|
55473
|
+
context.typeStack.push(type.id);
|
|
55474
|
+
context.typeStack.push(-1);
|
|
55475
|
+
const table = createSymbolTable([symbol]);
|
|
55476
|
+
const statements = symbolTableToDeclarationStatements(table, context);
|
|
55477
|
+
context.typeStack.pop();
|
|
55478
|
+
context.typeStack.pop();
|
|
55479
|
+
return statements;
|
|
55480
|
+
}
|
|
55481
|
+
function withContext2(enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, cb, out) {
|
|
55233
55482
|
const moduleResolverHost = (tracker == null ? void 0 : tracker.trackSymbol) ? tracker.moduleResolverHost : (internalFlags || 0 /* None */) & 4 /* DoNotIncludeSymbolChain */ ? createBasicNodeBuilderModuleSpecifierResolutionHost(host) : void 0;
|
|
55234
55483
|
const context = {
|
|
55235
55484
|
enclosingDeclaration,
|
|
@@ -55237,6 +55486,7 @@ function createTypeChecker(host) {
|
|
|
55237
55486
|
flags: flags || 0 /* None */,
|
|
55238
55487
|
internalFlags: internalFlags || 0 /* None */,
|
|
55239
55488
|
tracker: void 0,
|
|
55489
|
+
maxExpansionDepth: verbosityLevel ?? -1,
|
|
55240
55490
|
encounteredError: false,
|
|
55241
55491
|
suppressReportInferenceFallback: false,
|
|
55242
55492
|
reportedDiagnostic: false,
|
|
@@ -55258,13 +55508,23 @@ function createTypeChecker(host) {
|
|
|
55258
55508
|
typeParameterNamesByText: void 0,
|
|
55259
55509
|
typeParameterNamesByTextNextNameCount: void 0,
|
|
55260
55510
|
enclosingSymbolTypes: /* @__PURE__ */ new Map(),
|
|
55261
|
-
mapper: void 0
|
|
55511
|
+
mapper: void 0,
|
|
55512
|
+
depth: 0,
|
|
55513
|
+
typeStack: [],
|
|
55514
|
+
out: {
|
|
55515
|
+
canIncreaseExpansionDepth: false,
|
|
55516
|
+
truncated: false
|
|
55517
|
+
}
|
|
55262
55518
|
};
|
|
55263
55519
|
context.tracker = new SymbolTrackerImpl(context, tracker, moduleResolverHost);
|
|
55264
55520
|
const resultingNode = cb(context);
|
|
55265
55521
|
if (context.truncating && context.flags & 1 /* NoTruncation */) {
|
|
55266
55522
|
context.tracker.reportTruncationError();
|
|
55267
55523
|
}
|
|
55524
|
+
if (out) {
|
|
55525
|
+
out.canIncreaseExpansionDepth = context.out.canIncreaseExpansionDepth;
|
|
55526
|
+
out.truncated = context.out.truncated;
|
|
55527
|
+
}
|
|
55268
55528
|
return context.encounteredError ? void 0 : resultingNode;
|
|
55269
55529
|
}
|
|
55270
55530
|
function addSymbolTypeToContext(context, symbol, type) {
|
|
@@ -55283,19 +55543,49 @@ function createTypeChecker(host) {
|
|
|
55283
55543
|
function saveRestoreFlags(context) {
|
|
55284
55544
|
const flags = context.flags;
|
|
55285
55545
|
const internalFlags = context.internalFlags;
|
|
55546
|
+
const depth = context.depth;
|
|
55286
55547
|
return restore;
|
|
55287
55548
|
function restore() {
|
|
55288
55549
|
context.flags = flags;
|
|
55289
55550
|
context.internalFlags = internalFlags;
|
|
55551
|
+
context.depth = depth;
|
|
55290
55552
|
}
|
|
55291
55553
|
}
|
|
55554
|
+
function checkTruncationLengthIfExpanding(context) {
|
|
55555
|
+
return context.maxExpansionDepth >= 0 && checkTruncationLength(context);
|
|
55556
|
+
}
|
|
55292
55557
|
function checkTruncationLength(context) {
|
|
55293
55558
|
if (context.truncating) return context.truncating;
|
|
55294
55559
|
return context.truncating = context.approximateLength > (context.flags & 1 /* NoTruncation */ ? noTruncationMaximumTruncationLength : defaultMaximumTruncationLength);
|
|
55295
55560
|
}
|
|
55561
|
+
function canPossiblyExpandType(type, context) {
|
|
55562
|
+
for (let i = 0; i < context.typeStack.length - 1; i++) {
|
|
55563
|
+
if (context.typeStack[i] === type.id) {
|
|
55564
|
+
return false;
|
|
55565
|
+
}
|
|
55566
|
+
}
|
|
55567
|
+
return context.depth < context.maxExpansionDepth || context.depth === context.maxExpansionDepth && !context.out.canIncreaseExpansionDepth;
|
|
55568
|
+
}
|
|
55569
|
+
function shouldExpandType(type, context, isAlias = false) {
|
|
55570
|
+
if (!isAlias && isLibType(type)) {
|
|
55571
|
+
return false;
|
|
55572
|
+
}
|
|
55573
|
+
for (let i = 0; i < context.typeStack.length - 1; i++) {
|
|
55574
|
+
if (context.typeStack[i] === type.id) {
|
|
55575
|
+
return false;
|
|
55576
|
+
}
|
|
55577
|
+
}
|
|
55578
|
+
const result = context.depth < context.maxExpansionDepth;
|
|
55579
|
+
if (!result) {
|
|
55580
|
+
context.out.canIncreaseExpansionDepth = true;
|
|
55581
|
+
}
|
|
55582
|
+
return result;
|
|
55583
|
+
}
|
|
55296
55584
|
function typeToTypeNodeHelper(type, context) {
|
|
55297
55585
|
const restoreFlags = saveRestoreFlags(context);
|
|
55586
|
+
if (type) context.typeStack.push(type.id);
|
|
55298
55587
|
const typeNode = typeToTypeNodeWorker(type, context);
|
|
55588
|
+
if (type) context.typeStack.pop();
|
|
55299
55589
|
restoreFlags();
|
|
55300
55590
|
return typeNode;
|
|
55301
55591
|
}
|
|
@@ -55306,6 +55596,7 @@ function createTypeChecker(host) {
|
|
|
55306
55596
|
}
|
|
55307
55597
|
const inTypeAlias = context.flags & 8388608 /* InTypeAlias */;
|
|
55308
55598
|
context.flags &= ~8388608 /* InTypeAlias */;
|
|
55599
|
+
let expandingEnum = false;
|
|
55309
55600
|
if (!type) {
|
|
55310
55601
|
if (!(context.flags & 262144 /* AllowEmptyUnionOrIntersection */)) {
|
|
55311
55602
|
context.encounteredError = true;
|
|
@@ -55373,7 +55664,11 @@ function createTypeChecker(host) {
|
|
|
55373
55664
|
return Debug.fail("Unhandled type node kind returned from `symbolToTypeNode`.");
|
|
55374
55665
|
}
|
|
55375
55666
|
}
|
|
55376
|
-
|
|
55667
|
+
if (!shouldExpandType(type, context)) {
|
|
55668
|
+
return symbolToTypeNode(type.symbol, context, 788968 /* Type */);
|
|
55669
|
+
} else {
|
|
55670
|
+
expandingEnum = true;
|
|
55671
|
+
}
|
|
55377
55672
|
}
|
|
55378
55673
|
if (type.flags & 128 /* StringLiteral */) {
|
|
55379
55674
|
context.approximateLength += type.value.length + 2;
|
|
@@ -55440,16 +55735,34 @@ function createTypeChecker(host) {
|
|
|
55440
55735
|
return factory.createThisTypeNode();
|
|
55441
55736
|
}
|
|
55442
55737
|
if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) {
|
|
55443
|
-
|
|
55444
|
-
|
|
55445
|
-
|
|
55446
|
-
|
|
55738
|
+
if (!shouldExpandType(
|
|
55739
|
+
type,
|
|
55740
|
+
context,
|
|
55741
|
+
/*isAlias*/
|
|
55742
|
+
true
|
|
55743
|
+
)) {
|
|
55744
|
+
const typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context);
|
|
55745
|
+
if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) return factory.createTypeReferenceNode(factory.createIdentifier(""), typeArgumentNodes);
|
|
55746
|
+
if (length(typeArgumentNodes) === 1 && type.aliasSymbol === globalArrayType.symbol) {
|
|
55747
|
+
return factory.createArrayTypeNode(typeArgumentNodes[0]);
|
|
55748
|
+
}
|
|
55749
|
+
return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes);
|
|
55447
55750
|
}
|
|
55448
|
-
|
|
55751
|
+
context.depth += 1;
|
|
55449
55752
|
}
|
|
55450
55753
|
const objectFlags = getObjectFlags(type);
|
|
55451
55754
|
if (objectFlags & 4 /* Reference */) {
|
|
55452
55755
|
Debug.assert(!!(type.flags & 524288 /* Object */));
|
|
55756
|
+
if (shouldExpandType(type, context)) {
|
|
55757
|
+
context.depth += 1;
|
|
55758
|
+
return createAnonymousTypeNode(
|
|
55759
|
+
type,
|
|
55760
|
+
/*forceClassExpansion*/
|
|
55761
|
+
true,
|
|
55762
|
+
/*forceExpansion*/
|
|
55763
|
+
true
|
|
55764
|
+
);
|
|
55765
|
+
}
|
|
55453
55766
|
return type.node ? visitAndTransformType(type, typeReferenceToTypeNode) : typeReferenceToTypeNode(type);
|
|
55454
55767
|
}
|
|
55455
55768
|
if (type.flags & 262144 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) {
|
|
@@ -55479,6 +55792,16 @@ function createTypeChecker(host) {
|
|
|
55479
55792
|
void 0
|
|
55480
55793
|
);
|
|
55481
55794
|
}
|
|
55795
|
+
if (objectFlags & 3 /* ClassOrInterface */ && shouldExpandType(type, context)) {
|
|
55796
|
+
context.depth += 1;
|
|
55797
|
+
return createAnonymousTypeNode(
|
|
55798
|
+
type,
|
|
55799
|
+
/*forceClassExpansion*/
|
|
55800
|
+
true,
|
|
55801
|
+
/*forceExpansion*/
|
|
55802
|
+
true
|
|
55803
|
+
);
|
|
55804
|
+
}
|
|
55482
55805
|
if (type.symbol) {
|
|
55483
55806
|
return symbolToTypeNode(type.symbol, context, 788968 /* Type */);
|
|
55484
55807
|
}
|
|
@@ -55493,7 +55816,7 @@ function createTypeChecker(host) {
|
|
|
55493
55816
|
type = type.origin;
|
|
55494
55817
|
}
|
|
55495
55818
|
if (type.flags & (1048576 /* Union */ | 2097152 /* Intersection */)) {
|
|
55496
|
-
const types = type.flags & 1048576 /* Union */ ? formatUnionTypes(type.types) : type.types;
|
|
55819
|
+
const types = type.flags & 1048576 /* Union */ ? formatUnionTypes(type.types, expandingEnum) : type.types;
|
|
55497
55820
|
if (length(types) === 1) {
|
|
55498
55821
|
return typeToTypeNodeHelper(types[0], context);
|
|
55499
55822
|
}
|
|
@@ -55682,7 +56005,7 @@ function createTypeChecker(host) {
|
|
|
55682
56005
|
}
|
|
55683
56006
|
return result;
|
|
55684
56007
|
}
|
|
55685
|
-
function createAnonymousTypeNode(type2) {
|
|
56008
|
+
function createAnonymousTypeNode(type2, forceClassExpansion = false, forceExpansion = false) {
|
|
55686
56009
|
var _a2, _b2;
|
|
55687
56010
|
const typeId = type2.id;
|
|
55688
56011
|
const symbol = type2.symbol;
|
|
@@ -55705,15 +56028,20 @@ function createTypeChecker(host) {
|
|
|
55705
56028
|
const isInstanceType = isClassInstanceSide(type2) ? 788968 /* Type */ : 111551 /* Value */;
|
|
55706
56029
|
if (isJSConstructor(symbol.valueDeclaration)) {
|
|
55707
56030
|
return symbolToTypeNode(symbol, context, isInstanceType);
|
|
55708
|
-
} else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration && isClassLike(symbol.valueDeclaration) && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ && (!isClassDeclaration(symbol.valueDeclaration) || isSymbolAccessible(
|
|
56031
|
+
} else if (!forceExpansion && (symbol.flags & 32 /* Class */ && !forceClassExpansion && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration && isClassLike(symbol.valueDeclaration) && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ && (!isClassDeclaration(symbol.valueDeclaration) || isSymbolAccessible(
|
|
55709
56032
|
symbol,
|
|
55710
56033
|
context.enclosingDeclaration,
|
|
55711
56034
|
isInstanceType,
|
|
55712
56035
|
/*shouldComputeAliasesToMakeVisible*/
|
|
55713
56036
|
false
|
|
55714
|
-
).accessibility !== 0 /* Accessible */)) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) {
|
|
55715
|
-
|
|
55716
|
-
|
|
56037
|
+
).accessibility !== 0 /* Accessible */)) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol())) {
|
|
56038
|
+
if (shouldExpandType(type2, context)) {
|
|
56039
|
+
context.depth += 1;
|
|
56040
|
+
} else {
|
|
56041
|
+
return symbolToTypeNode(symbol, context, isInstanceType);
|
|
56042
|
+
}
|
|
56043
|
+
}
|
|
56044
|
+
if ((_b2 = context.visitedTypes) == null ? void 0 : _b2.has(typeId)) {
|
|
55717
56045
|
const typeAlias = getTypeAliasForTypeLiteral(type2);
|
|
55718
56046
|
if (typeAlias) {
|
|
55719
56047
|
return symbolToTypeNode(typeAlias, context, 788968 /* Type */);
|
|
@@ -55749,7 +56077,7 @@ function createTypeChecker(host) {
|
|
|
55749
56077
|
if (id && !context.symbolDepth) {
|
|
55750
56078
|
context.symbolDepth = /* @__PURE__ */ new Map();
|
|
55751
56079
|
}
|
|
55752
|
-
const links = context.enclosingDeclaration && getNodeLinks(context.enclosingDeclaration);
|
|
56080
|
+
const links = context.maxExpansionDepth >= 0 ? void 0 : context.enclosingDeclaration && getNodeLinks(context.enclosingDeclaration);
|
|
55753
56081
|
const key = `${getTypeId(type2)}|${context.flags}|${context.internalFlags}`;
|
|
55754
56082
|
if (links) {
|
|
55755
56083
|
links.serializedTypes || (links.serializedTypes = /* @__PURE__ */ new Map());
|
|
@@ -56066,6 +56394,7 @@ function createTypeChecker(host) {
|
|
|
56066
56394
|
}
|
|
56067
56395
|
function createTypeNodesFromResolvedType(resolvedType) {
|
|
56068
56396
|
if (checkTruncationLength(context)) {
|
|
56397
|
+
context.out.truncated = true;
|
|
56069
56398
|
if (context.flags & 1 /* NoTruncation */) {
|
|
56070
56399
|
return [addSyntheticTrailingComment(factory.createNotEmittedTypeElement(), 3 /* MultiLineCommentTrivia */, "elided")];
|
|
56071
56400
|
}
|
|
@@ -56079,6 +56408,7 @@ function createTypeChecker(host) {
|
|
|
56079
56408
|
void 0
|
|
56080
56409
|
)];
|
|
56081
56410
|
}
|
|
56411
|
+
context.typeStack.push(-1);
|
|
56082
56412
|
const typeElements = [];
|
|
56083
56413
|
for (const signature of resolvedType.callSignatures) {
|
|
56084
56414
|
typeElements.push(signatureToSignatureDeclarationHelper(signature, 179 /* CallSignature */, context));
|
|
@@ -56092,10 +56422,14 @@ function createTypeChecker(host) {
|
|
|
56092
56422
|
}
|
|
56093
56423
|
const properties = resolvedType.properties;
|
|
56094
56424
|
if (!properties) {
|
|
56425
|
+
context.typeStack.pop();
|
|
56095
56426
|
return typeElements;
|
|
56096
56427
|
}
|
|
56097
56428
|
let i = 0;
|
|
56098
56429
|
for (const propertySymbol of properties) {
|
|
56430
|
+
if (isExpanding(context) && propertySymbol.flags & 4194304 /* Prototype */) {
|
|
56431
|
+
continue;
|
|
56432
|
+
}
|
|
56099
56433
|
i++;
|
|
56100
56434
|
if (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) {
|
|
56101
56435
|
if (propertySymbol.flags & 4194304 /* Prototype */) {
|
|
@@ -56106,6 +56440,7 @@ function createTypeChecker(host) {
|
|
|
56106
56440
|
}
|
|
56107
56441
|
}
|
|
56108
56442
|
if (checkTruncationLength(context) && i + 2 < properties.length - 1) {
|
|
56443
|
+
context.out.truncated = true;
|
|
56109
56444
|
if (context.flags & 1 /* NoTruncation */) {
|
|
56110
56445
|
const typeElement = typeElements.pop();
|
|
56111
56446
|
typeElements.push(addSyntheticTrailingComment(typeElement, 3 /* MultiLineCommentTrivia */, `... ${properties.length - i} more elided ...`));
|
|
@@ -56125,6 +56460,7 @@ function createTypeChecker(host) {
|
|
|
56125
56460
|
}
|
|
56126
56461
|
addPropertyToElementList(propertySymbol, context, typeElements);
|
|
56127
56462
|
}
|
|
56463
|
+
context.typeStack.pop();
|
|
56128
56464
|
return typeElements.length ? typeElements : void 0;
|
|
56129
56465
|
}
|
|
56130
56466
|
}
|
|
@@ -56273,6 +56609,7 @@ function createTypeChecker(host) {
|
|
|
56273
56609
|
function mapToTypeNodes(types, context, isBareList) {
|
|
56274
56610
|
if (some(types)) {
|
|
56275
56611
|
if (checkTruncationLength(context)) {
|
|
56612
|
+
context.out.truncated = true;
|
|
56276
56613
|
if (!isBareList) {
|
|
56277
56614
|
return [
|
|
56278
56615
|
context.flags & 1 /* NoTruncation */ ? addSyntheticLeadingComment(factory.createKeywordTypeNode(133 /* AnyKeyword */), 3 /* MultiLineCommentTrivia */, "elided") : factory.createTypeReferenceNode(
|
|
@@ -56300,6 +56637,7 @@ function createTypeChecker(host) {
|
|
|
56300
56637
|
for (const type of types) {
|
|
56301
56638
|
i++;
|
|
56302
56639
|
if (checkTruncationLength(context) && i + 2 < types.length - 1) {
|
|
56640
|
+
context.out.truncated = true;
|
|
56303
56641
|
result.push(
|
|
56304
56642
|
context.flags & 1 /* NoTruncation */ ? addSyntheticLeadingComment(factory.createKeywordTypeNode(133 /* AnyKeyword */), 3 /* MultiLineCommentTrivia */, `... ${types.length - i} more elided ...`) : factory.createTypeReferenceNode(
|
|
56305
56643
|
`... ${types.length - i} more ...`,
|
|
@@ -56697,7 +57035,7 @@ function createTypeChecker(host) {
|
|
|
56697
57035
|
return factory.createTypeParameterDeclaration(modifiers, name, constraintNode, defaultParameterNode);
|
|
56698
57036
|
}
|
|
56699
57037
|
function typeToTypeNodeHelperWithPossibleReusableTypeNode(type, typeNode, context) {
|
|
56700
|
-
return typeNode && getTypeFromTypeNode2(context, typeNode) === type && syntacticNodeBuilder.tryReuseExistingTypeNode(context, typeNode) || typeToTypeNodeHelper(type, context);
|
|
57038
|
+
return !canPossiblyExpandType(type, context) && typeNode && getTypeFromTypeNode2(context, typeNode) === type && syntacticNodeBuilder.tryReuseExistingTypeNode(context, typeNode) || typeToTypeNodeHelper(type, context);
|
|
56701
57039
|
}
|
|
56702
57040
|
function typeParameterToDeclaration(type, context, constraint = getConstraintOfTypeParameter(type)) {
|
|
56703
57041
|
const constraintNode = constraint && typeToTypeNodeHelperWithPossibleReusableTypeNode(constraint, getConstraintDeclaration(type), context);
|
|
@@ -57216,12 +57554,15 @@ function createTypeChecker(host) {
|
|
|
57216
57554
|
}
|
|
57217
57555
|
let firstChar = symbolName2.charCodeAt(0);
|
|
57218
57556
|
if (isSingleOrDoubleQuote(firstChar) && some(symbol2.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
|
|
57219
|
-
|
|
57557
|
+
const specifier = getSpecifierForModuleSymbol(symbol2, context);
|
|
57558
|
+
context.approximateLength += 2 + specifier.length;
|
|
57559
|
+
return factory.createStringLiteral(specifier);
|
|
57220
57560
|
}
|
|
57221
57561
|
if (index === 0 || canUsePropertyAccess(symbolName2, languageVersion)) {
|
|
57222
57562
|
const identifier = setEmitFlags(factory.createIdentifier(symbolName2), 16777216 /* NoAsciiEscaping */);
|
|
57223
57563
|
if (typeParameterNodes) setIdentifierTypeArguments(identifier, factory.createNodeArray(typeParameterNodes));
|
|
57224
57564
|
identifier.symbol = symbol2;
|
|
57565
|
+
context.approximateLength += 1 + symbolName2.length;
|
|
57225
57566
|
return index > 0 ? factory.createPropertyAccessExpression(createExpressionFromSymbolChain(chain2, index - 1), identifier) : identifier;
|
|
57226
57567
|
} else {
|
|
57227
57568
|
if (firstChar === 91 /* openBracket */) {
|
|
@@ -57230,16 +57571,21 @@ function createTypeChecker(host) {
|
|
|
57230
57571
|
}
|
|
57231
57572
|
let expression;
|
|
57232
57573
|
if (isSingleOrDoubleQuote(firstChar) && !(symbol2.flags & 8 /* EnumMember */)) {
|
|
57233
|
-
|
|
57574
|
+
const literalText = stripQuotes(symbolName2).replace(/\\./g, (s) => s.substring(1));
|
|
57575
|
+
context.approximateLength += literalText.length + 2;
|
|
57576
|
+
expression = factory.createStringLiteral(literalText, firstChar === 39 /* singleQuote */);
|
|
57234
57577
|
} else if ("" + +symbolName2 === symbolName2) {
|
|
57578
|
+
context.approximateLength += symbolName2.length;
|
|
57235
57579
|
expression = factory.createNumericLiteral(+symbolName2);
|
|
57236
57580
|
}
|
|
57237
57581
|
if (!expression) {
|
|
57238
57582
|
const identifier = setEmitFlags(factory.createIdentifier(symbolName2), 16777216 /* NoAsciiEscaping */);
|
|
57239
57583
|
if (typeParameterNodes) setIdentifierTypeArguments(identifier, factory.createNodeArray(typeParameterNodes));
|
|
57240
57584
|
identifier.symbol = symbol2;
|
|
57585
|
+
context.approximateLength += symbolName2.length;
|
|
57241
57586
|
expression = identifier;
|
|
57242
57587
|
}
|
|
57588
|
+
context.approximateLength += 2;
|
|
57243
57589
|
return factory.createElementAccessExpression(createExpressionFromSymbolChain(chain2, index - 1), expression);
|
|
57244
57590
|
}
|
|
57245
57591
|
}
|
|
@@ -57268,6 +57614,10 @@ function createTypeChecker(host) {
|
|
|
57268
57614
|
), "'")));
|
|
57269
57615
|
}
|
|
57270
57616
|
function getPropertyNameNodeForSymbol(symbol, context) {
|
|
57617
|
+
const hashPrivateName = getClonedHashPrivateName(symbol);
|
|
57618
|
+
if (hashPrivateName) {
|
|
57619
|
+
return hashPrivateName;
|
|
57620
|
+
}
|
|
57271
57621
|
const stringNamed = !!length(symbol.declarations) && every(symbol.declarations, isStringNamed);
|
|
57272
57622
|
const singleQuote = !!length(symbol.declarations) && every(symbol.declarations, isSingleQuotedStringNamed);
|
|
57273
57623
|
const isMethod = !!(symbol.flags & 8192 /* Method */);
|
|
@@ -57344,7 +57694,7 @@ function createTypeChecker(host) {
|
|
|
57344
57694
|
let result;
|
|
57345
57695
|
const addUndefinedForParameter = declaration && (isParameter(declaration) || isJSDocParameterTag(declaration)) && requiresAddingImplicitUndefined(declaration, context.enclosingDeclaration);
|
|
57346
57696
|
const decl = declaration ?? symbol.valueDeclaration ?? getDeclarationWithTypeAnnotation(symbol) ?? ((_a = symbol.declarations) == null ? void 0 : _a[0]);
|
|
57347
|
-
if (decl) {
|
|
57697
|
+
if (!canPossiblyExpandType(type, context) && decl) {
|
|
57348
57698
|
const restore = addSymbolTypeToContext(context, symbol, type);
|
|
57349
57699
|
if (isAccessor(decl)) {
|
|
57350
57700
|
result = syntacticNodeBuilder.serializeTypeOfAccessor(decl, symbol, context);
|
|
@@ -57383,7 +57733,7 @@ function createTypeChecker(host) {
|
|
|
57383
57733
|
let returnTypeNode;
|
|
57384
57734
|
const returnType = getReturnTypeOfSignature(signature);
|
|
57385
57735
|
if (!(suppressAny && isTypeAny(returnType))) {
|
|
57386
|
-
if (signature.declaration && !nodeIsSynthesized(signature.declaration)) {
|
|
57736
|
+
if (signature.declaration && !nodeIsSynthesized(signature.declaration) && !canPossiblyExpandType(returnType, context)) {
|
|
57387
57737
|
const declarationSymbol = getSymbolOfDeclaration(signature.declaration);
|
|
57388
57738
|
const restore = addSymbolTypeToContext(context, declarationSymbol, returnType);
|
|
57389
57739
|
returnTypeNode = syntacticNodeBuilder.serializeReturnTypeForSignature(signature.declaration, declarationSymbol, context);
|
|
@@ -57794,14 +58144,28 @@ function createTypeChecker(host) {
|
|
|
57794
58144
|
if (!suppressNewPrivateContext) {
|
|
57795
58145
|
deferredPrivatesStack.push(/* @__PURE__ */ new Map());
|
|
57796
58146
|
}
|
|
57797
|
-
|
|
58147
|
+
let i = 0;
|
|
58148
|
+
const symbols = Array.from(symbolTable2.values());
|
|
58149
|
+
for (const symbol of symbols) {
|
|
58150
|
+
i++;
|
|
58151
|
+
if (checkTruncationLengthIfExpanding(context) && i + 2 < symbolTable2.size - 1) {
|
|
58152
|
+
context.out.truncated = true;
|
|
58153
|
+
results.push(createTruncationStatement(`... (${symbolTable2.size - i} more ...)`));
|
|
58154
|
+
serializeSymbol(
|
|
58155
|
+
symbols[symbols.length - 1],
|
|
58156
|
+
/*isPrivate*/
|
|
58157
|
+
false,
|
|
58158
|
+
!!propertyAsAlias
|
|
58159
|
+
);
|
|
58160
|
+
break;
|
|
58161
|
+
}
|
|
57798
58162
|
serializeSymbol(
|
|
57799
58163
|
symbol,
|
|
57800
58164
|
/*isPrivate*/
|
|
57801
58165
|
false,
|
|
57802
58166
|
!!propertyAsAlias
|
|
57803
58167
|
);
|
|
57804
|
-
}
|
|
58168
|
+
}
|
|
57805
58169
|
if (!suppressNewPrivateContext) {
|
|
57806
58170
|
deferredPrivatesStack[deferredPrivatesStack.length - 1].forEach((symbol) => {
|
|
57807
58171
|
serializeSymbol(
|
|
@@ -57831,7 +58195,7 @@ function createTypeChecker(host) {
|
|
|
57831
58195
|
}
|
|
57832
58196
|
}
|
|
57833
58197
|
function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias, escapedSymbolName = symbol.escapedName) {
|
|
57834
|
-
var _a2, _b, _c, _d, _e, _f;
|
|
58198
|
+
var _a2, _b, _c, _d, _e, _f, _g;
|
|
57835
58199
|
const symbolName2 = unescapeLeadingUnderscores(escapedSymbolName);
|
|
57836
58200
|
const isDefault = escapedSymbolName === "default" /* Default */;
|
|
57837
58201
|
if (isPrivate && !(context.flags & 131072 /* AllowAnonymousIdentifier */) && isStringANonContextualKeyword(symbolName2) && !isDefault) {
|
|
@@ -57881,6 +58245,7 @@ function createTypeChecker(host) {
|
|
|
57881
58245
|
const propertyAccessRequire = (_e = symbol.declarations) == null ? void 0 : _e.find(isPropertyAccessExpression);
|
|
57882
58246
|
if (propertyAccessRequire && isBinaryExpression(propertyAccessRequire.parent) && isIdentifier(propertyAccessRequire.parent.right) && ((_f = type.symbol) == null ? void 0 : _f.valueDeclaration) && isSourceFile(type.symbol.valueDeclaration)) {
|
|
57883
58247
|
const alias = localName === propertyAccessRequire.parent.right.escapedText ? void 0 : propertyAccessRequire.parent.right;
|
|
58248
|
+
context.approximateLength += 12 + (((_g = alias == null ? void 0 : alias.escapedText) == null ? void 0 : _g.length) ?? 0);
|
|
57884
58249
|
addResult(
|
|
57885
58250
|
factory.createExportDeclaration(
|
|
57886
58251
|
/*modifiers*/
|
|
@@ -57920,8 +58285,10 @@ function createTypeChecker(host) {
|
|
|
57920
58285
|
),
|
|
57921
58286
|
textRange
|
|
57922
58287
|
);
|
|
58288
|
+
context.approximateLength += 7 + name.length;
|
|
57923
58289
|
addResult(statement, name !== localName ? modifierFlags & ~32 /* Export */ : modifierFlags);
|
|
57924
58290
|
if (name !== localName && !isPrivate) {
|
|
58291
|
+
context.approximateLength += 16 + name.length + localName.length;
|
|
57925
58292
|
addResult(
|
|
57926
58293
|
factory.createExportDeclaration(
|
|
57927
58294
|
/*modifiers*/
|
|
@@ -57971,27 +58338,33 @@ function createTypeChecker(host) {
|
|
|
57971
58338
|
for (const node of symbol.declarations) {
|
|
57972
58339
|
const resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier);
|
|
57973
58340
|
if (!resolvedModule) continue;
|
|
58341
|
+
const isTypeOnly = node.isTypeOnly;
|
|
58342
|
+
const specifier = getSpecifierForModuleSymbol(resolvedModule, context);
|
|
58343
|
+
context.approximateLength += 17 + specifier.length;
|
|
57974
58344
|
addResult(factory.createExportDeclaration(
|
|
57975
58345
|
/*modifiers*/
|
|
57976
58346
|
void 0,
|
|
57977
|
-
|
|
57978
|
-
node.isTypeOnly,
|
|
58347
|
+
isTypeOnly,
|
|
57979
58348
|
/*exportClause*/
|
|
57980
58349
|
void 0,
|
|
57981
|
-
factory.createStringLiteral(
|
|
58350
|
+
factory.createStringLiteral(specifier)
|
|
57982
58351
|
), 0 /* None */);
|
|
57983
58352
|
}
|
|
57984
58353
|
}
|
|
57985
58354
|
}
|
|
57986
58355
|
if (needsPostExportDefault) {
|
|
58356
|
+
const internalSymbolName = getInternalSymbolName(symbol, symbolName2);
|
|
58357
|
+
context.approximateLength += 16 + internalSymbolName.length;
|
|
57987
58358
|
addResult(factory.createExportAssignment(
|
|
57988
58359
|
/*modifiers*/
|
|
57989
58360
|
void 0,
|
|
57990
58361
|
/*isExportEquals*/
|
|
57991
58362
|
false,
|
|
57992
|
-
factory.createIdentifier(
|
|
58363
|
+
factory.createIdentifier(internalSymbolName)
|
|
57993
58364
|
), 0 /* None */);
|
|
57994
58365
|
} else if (needsExportDeclaration) {
|
|
58366
|
+
const internalSymbolName = getInternalSymbolName(symbol, symbolName2);
|
|
58367
|
+
context.approximateLength += 22 + symbolName2.length + internalSymbolName.length;
|
|
57995
58368
|
addResult(
|
|
57996
58369
|
factory.createExportDeclaration(
|
|
57997
58370
|
/*modifiers*/
|
|
@@ -58001,7 +58374,7 @@ function createTypeChecker(host) {
|
|
|
58001
58374
|
factory.createNamedExports([factory.createExportSpecifier(
|
|
58002
58375
|
/*isTypeOnly*/
|
|
58003
58376
|
false,
|
|
58004
|
-
|
|
58377
|
+
internalSymbolName,
|
|
58005
58378
|
symbolName2
|
|
58006
58379
|
)])
|
|
58007
58380
|
),
|
|
@@ -58021,6 +58394,7 @@ function createTypeChecker(host) {
|
|
|
58021
58394
|
}
|
|
58022
58395
|
function addResult(node, additionalModifierFlags) {
|
|
58023
58396
|
if (canHaveModifiers(node)) {
|
|
58397
|
+
const oldModifierFlags = getEffectiveModifierFlags(node);
|
|
58024
58398
|
let newModifierFlags = 0 /* None */;
|
|
58025
58399
|
const enclosingDeclaration2 = context.enclosingDeclaration && (isJSDocTypeAlias(context.enclosingDeclaration) ? getSourceFileOfNode(context.enclosingDeclaration) : context.enclosingDeclaration);
|
|
58026
58400
|
if (additionalModifierFlags & 32 /* Export */ && enclosingDeclaration2 && (isExportingScope(enclosingDeclaration2) || isModuleDeclaration(enclosingDeclaration2)) && canHaveExportModifier(node)) {
|
|
@@ -58033,8 +58407,9 @@ function createTypeChecker(host) {
|
|
|
58033
58407
|
newModifierFlags |= 2048 /* Default */;
|
|
58034
58408
|
}
|
|
58035
58409
|
if (newModifierFlags) {
|
|
58036
|
-
node = factory.replaceModifiers(node, newModifierFlags |
|
|
58410
|
+
node = factory.replaceModifiers(node, newModifierFlags | oldModifierFlags);
|
|
58037
58411
|
}
|
|
58412
|
+
context.approximateLength += modifiersLength(newModifierFlags | oldModifierFlags);
|
|
58038
58413
|
}
|
|
58039
58414
|
results.push(node);
|
|
58040
58415
|
}
|
|
@@ -58050,12 +58425,14 @@ function createTypeChecker(host) {
|
|
|
58050
58425
|
const oldEnclosingDecl = context.enclosingDeclaration;
|
|
58051
58426
|
context.enclosingDeclaration = jsdocAliasDecl;
|
|
58052
58427
|
const typeNode = jsdocAliasDecl && jsdocAliasDecl.typeExpression && isJSDocTypeExpression(jsdocAliasDecl.typeExpression) && syntacticNodeBuilder.tryReuseExistingTypeNode(context, jsdocAliasDecl.typeExpression.type) || typeToTypeNodeHelper(aliasType, context);
|
|
58428
|
+
const internalSymbolName = getInternalSymbolName(symbol, symbolName2);
|
|
58429
|
+
context.approximateLength += 8 + ((commentText == null ? void 0 : commentText.length) ?? 0) + internalSymbolName.length;
|
|
58053
58430
|
addResult(
|
|
58054
58431
|
setSyntheticLeadingComments(
|
|
58055
58432
|
factory.createTypeAliasDeclaration(
|
|
58056
58433
|
/*modifiers*/
|
|
58057
58434
|
void 0,
|
|
58058
|
-
|
|
58435
|
+
internalSymbolName,
|
|
58059
58436
|
typeParamDecls,
|
|
58060
58437
|
typeNode
|
|
58061
58438
|
),
|
|
@@ -58067,12 +58444,19 @@ function createTypeChecker(host) {
|
|
|
58067
58444
|
context.enclosingDeclaration = oldEnclosingDecl;
|
|
58068
58445
|
}
|
|
58069
58446
|
function serializeInterface(symbol, symbolName2, modifierFlags) {
|
|
58447
|
+
const internalSymbolName = getInternalSymbolName(symbol, symbolName2);
|
|
58448
|
+
context.approximateLength += 14 + internalSymbolName.length;
|
|
58070
58449
|
const interfaceType = getDeclaredTypeOfClassOrInterface(symbol);
|
|
58071
58450
|
const localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol);
|
|
58072
58451
|
const typeParamDecls = map(localParams, (p) => typeParameterToDeclaration(p, context));
|
|
58073
58452
|
const baseTypes = getBaseTypes(interfaceType);
|
|
58074
58453
|
const baseType = length(baseTypes) ? getIntersectionType(baseTypes) : void 0;
|
|
58075
|
-
const members =
|
|
58454
|
+
const members = serializePropertySymbolsForClassOrInterface(
|
|
58455
|
+
getPropertiesOfType(interfaceType),
|
|
58456
|
+
/*isClass*/
|
|
58457
|
+
false,
|
|
58458
|
+
baseType
|
|
58459
|
+
);
|
|
58076
58460
|
const callSignatures = serializeSignatures(0 /* Call */, interfaceType, baseType, 179 /* CallSignature */);
|
|
58077
58461
|
const constructSignatures = serializeSignatures(1 /* Construct */, interfaceType, baseType, 180 /* ConstructSignature */);
|
|
58078
58462
|
const indexSignatures = serializeIndexSignatures(interfaceType, baseType);
|
|
@@ -58081,7 +58465,7 @@ function createTypeChecker(host) {
|
|
|
58081
58465
|
factory.createInterfaceDeclaration(
|
|
58082
58466
|
/*modifiers*/
|
|
58083
58467
|
void 0,
|
|
58084
|
-
|
|
58468
|
+
internalSymbolName,
|
|
58085
58469
|
typeParamDecls,
|
|
58086
58470
|
heritageClauses,
|
|
58087
58471
|
[...indexSignatures, ...constructSignatures, ...callSignatures, ...members]
|
|
@@ -58089,6 +58473,57 @@ function createTypeChecker(host) {
|
|
|
58089
58473
|
modifierFlags
|
|
58090
58474
|
);
|
|
58091
58475
|
}
|
|
58476
|
+
function serializePropertySymbolsForClassOrInterface(props, isClass, baseType, isStatic2) {
|
|
58477
|
+
const elements = [];
|
|
58478
|
+
let i = 0;
|
|
58479
|
+
for (const prop of props) {
|
|
58480
|
+
i++;
|
|
58481
|
+
if (checkTruncationLengthIfExpanding(context) && i + 2 < props.length - 1) {
|
|
58482
|
+
context.out.truncated = true;
|
|
58483
|
+
const placeholder = createTruncationProperty(`... ${props.length - i} more ... `, isClass);
|
|
58484
|
+
elements.push(placeholder);
|
|
58485
|
+
const result2 = isClass ? serializePropertySymbolForClass(props[props.length - 1], isStatic2, baseType) : serializePropertySymbolForInterface(props[props.length - 1], baseType);
|
|
58486
|
+
if (isArray(result2)) {
|
|
58487
|
+
elements.push(...result2);
|
|
58488
|
+
} else {
|
|
58489
|
+
elements.push(result2);
|
|
58490
|
+
}
|
|
58491
|
+
break;
|
|
58492
|
+
}
|
|
58493
|
+
context.approximateLength += 1;
|
|
58494
|
+
const result = isClass ? serializePropertySymbolForClass(prop, isStatic2, baseType) : serializePropertySymbolForInterface(prop, baseType);
|
|
58495
|
+
if (isArray(result)) {
|
|
58496
|
+
elements.push(...result);
|
|
58497
|
+
} else {
|
|
58498
|
+
elements.push(result);
|
|
58499
|
+
}
|
|
58500
|
+
}
|
|
58501
|
+
return elements;
|
|
58502
|
+
}
|
|
58503
|
+
function createTruncationProperty(dotDotDotText, isClass) {
|
|
58504
|
+
if (context.flags & 1 /* NoTruncation */) {
|
|
58505
|
+
return addSyntheticLeadingComment(factory.createNotEmittedTypeElement(), 3 /* MultiLineCommentTrivia */, dotDotDotText);
|
|
58506
|
+
}
|
|
58507
|
+
return isClass ? factory.createPropertyDeclaration(
|
|
58508
|
+
/*modifiers*/
|
|
58509
|
+
void 0,
|
|
58510
|
+
dotDotDotText,
|
|
58511
|
+
/*questionOrExclamationToken*/
|
|
58512
|
+
void 0,
|
|
58513
|
+
/*type*/
|
|
58514
|
+
void 0,
|
|
58515
|
+
/*initializer*/
|
|
58516
|
+
void 0
|
|
58517
|
+
) : factory.createPropertySignature(
|
|
58518
|
+
/*modifiers*/
|
|
58519
|
+
void 0,
|
|
58520
|
+
dotDotDotText,
|
|
58521
|
+
/*questionToken*/
|
|
58522
|
+
void 0,
|
|
58523
|
+
/*type*/
|
|
58524
|
+
void 0
|
|
58525
|
+
);
|
|
58526
|
+
}
|
|
58092
58527
|
function getNamespaceMembersForSerialization(symbol) {
|
|
58093
58528
|
let exports2 = arrayFrom(getExportsOfSymbol(symbol).values());
|
|
58094
58529
|
const merged = getMergedSymbol(symbol);
|
|
@@ -58108,11 +58543,27 @@ function createTypeChecker(host) {
|
|
|
58108
58543
|
}
|
|
58109
58544
|
function serializeModule(symbol, symbolName2, modifierFlags) {
|
|
58110
58545
|
const members = getNamespaceMembersForSerialization(symbol);
|
|
58111
|
-
const
|
|
58546
|
+
const expanding = isExpanding(context);
|
|
58547
|
+
const locationMap = arrayToMultiMap(members, (m) => m.parent && m.parent === symbol || expanding ? "real" : "merged");
|
|
58112
58548
|
const realMembers = locationMap.get("real") || emptyArray;
|
|
58113
58549
|
const mergedMembers = locationMap.get("merged") || emptyArray;
|
|
58114
|
-
if (length(realMembers)) {
|
|
58115
|
-
|
|
58550
|
+
if (length(realMembers) || expanding) {
|
|
58551
|
+
let localName;
|
|
58552
|
+
if (expanding) {
|
|
58553
|
+
const oldFlags = context.flags;
|
|
58554
|
+
context.flags |= 512 /* WriteTypeParametersInQualifiedName */ | 2 /* UseOnlyExternalAliasing */;
|
|
58555
|
+
localName = symbolToNode(
|
|
58556
|
+
symbol,
|
|
58557
|
+
context,
|
|
58558
|
+
/*meaning*/
|
|
58559
|
+
-1 /* All */
|
|
58560
|
+
);
|
|
58561
|
+
context.flags = oldFlags;
|
|
58562
|
+
} else {
|
|
58563
|
+
const localText = getInternalSymbolName(symbol, symbolName2);
|
|
58564
|
+
localName = factory.createIdentifier(localText);
|
|
58565
|
+
context.approximateLength += localText.length;
|
|
58566
|
+
}
|
|
58116
58567
|
serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, !!(symbol.flags & (16 /* Function */ | 67108864 /* Assignment */)));
|
|
58117
58568
|
}
|
|
58118
58569
|
if (length(mergedMembers)) {
|
|
@@ -58160,17 +58611,51 @@ function createTypeChecker(host) {
|
|
|
58160
58611
|
}
|
|
58161
58612
|
}
|
|
58162
58613
|
function serializeEnum(symbol, symbolName2, modifierFlags) {
|
|
58614
|
+
const internalSymbolName = getInternalSymbolName(symbol, symbolName2);
|
|
58615
|
+
context.approximateLength += 9 + internalSymbolName.length;
|
|
58616
|
+
const members = [];
|
|
58617
|
+
const memberProps = filter(getPropertiesOfType(getTypeOfSymbol(symbol)), (p) => !!(p.flags & 8 /* EnumMember */));
|
|
58618
|
+
let i = 0;
|
|
58619
|
+
for (const p of memberProps) {
|
|
58620
|
+
i++;
|
|
58621
|
+
if (checkTruncationLengthIfExpanding(context) && i + 2 < memberProps.length - 1) {
|
|
58622
|
+
context.out.truncated = true;
|
|
58623
|
+
members.push(factory.createEnumMember(` ... ${memberProps.length - i} more ... `));
|
|
58624
|
+
const last2 = memberProps[memberProps.length - 1];
|
|
58625
|
+
const initializedValue = last2.declarations && last2.declarations[0] && isEnumMember(last2.declarations[0]) ? getConstantValue2(last2.declarations[0]) : void 0;
|
|
58626
|
+
const initializer2 = initializedValue === void 0 ? void 0 : typeof initializedValue === "string" ? factory.createStringLiteral(initializedValue) : factory.createNumericLiteral(initializedValue);
|
|
58627
|
+
const memberName2 = unescapeLeadingUnderscores(last2.escapedName);
|
|
58628
|
+
const member2 = factory.createEnumMember(
|
|
58629
|
+
memberName2,
|
|
58630
|
+
initializer2
|
|
58631
|
+
);
|
|
58632
|
+
members.push(member2);
|
|
58633
|
+
break;
|
|
58634
|
+
}
|
|
58635
|
+
const memberDecl = p.declarations && p.declarations[0] && isEnumMember(p.declarations[0]) ? p.declarations[0] : void 0;
|
|
58636
|
+
let initializer;
|
|
58637
|
+
let initializerLength;
|
|
58638
|
+
if (isExpanding(context) && memberDecl && memberDecl.initializer) {
|
|
58639
|
+
initializer = getSynthesizedDeepClone(memberDecl.initializer);
|
|
58640
|
+
initializerLength = memberDecl.initializer.end - memberDecl.initializer.pos;
|
|
58641
|
+
} else {
|
|
58642
|
+
const initializedValue = memberDecl && getConstantValue2(memberDecl);
|
|
58643
|
+
initializer = initializedValue === void 0 ? void 0 : typeof initializedValue === "string" ? factory.createStringLiteral(initializedValue) : factory.createNumericLiteral(initializedValue);
|
|
58644
|
+
initializerLength = (initializer == null ? void 0 : initializer.text.length) ?? 0;
|
|
58645
|
+
}
|
|
58646
|
+
const memberName = unescapeLeadingUnderscores(p.escapedName);
|
|
58647
|
+
context.approximateLength += 4 + memberName.length + initializerLength;
|
|
58648
|
+
const member = factory.createEnumMember(
|
|
58649
|
+
memberName,
|
|
58650
|
+
initializer
|
|
58651
|
+
);
|
|
58652
|
+
members.push(member);
|
|
58653
|
+
}
|
|
58163
58654
|
addResult(
|
|
58164
58655
|
factory.createEnumDeclaration(
|
|
58165
58656
|
factory.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 4096 /* Const */ : 0),
|
|
58166
|
-
|
|
58167
|
-
|
|
58168
|
-
const initializedValue = p.declarations && p.declarations[0] && isEnumMember(p.declarations[0]) ? getConstantValue2(p.declarations[0]) : void 0;
|
|
58169
|
-
return factory.createEnumMember(
|
|
58170
|
-
unescapeLeadingUnderscores(p.escapedName),
|
|
58171
|
-
initializedValue === void 0 ? void 0 : typeof initializedValue === "string" ? factory.createStringLiteral(initializedValue) : factory.createNumericLiteral(initializedValue)
|
|
58172
|
-
);
|
|
58173
|
-
})
|
|
58657
|
+
internalSymbolName,
|
|
58658
|
+
members
|
|
58174
58659
|
),
|
|
58175
58660
|
modifierFlags
|
|
58176
58661
|
);
|
|
@@ -58178,20 +58663,28 @@ function createTypeChecker(host) {
|
|
|
58178
58663
|
function serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags) {
|
|
58179
58664
|
const signatures = getSignaturesOfType(type, 0 /* Call */);
|
|
58180
58665
|
for (const sig of signatures) {
|
|
58666
|
+
context.approximateLength += 1;
|
|
58181
58667
|
const decl = signatureToSignatureDeclarationHelper(sig, 262 /* FunctionDeclaration */, context, { name: factory.createIdentifier(localName) });
|
|
58182
58668
|
addResult(setTextRange2(context, decl, getSignatureTextRangeLocation(sig)), modifierFlags);
|
|
58183
58669
|
}
|
|
58184
58670
|
if (!(symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && !!symbol.exports && !!symbol.exports.size)) {
|
|
58185
58671
|
const props = filter(getPropertiesOfType(type), isNamespaceMember);
|
|
58672
|
+
context.approximateLength += localName.length;
|
|
58186
58673
|
serializeAsNamespaceDeclaration(
|
|
58187
58674
|
props,
|
|
58188
|
-
localName,
|
|
58675
|
+
factory.createIdentifier(localName),
|
|
58189
58676
|
modifierFlags,
|
|
58190
58677
|
/*suppressNewPrivateContext*/
|
|
58191
58678
|
true
|
|
58192
58679
|
);
|
|
58193
58680
|
}
|
|
58194
58681
|
}
|
|
58682
|
+
function createTruncationStatement(dotDotDotText) {
|
|
58683
|
+
if (context.flags & 1 /* NoTruncation */) {
|
|
58684
|
+
return addSyntheticLeadingComment(factory.createEmptyStatement(), 3 /* MultiLineCommentTrivia */, dotDotDotText);
|
|
58685
|
+
}
|
|
58686
|
+
return factory.createExpressionStatement(factory.createIdentifier(dotDotDotText));
|
|
58687
|
+
}
|
|
58195
58688
|
function getSignatureTextRangeLocation(signature) {
|
|
58196
58689
|
if (signature.declaration && signature.declaration.parent) {
|
|
58197
58690
|
if (isBinaryExpression(signature.declaration.parent) && getAssignmentDeclarationKind(signature.declaration.parent) === 5 /* Property */) {
|
|
@@ -58204,15 +58697,18 @@ function createTypeChecker(host) {
|
|
|
58204
58697
|
return signature.declaration;
|
|
58205
58698
|
}
|
|
58206
58699
|
function serializeAsNamespaceDeclaration(props, localName, modifierFlags, suppressNewPrivateContext) {
|
|
58700
|
+
const nodeFlags = isIdentifier(localName) ? 32 /* Namespace */ : 0 /* None */;
|
|
58701
|
+
const expanding = isExpanding(context);
|
|
58207
58702
|
if (length(props)) {
|
|
58208
|
-
|
|
58703
|
+
context.approximateLength += 14;
|
|
58704
|
+
const localVsRemoteMap = arrayToMultiMap(props, (p) => !length(p.declarations) || some(p.declarations, (d) => getSourceFileOfNode(d) === getSourceFileOfNode(context.enclosingDeclaration)) || expanding ? "local" : "remote");
|
|
58209
58705
|
const localProps = localVsRemoteMap.get("local") || emptyArray;
|
|
58210
58706
|
let fakespace = parseNodeFactory.createModuleDeclaration(
|
|
58211
58707
|
/*modifiers*/
|
|
58212
58708
|
void 0,
|
|
58213
|
-
|
|
58709
|
+
localName,
|
|
58214
58710
|
factory.createModuleBlock([]),
|
|
58215
|
-
|
|
58711
|
+
nodeFlags
|
|
58216
58712
|
);
|
|
58217
58713
|
setParent(fakespace, enclosingDeclaration);
|
|
58218
58714
|
fakespace.locals = createSymbolTable(props);
|
|
@@ -58254,6 +58750,18 @@ function createTypeChecker(host) {
|
|
|
58254
58750
|
factory.createModuleBlock(exportModifierStripped)
|
|
58255
58751
|
);
|
|
58256
58752
|
addResult(fakespace, modifierFlags);
|
|
58753
|
+
} else if (expanding) {
|
|
58754
|
+
context.approximateLength += 14;
|
|
58755
|
+
addResult(
|
|
58756
|
+
factory.createModuleDeclaration(
|
|
58757
|
+
/*modifiers*/
|
|
58758
|
+
void 0,
|
|
58759
|
+
localName,
|
|
58760
|
+
factory.createModuleBlock([]),
|
|
58761
|
+
nodeFlags
|
|
58762
|
+
),
|
|
58763
|
+
modifierFlags
|
|
58764
|
+
);
|
|
58257
58765
|
}
|
|
58258
58766
|
}
|
|
58259
58767
|
function isNamespaceMember(p) {
|
|
@@ -58296,11 +58804,13 @@ function createTypeChecker(host) {
|
|
|
58296
58804
|
}
|
|
58297
58805
|
function serializeAsClass(symbol, localName, modifierFlags) {
|
|
58298
58806
|
var _a2, _b;
|
|
58807
|
+
context.approximateLength += 9 + localName.length;
|
|
58299
58808
|
const originalDecl = (_a2 = symbol.declarations) == null ? void 0 : _a2.find(isClassLike);
|
|
58300
58809
|
const oldEnclosing = context.enclosingDeclaration;
|
|
58301
58810
|
context.enclosingDeclaration = originalDecl || oldEnclosing;
|
|
58302
58811
|
const localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol);
|
|
58303
58812
|
const typeParamDecls = map(localParams, (p) => typeParameterToDeclaration(p, context));
|
|
58813
|
+
forEach(localParams, (p) => context.approximateLength += symbolName(p.symbol).length);
|
|
58304
58814
|
const classType = getTypeWithThisArgument(getDeclaredTypeOfClassOrInterface(symbol));
|
|
58305
58815
|
const baseTypes = getBaseTypes(classType);
|
|
58306
58816
|
const originalImplements = originalDecl && getEffectiveImplementsTypeNodes(originalDecl);
|
|
@@ -58308,20 +58818,22 @@ function createTypeChecker(host) {
|
|
|
58308
58818
|
const staticType = getTypeOfSymbol(symbol);
|
|
58309
58819
|
const isClass = !!((_b = staticType.symbol) == null ? void 0 : _b.valueDeclaration) && isClassLike(staticType.symbol.valueDeclaration);
|
|
58310
58820
|
const staticBaseType = isClass ? getBaseConstructorTypeOfClass(staticType) : anyType;
|
|
58821
|
+
context.approximateLength += (length(baseTypes) ? 8 : 0) + (length(implementsExpressions) ? 11 : 0);
|
|
58311
58822
|
const heritageClauses = [
|
|
58312
58823
|
...!length(baseTypes) ? [] : [factory.createHeritageClause(96 /* ExtendsKeyword */, map(baseTypes, (b) => serializeBaseType(b, staticBaseType, localName)))],
|
|
58313
58824
|
...!length(implementsExpressions) ? [] : [factory.createHeritageClause(119 /* ImplementsKeyword */, implementsExpressions)]
|
|
58314
58825
|
];
|
|
58315
58826
|
const symbolProps = getNonInheritedProperties(classType, baseTypes, getPropertiesOfType(classType));
|
|
58316
|
-
const publicSymbolProps = filter(symbolProps, (s) =>
|
|
58317
|
-
|
|
58318
|
-
|
|
58319
|
-
|
|
58320
|
-
|
|
58321
|
-
|
|
58322
|
-
|
|
58323
|
-
|
|
58324
|
-
|
|
58827
|
+
const publicSymbolProps = filter(symbolProps, (s) => !isHashPrivate(s));
|
|
58828
|
+
const hasPrivateIdentifier = some(symbolProps, isHashPrivate);
|
|
58829
|
+
const privateProperties = hasPrivateIdentifier ? isExpanding(context) ? serializePropertySymbolsForClassOrInterface(
|
|
58830
|
+
filter(symbolProps, isHashPrivate),
|
|
58831
|
+
/*isClass*/
|
|
58832
|
+
true,
|
|
58833
|
+
baseTypes[0],
|
|
58834
|
+
/*isStatic*/
|
|
58835
|
+
false
|
|
58836
|
+
) : [factory.createPropertyDeclaration(
|
|
58325
58837
|
/*modifiers*/
|
|
58326
58838
|
void 0,
|
|
58327
58839
|
factory.createPrivateIdentifier("#private"),
|
|
@@ -58332,22 +58844,27 @@ function createTypeChecker(host) {
|
|
|
58332
58844
|
/*initializer*/
|
|
58333
58845
|
void 0
|
|
58334
58846
|
)] : emptyArray;
|
|
58335
|
-
|
|
58336
|
-
|
|
58847
|
+
if (hasPrivateIdentifier && !isExpanding(context)) {
|
|
58848
|
+
context.approximateLength += 9;
|
|
58849
|
+
}
|
|
58850
|
+
const publicProperties = serializePropertySymbolsForClassOrInterface(
|
|
58851
|
+
publicSymbolProps,
|
|
58852
|
+
/*isClass*/
|
|
58853
|
+
true,
|
|
58854
|
+
baseTypes[0],
|
|
58337
58855
|
/*isStatic*/
|
|
58338
|
-
false
|
|
58339
|
-
|
|
58340
|
-
|
|
58341
|
-
const staticMembers = flatMap(
|
|
58856
|
+
false
|
|
58857
|
+
);
|
|
58858
|
+
const staticMembers = serializePropertySymbolsForClassOrInterface(
|
|
58342
58859
|
filter(getPropertiesOfType(staticType), (p) => !(p.flags & 4194304 /* Prototype */) && p.escapedName !== "prototype" && !isNamespaceMember(p)),
|
|
58343
|
-
|
|
58344
|
-
|
|
58345
|
-
|
|
58346
|
-
|
|
58347
|
-
|
|
58348
|
-
)
|
|
58860
|
+
/*isClass*/
|
|
58861
|
+
true,
|
|
58862
|
+
staticBaseType,
|
|
58863
|
+
/*isStatic*/
|
|
58864
|
+
true
|
|
58349
58865
|
);
|
|
58350
58866
|
const isNonConstructableClassLikeInJsFile = !isClass && !!symbol.valueDeclaration && isInJSFile(symbol.valueDeclaration) && !some(getSignaturesOfType(staticType, 1 /* Construct */));
|
|
58867
|
+
if (isNonConstructableClassLikeInJsFile) context.approximateLength += 21;
|
|
58351
58868
|
const constructors = isNonConstructableClassLikeInJsFile ? [factory.createConstructorDeclaration(
|
|
58352
58869
|
factory.createModifiersFromModifierFlags(2 /* Private */),
|
|
58353
58870
|
[],
|
|
@@ -58415,6 +58932,8 @@ function createTypeChecker(host) {
|
|
|
58415
58932
|
if (((_b = (_a2 = node.parent) == null ? void 0 : _a2.parent) == null ? void 0 : _b.kind) === 260 /* VariableDeclaration */) {
|
|
58416
58933
|
const specifier2 = getSpecifierForModuleSymbol(target.parent || target, context);
|
|
58417
58934
|
const { propertyName } = node;
|
|
58935
|
+
const propertyNameText = propertyName && isIdentifier(propertyName) ? idText(propertyName) : void 0;
|
|
58936
|
+
context.approximateLength += 24 + localName.length + specifier2.length + ((propertyNameText == null ? void 0 : propertyNameText.length) ?? 0);
|
|
58418
58937
|
addResult(
|
|
58419
58938
|
factory.createImportDeclaration(
|
|
58420
58939
|
/*modifiers*/
|
|
@@ -58427,7 +58946,7 @@ function createTypeChecker(host) {
|
|
|
58427
58946
|
factory.createNamedImports([factory.createImportSpecifier(
|
|
58428
58947
|
/*isTypeOnly*/
|
|
58429
58948
|
false,
|
|
58430
|
-
|
|
58949
|
+
propertyNameText ? factory.createIdentifier(propertyNameText) : void 0,
|
|
58431
58950
|
factory.createIdentifier(localName)
|
|
58432
58951
|
)])
|
|
58433
58952
|
),
|
|
@@ -58454,6 +58973,7 @@ function createTypeChecker(host) {
|
|
|
58454
58973
|
const initializer = node.initializer;
|
|
58455
58974
|
const uniqueName = factory.createUniqueName(localName);
|
|
58456
58975
|
const specifier2 = getSpecifierForModuleSymbol(target.parent || target, context);
|
|
58976
|
+
context.approximateLength += 22 + specifier2.length + idText(uniqueName).length;
|
|
58457
58977
|
addResult(
|
|
58458
58978
|
factory.createImportEqualsDeclaration(
|
|
58459
58979
|
/*modifiers*/
|
|
@@ -58465,6 +58985,7 @@ function createTypeChecker(host) {
|
|
|
58465
58985
|
),
|
|
58466
58986
|
0 /* None */
|
|
58467
58987
|
);
|
|
58988
|
+
context.approximateLength += 12 + localName.length + idText(uniqueName).length + idText(initializer.name).length;
|
|
58468
58989
|
addResult(
|
|
58469
58990
|
factory.createImportEqualsDeclaration(
|
|
58470
58991
|
/*modifiers*/
|
|
@@ -58485,6 +59006,7 @@ function createTypeChecker(host) {
|
|
|
58485
59006
|
break;
|
|
58486
59007
|
}
|
|
58487
59008
|
const isLocalImport = !(target.flags & 512 /* ValueModule */) && !isVariableDeclaration(node);
|
|
59009
|
+
context.approximateLength += 11 + localName.length + unescapeLeadingUnderscores(target.escapedName).length;
|
|
58488
59010
|
addResult(
|
|
58489
59011
|
factory.createImportEqualsDeclaration(
|
|
58490
59012
|
/*modifiers*/
|
|
@@ -58511,6 +59033,7 @@ function createTypeChecker(host) {
|
|
|
58511
59033
|
const specifier2 = context.bundled ? factory.createStringLiteral(generatedSpecifier) : node.parent.moduleSpecifier;
|
|
58512
59034
|
const attributes = isImportDeclaration(node.parent) ? node.parent.attributes : void 0;
|
|
58513
59035
|
const isTypeOnly = isJSDocImportTag(node.parent);
|
|
59036
|
+
context.approximateLength += 14 + localName.length + 3 + (isTypeOnly ? 4 : 0);
|
|
58514
59037
|
addResult(
|
|
58515
59038
|
factory.createImportDeclaration(
|
|
58516
59039
|
/*modifiers*/
|
|
@@ -58532,6 +59055,7 @@ function createTypeChecker(host) {
|
|
|
58532
59055
|
const generatedSpecifier = getSpecifierForModuleSymbol(target.parent || target, context);
|
|
58533
59056
|
const specifier2 = context.bundled ? factory.createStringLiteral(generatedSpecifier) : node.parent.parent.moduleSpecifier;
|
|
58534
59057
|
const isTypeOnly = isJSDocImportTag(node.parent.parent);
|
|
59058
|
+
context.approximateLength += 19 + localName.length + 3 + (isTypeOnly ? 4 : 0);
|
|
58535
59059
|
addResult(
|
|
58536
59060
|
factory.createImportDeclaration(
|
|
58537
59061
|
/*modifiers*/
|
|
@@ -58550,6 +59074,7 @@ function createTypeChecker(host) {
|
|
|
58550
59074
|
break;
|
|
58551
59075
|
}
|
|
58552
59076
|
case 280 /* NamespaceExport */:
|
|
59077
|
+
context.approximateLength += 19 + localName.length + 3;
|
|
58553
59078
|
addResult(
|
|
58554
59079
|
factory.createExportDeclaration(
|
|
58555
59080
|
/*modifiers*/
|
|
@@ -58566,6 +59091,7 @@ function createTypeChecker(host) {
|
|
|
58566
59091
|
const generatedSpecifier = getSpecifierForModuleSymbol(target.parent || target, context);
|
|
58567
59092
|
const specifier2 = context.bundled ? factory.createStringLiteral(generatedSpecifier) : node.parent.parent.parent.moduleSpecifier;
|
|
58568
59093
|
const isTypeOnly = isJSDocImportTag(node.parent.parent.parent);
|
|
59094
|
+
context.approximateLength += 19 + localName.length + 3 + (isTypeOnly ? 4 : 0);
|
|
58569
59095
|
addResult(
|
|
58570
59096
|
factory.createImportDeclaration(
|
|
58571
59097
|
/*modifiers*/
|
|
@@ -58621,6 +59147,7 @@ function createTypeChecker(host) {
|
|
|
58621
59147
|
}
|
|
58622
59148
|
}
|
|
58623
59149
|
function serializeExportSpecifier(localName, targetName, specifier) {
|
|
59150
|
+
context.approximateLength += 16 + localName.length + (localName !== targetName ? targetName.length : 0);
|
|
58624
59151
|
addResult(
|
|
58625
59152
|
factory.createExportDeclaration(
|
|
58626
59153
|
/*modifiers*/
|
|
@@ -58671,6 +59198,7 @@ function createTypeChecker(host) {
|
|
|
58671
59198
|
const prevDisableTrackSymbol = context.tracker.disableTrackSymbol;
|
|
58672
59199
|
context.tracker.disableTrackSymbol = true;
|
|
58673
59200
|
if (isExportAssignmentCompatibleSymbolName) {
|
|
59201
|
+
context.approximateLength += 10;
|
|
58674
59202
|
results.push(factory.createExportAssignment(
|
|
58675
59203
|
/*modifiers*/
|
|
58676
59204
|
void 0,
|
|
@@ -58684,6 +59212,7 @@ function createTypeChecker(host) {
|
|
|
58684
59212
|
serializeExportSpecifier(name, getInternalSymbolName(target, symbolName(target)));
|
|
58685
59213
|
} else {
|
|
58686
59214
|
const varName = getUnusedName(name, symbol);
|
|
59215
|
+
context.approximateLength += varName.length + 10;
|
|
58687
59216
|
addResult(
|
|
58688
59217
|
factory.createImportEqualsDeclaration(
|
|
58689
59218
|
/*modifiers*/
|
|
@@ -58713,6 +59242,7 @@ function createTypeChecker(host) {
|
|
|
58713
59242
|
serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignmentCompatibleSymbolName ? 0 /* None */ : 32 /* Export */);
|
|
58714
59243
|
} else {
|
|
58715
59244
|
const flags = ((_a2 = context.enclosingDeclaration) == null ? void 0 : _a2.kind) === 267 /* ModuleDeclaration */ && (!(symbol.flags & 98304 /* Accessor */) || symbol.flags & 65536 /* SetAccessor */) ? 1 /* Let */ : 2 /* Const */;
|
|
59245
|
+
context.approximateLength += varName.length + 5;
|
|
58716
59246
|
const statement = factory.createVariableStatement(
|
|
58717
59247
|
/*modifiers*/
|
|
58718
59248
|
void 0,
|
|
@@ -58737,6 +59267,7 @@ function createTypeChecker(host) {
|
|
|
58737
59267
|
);
|
|
58738
59268
|
}
|
|
58739
59269
|
if (isExportAssignmentCompatibleSymbolName) {
|
|
59270
|
+
context.approximateLength += varName.length + 10;
|
|
58740
59271
|
results.push(factory.createExportAssignment(
|
|
58741
59272
|
/*modifiers*/
|
|
58742
59273
|
void 0,
|
|
@@ -58771,7 +59302,7 @@ function createTypeChecker(host) {
|
|
|
58771
59302
|
return function serializePropertySymbol(p, isStatic2, baseType) {
|
|
58772
59303
|
var _a2, _b, _c, _d, _e, _f;
|
|
58773
59304
|
const modifierFlags = getDeclarationModifierFlagsFromSymbol(p);
|
|
58774
|
-
const
|
|
59305
|
+
const omitType = !!(modifierFlags & 2 /* Private */) && !isExpanding(context);
|
|
58775
59306
|
if (isStatic2 && p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */)) {
|
|
58776
59307
|
return [];
|
|
58777
59308
|
}
|
|
@@ -58800,6 +59331,7 @@ function createTypeChecker(host) {
|
|
|
58800
59331
|
Debug.assert(!!setter);
|
|
58801
59332
|
const paramSymbol = isFunctionLikeDeclaration(setter) ? getSignatureFromDeclaration(setter).parameters[0] : void 0;
|
|
58802
59333
|
const setterDeclaration = (_b = p.declarations) == null ? void 0 : _b.find(isSetAccessor);
|
|
59334
|
+
context.approximateLength += modifiersLength(flag) + 7 + (paramSymbol ? symbolName(paramSymbol).length : 5) + (omitType ? 0 : 2);
|
|
58803
59335
|
result.push(setTextRange2(
|
|
58804
59336
|
context,
|
|
58805
59337
|
factory.createSetAccessorDeclaration(
|
|
@@ -58813,7 +59345,7 @@ function createTypeChecker(host) {
|
|
|
58813
59345
|
paramSymbol ? parameterToParameterDeclarationName(paramSymbol, getEffectiveParameterDeclaration(paramSymbol), context) : "value",
|
|
58814
59346
|
/*questionToken*/
|
|
58815
59347
|
void 0,
|
|
58816
|
-
|
|
59348
|
+
omitType ? void 0 : serializeTypeForDeclaration(context, setterDeclaration, getWriteTypeOfSymbol(p), p)
|
|
58817
59349
|
)],
|
|
58818
59350
|
/*body*/
|
|
58819
59351
|
void 0
|
|
@@ -58822,15 +59354,15 @@ function createTypeChecker(host) {
|
|
|
58822
59354
|
));
|
|
58823
59355
|
}
|
|
58824
59356
|
if (p.flags & 32768 /* GetAccessor */) {
|
|
58825
|
-
const isPrivate2 = modifierFlags & 2 /* Private */;
|
|
58826
59357
|
const getterDeclaration = (_c = p.declarations) == null ? void 0 : _c.find(isGetAccessor);
|
|
59358
|
+
context.approximateLength += modifiersLength(flag) + 8 + (omitType ? 0 : 2);
|
|
58827
59359
|
result.push(setTextRange2(
|
|
58828
59360
|
context,
|
|
58829
59361
|
factory.createGetAccessorDeclaration(
|
|
58830
59362
|
factory.createModifiersFromModifierFlags(flag),
|
|
58831
59363
|
name,
|
|
58832
59364
|
[],
|
|
58833
|
-
|
|
59365
|
+
omitType ? void 0 : serializeTypeForDeclaration(context, getterDeclaration, getTypeOfSymbol(p), p),
|
|
58834
59366
|
/*body*/
|
|
58835
59367
|
void 0
|
|
58836
59368
|
),
|
|
@@ -58839,13 +59371,15 @@ function createTypeChecker(host) {
|
|
|
58839
59371
|
}
|
|
58840
59372
|
return result;
|
|
58841
59373
|
} else if (p.flags & (4 /* Property */ | 3 /* Variable */ | 98304 /* Accessor */)) {
|
|
59374
|
+
const modifierFlags2 = (isReadonlySymbol(p) ? 8 /* Readonly */ : 0) | flag;
|
|
59375
|
+
context.approximateLength += 2 + (omitType ? 0 : 2) + modifiersLength(modifierFlags2);
|
|
58842
59376
|
return setTextRange2(
|
|
58843
59377
|
context,
|
|
58844
59378
|
createProperty2(
|
|
58845
|
-
factory.createModifiersFromModifierFlags(
|
|
59379
|
+
factory.createModifiersFromModifierFlags(modifierFlags2),
|
|
58846
59380
|
name,
|
|
58847
59381
|
p.flags & 16777216 /* Optional */ ? factory.createToken(58 /* QuestionToken */) : void 0,
|
|
58848
|
-
|
|
59382
|
+
omitType ? void 0 : serializeTypeForDeclaration(context, (_d = p.declarations) == null ? void 0 : _d.find(isSetAccessorDeclaration), getWriteTypeOfSymbol(p), p),
|
|
58849
59383
|
// TODO: https://github.com/microsoft/TypeScript/pull/32372#discussion_r328386357
|
|
58850
59384
|
// interface members can't have initializers, however class members _can_
|
|
58851
59385
|
/*initializer*/
|
|
@@ -58857,11 +59391,13 @@ function createTypeChecker(host) {
|
|
|
58857
59391
|
if (p.flags & (8192 /* Method */ | 16 /* Function */)) {
|
|
58858
59392
|
const type = getTypeOfSymbol(p);
|
|
58859
59393
|
const signatures = getSignaturesOfType(type, 0 /* Call */);
|
|
58860
|
-
if (
|
|
59394
|
+
if (omitType) {
|
|
59395
|
+
const modifierFlags2 = (isReadonlySymbol(p) ? 8 /* Readonly */ : 0) | flag;
|
|
59396
|
+
context.approximateLength += 1 + modifiersLength(modifierFlags2);
|
|
58861
59397
|
return setTextRange2(
|
|
58862
59398
|
context,
|
|
58863
59399
|
createProperty2(
|
|
58864
|
-
factory.createModifiersFromModifierFlags(
|
|
59400
|
+
factory.createModifiersFromModifierFlags(modifierFlags2),
|
|
58865
59401
|
name,
|
|
58866
59402
|
p.flags & 16777216 /* Optional */ ? factory.createToken(58 /* QuestionToken */) : void 0,
|
|
58867
59403
|
/*type*/
|
|
@@ -58874,6 +59410,7 @@ function createTypeChecker(host) {
|
|
|
58874
59410
|
}
|
|
58875
59411
|
const results2 = [];
|
|
58876
59412
|
for (const sig of signatures) {
|
|
59413
|
+
context.approximateLength += 1;
|
|
58877
59414
|
const decl = signatureToSignatureDeclarationHelper(
|
|
58878
59415
|
sig,
|
|
58879
59416
|
methodKind,
|
|
@@ -58892,6 +59429,25 @@ function createTypeChecker(host) {
|
|
|
58892
59429
|
return Debug.fail(`Unhandled class member kind! ${p.__debugFlags || p.flags}`);
|
|
58893
59430
|
};
|
|
58894
59431
|
}
|
|
59432
|
+
function modifiersLength(flags) {
|
|
59433
|
+
let result = 0;
|
|
59434
|
+
if (flags & 32 /* Export */) result += 7;
|
|
59435
|
+
if (flags & 128 /* Ambient */) result += 8;
|
|
59436
|
+
if (flags & 2048 /* Default */) result += 8;
|
|
59437
|
+
if (flags & 4096 /* Const */) result += 6;
|
|
59438
|
+
if (flags & 1 /* Public */) result += 7;
|
|
59439
|
+
if (flags & 2 /* Private */) result += 8;
|
|
59440
|
+
if (flags & 4 /* Protected */) result += 10;
|
|
59441
|
+
if (flags & 64 /* Abstract */) result += 9;
|
|
59442
|
+
if (flags & 256 /* Static */) result += 7;
|
|
59443
|
+
if (flags & 16 /* Override */) result += 9;
|
|
59444
|
+
if (flags & 8 /* Readonly */) result += 9;
|
|
59445
|
+
if (flags & 512 /* Accessor */) result += 9;
|
|
59446
|
+
if (flags & 1024 /* Async */) result += 6;
|
|
59447
|
+
if (flags & 8192 /* In */) result += 3;
|
|
59448
|
+
if (flags & 16384 /* Out */) result += 4;
|
|
59449
|
+
return result;
|
|
59450
|
+
}
|
|
58895
59451
|
function serializePropertySymbolForInterface(p, baseType) {
|
|
58896
59452
|
return serializePropertySymbolForInterfaceWorker(
|
|
58897
59453
|
p,
|
|
@@ -58956,6 +59512,7 @@ function createTypeChecker(host) {
|
|
|
58956
59512
|
}
|
|
58957
59513
|
const results2 = [];
|
|
58958
59514
|
for (const sig of signatures) {
|
|
59515
|
+
context.approximateLength += 1;
|
|
58959
59516
|
const decl = signatureToSignatureDeclarationHelper(sig, outputKind, context);
|
|
58960
59517
|
results2.push(setTextRange2(context, decl, sig.declaration));
|
|
58961
59518
|
}
|
|
@@ -59081,6 +59638,23 @@ function createTypeChecker(host) {
|
|
|
59081
59638
|
return localName;
|
|
59082
59639
|
}
|
|
59083
59640
|
}
|
|
59641
|
+
function isExpanding(context) {
|
|
59642
|
+
return context.maxExpansionDepth !== -1;
|
|
59643
|
+
}
|
|
59644
|
+
function isHashPrivate(s) {
|
|
59645
|
+
return !!s.valueDeclaration && isNamedDeclaration(s.valueDeclaration) && isPrivateIdentifier(s.valueDeclaration.name);
|
|
59646
|
+
}
|
|
59647
|
+
function getClonedHashPrivateName(s) {
|
|
59648
|
+
if (s.valueDeclaration && isNamedDeclaration(s.valueDeclaration) && isPrivateIdentifier(s.valueDeclaration.name)) {
|
|
59649
|
+
return factory.cloneNode(s.valueDeclaration.name);
|
|
59650
|
+
}
|
|
59651
|
+
return void 0;
|
|
59652
|
+
}
|
|
59653
|
+
}
|
|
59654
|
+
function isLibType(type) {
|
|
59655
|
+
var _a;
|
|
59656
|
+
const symbol = (getObjectFlags(type) & 4 /* Reference */) !== 0 ? type.target.symbol : type.symbol;
|
|
59657
|
+
return isTupleType(type) || !!((_a = symbol == null ? void 0 : symbol.declarations) == null ? void 0 : _a.some((decl) => host.isSourceFileDefaultLibrary(getSourceFileOfNode(decl))));
|
|
59084
59658
|
}
|
|
59085
59659
|
function typePredicateToString(typePredicate, enclosingDeclaration, flags = 16384 /* UseAliasDefinedOutsideCurrentScope */, writer) {
|
|
59086
59660
|
return writer ? typePredicateToStringWorker(writer).getText() : usingSingleLineStringWriter(typePredicateToStringWorker);
|
|
@@ -59099,14 +59673,14 @@ function createTypeChecker(host) {
|
|
|
59099
59673
|
return writer2;
|
|
59100
59674
|
}
|
|
59101
59675
|
}
|
|
59102
|
-
function formatUnionTypes(types) {
|
|
59676
|
+
function formatUnionTypes(types, expandingEnum) {
|
|
59103
59677
|
const result = [];
|
|
59104
59678
|
let flags = 0;
|
|
59105
59679
|
for (let i = 0; i < types.length; i++) {
|
|
59106
59680
|
const t = types[i];
|
|
59107
59681
|
flags |= t.flags;
|
|
59108
59682
|
if (!(t.flags & 98304 /* Nullable */)) {
|
|
59109
|
-
if (t.flags &
|
|
59683
|
+
if (t.flags & 512 /* BooleanLiteral */ || !expandingEnum && t.flags | 1056 /* EnumLike */) {
|
|
59110
59684
|
const baseType = t.flags & 512 /* BooleanLiteral */ ? booleanType : getBaseTypeOfEnumLikeType(t);
|
|
59111
59685
|
if (baseType.flags & 1048576 /* Union */) {
|
|
59112
59686
|
const count = baseType.types.length;
|
|
@@ -63189,7 +63763,7 @@ function createTypeChecker(host) {
|
|
|
63189
63763
|
let hasThisParameter2 = false;
|
|
63190
63764
|
const iife = getImmediatelyInvokedFunctionExpression(declaration);
|
|
63191
63765
|
const isJSConstructSignature = isJSDocConstructSignature(declaration);
|
|
63192
|
-
const isUntypedSignatureInJSFile = !iife && isInJSFile(declaration) && isValueSignatureDeclaration(declaration) && !hasJSDocParameterTags(declaration) && !getJSDocType(declaration) && !getContextualSignatureForFunctionLikeDeclaration(declaration);
|
|
63766
|
+
const isUntypedSignatureInJSFile = !iife && isInJSFile(declaration) && isValueSignatureDeclaration(declaration) && !hasJSDocParameterTags(declaration) && !some(declaration.parameters, (p) => !!getJSDocType(p)) && !getJSDocType(declaration) && !getContextualSignatureForFunctionLikeDeclaration(declaration);
|
|
63193
63767
|
if (isUntypedSignatureInJSFile) {
|
|
63194
63768
|
flags |= 32 /* IsUntypedSignatureInJSFile */;
|
|
63195
63769
|
}
|
|
@@ -64053,14 +64627,11 @@ function createTypeChecker(host) {
|
|
|
64053
64627
|
function isNoInferType(type) {
|
|
64054
64628
|
return !!(type.flags & 33554432 /* Substitution */ && type.constraint.flags & 2 /* Unknown */);
|
|
64055
64629
|
}
|
|
64056
|
-
function
|
|
64057
|
-
return
|
|
64058
|
-
}
|
|
64059
|
-
function getSubstitutionType(baseType, constraint, isNarrowed) {
|
|
64060
|
-
return constraint.flags & 3 /* AnyOrUnknown */ || constraint === baseType || baseType.flags & 1 /* Any */ ? baseType : getOrCreateSubstitutionType(baseType, constraint, isNarrowed);
|
|
64630
|
+
function getSubstitutionType(baseType, constraint) {
|
|
64631
|
+
return constraint.flags & 3 /* AnyOrUnknown */ || constraint === baseType || baseType.flags & 1 /* Any */ ? baseType : getOrCreateSubstitutionType(baseType, constraint);
|
|
64061
64632
|
}
|
|
64062
|
-
function getOrCreateSubstitutionType(baseType, constraint
|
|
64063
|
-
const id = `${getTypeId(baseType)}>${getTypeId(constraint)}
|
|
64633
|
+
function getOrCreateSubstitutionType(baseType, constraint) {
|
|
64634
|
+
const id = `${getTypeId(baseType)}>${getTypeId(constraint)}`;
|
|
64064
64635
|
const cached = substitutionTypes.get(id);
|
|
64065
64636
|
if (cached) {
|
|
64066
64637
|
return cached;
|
|
@@ -64068,9 +64639,6 @@ function createTypeChecker(host) {
|
|
|
64068
64639
|
const result = createType(33554432 /* Substitution */);
|
|
64069
64640
|
result.baseType = baseType;
|
|
64070
64641
|
result.constraint = constraint;
|
|
64071
|
-
if (isNarrowed) {
|
|
64072
|
-
result.objectFlags |= 16777216 /* IsNarrowingType */;
|
|
64073
|
-
}
|
|
64074
64642
|
substitutionTypes.set(id, result);
|
|
64075
64643
|
return result;
|
|
64076
64644
|
}
|
|
@@ -66276,7 +66844,7 @@ function createTypeChecker(host) {
|
|
|
66276
66844
|
function isDeferredType(type, checkTuples) {
|
|
66277
66845
|
return isGenericType(type) || checkTuples && isTupleType(type) && some(getElementTypes(type), isGenericType);
|
|
66278
66846
|
}
|
|
66279
|
-
function getConditionalType(root, mapper, forConstraint, aliasSymbol, aliasTypeArguments
|
|
66847
|
+
function getConditionalType(root, mapper, forConstraint, aliasSymbol, aliasTypeArguments) {
|
|
66280
66848
|
let result;
|
|
66281
66849
|
let extraTypes;
|
|
66282
66850
|
let tailCount = 0;
|
|
@@ -66293,11 +66861,10 @@ function createTypeChecker(host) {
|
|
|
66293
66861
|
if (checkType === wildcardType || extendsType === wildcardType) {
|
|
66294
66862
|
return wildcardType;
|
|
66295
66863
|
}
|
|
66296
|
-
const effectiveCheckType = forNarrowing && isNarrowingSubstitutionType(checkType) ? checkType.constraint : checkType;
|
|
66297
66864
|
const checkTypeNode = skipTypeParentheses(root.node.checkType);
|
|
66298
66865
|
const extendsTypeNode = skipTypeParentheses(root.node.extendsType);
|
|
66299
66866
|
const checkTuples = isSimpleTupleType(checkTypeNode) && isSimpleTupleType(extendsTypeNode) && length(checkTypeNode.elements) === length(extendsTypeNode.elements);
|
|
66300
|
-
const checkTypeDeferred = isDeferredType(
|
|
66867
|
+
const checkTypeDeferred = isDeferredType(checkType, checkTuples);
|
|
66301
66868
|
let combinedMapper;
|
|
66302
66869
|
if (root.inferTypeParameters) {
|
|
66303
66870
|
const context = createInferenceContext(
|
|
@@ -66310,14 +66877,14 @@ function createTypeChecker(host) {
|
|
|
66310
66877
|
context.nonFixingMapper = combineTypeMappers(context.nonFixingMapper, mapper);
|
|
66311
66878
|
}
|
|
66312
66879
|
if (!checkTypeDeferred) {
|
|
66313
|
-
inferTypes(context.inferences, checkType, extendsType, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */);
|
|
66880
|
+
inferTypes(context, context.inferences, checkType, extendsType, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */);
|
|
66314
66881
|
}
|
|
66315
66882
|
combinedMapper = mapper ? combineTypeMappers(context.mapper, mapper) : context.mapper;
|
|
66316
66883
|
}
|
|
66317
66884
|
const inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType;
|
|
66318
66885
|
if (!checkTypeDeferred && !isDeferredType(inferredExtendsType, checkTuples)) {
|
|
66319
|
-
if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && (
|
|
66320
|
-
if (
|
|
66886
|
+
if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && (checkType.flags & 1 /* Any */ || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) {
|
|
66887
|
+
if (checkType.flags & 1 /* Any */ || forConstraint && !(inferredExtendsType.flags & 131072 /* Never */) && someType(getPermissiveInstantiation(inferredExtendsType), (t) => isTypeAssignableTo(t, getPermissiveInstantiation(checkType)))) {
|
|
66321
66888
|
(extraTypes || (extraTypes = [])).push(instantiateType(getTypeFromTypeNode(root.node.trueType), combinedMapper || mapper));
|
|
66322
66889
|
}
|
|
66323
66890
|
const falseType2 = getTypeFromTypeNode(root.node.falseType);
|
|
@@ -66334,7 +66901,7 @@ function createTypeChecker(host) {
|
|
|
66334
66901
|
result = instantiateType(falseType2, mapper);
|
|
66335
66902
|
break;
|
|
66336
66903
|
}
|
|
66337
|
-
if (inferredExtendsType.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(
|
|
66904
|
+
if (inferredExtendsType.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) {
|
|
66338
66905
|
const trueType2 = getTypeFromTypeNode(root.node.trueType);
|
|
66339
66906
|
const trueMapper = combinedMapper || mapper;
|
|
66340
66907
|
if (canTailRecurse(trueType2, trueMapper)) {
|
|
@@ -67300,44 +67867,8 @@ function createTypeChecker(host) {
|
|
|
67300
67867
|
if (!result) {
|
|
67301
67868
|
const newMapper = createTypeMapper(root.outerTypeParameters, typeArguments);
|
|
67302
67869
|
const checkType = root.checkType;
|
|
67303
|
-
|
|
67304
|
-
|
|
67305
|
-
const forNarrowing = distributionType && isNarrowingSubstitutionType(distributionType) && isNarrowableConditionalType(
|
|
67306
|
-
type,
|
|
67307
|
-
/*hadNonPrimitiveExtendsType*/
|
|
67308
|
-
[],
|
|
67309
|
-
mapper
|
|
67310
|
-
);
|
|
67311
|
-
if (forNarrowing) {
|
|
67312
|
-
narrowingBaseType = distributionType.baseType;
|
|
67313
|
-
distributionType = getReducedType(distributionType.constraint);
|
|
67314
|
-
}
|
|
67315
|
-
if (distributionType && checkType !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */)) {
|
|
67316
|
-
if (narrowingBaseType) {
|
|
67317
|
-
result = mapTypeToIntersection(
|
|
67318
|
-
distributionType,
|
|
67319
|
-
(t) => getConditionalType(
|
|
67320
|
-
root,
|
|
67321
|
-
prependTypeMapping(checkType, getSubstitutionType(
|
|
67322
|
-
narrowingBaseType,
|
|
67323
|
-
t,
|
|
67324
|
-
/*isNarrowed*/
|
|
67325
|
-
true
|
|
67326
|
-
), newMapper),
|
|
67327
|
-
forConstraint,
|
|
67328
|
-
/*aliasSymbol*/
|
|
67329
|
-
void 0,
|
|
67330
|
-
/*aliasTypeArguments*/
|
|
67331
|
-
void 0,
|
|
67332
|
-
forNarrowing
|
|
67333
|
-
)
|
|
67334
|
-
);
|
|
67335
|
-
} else {
|
|
67336
|
-
result = mapTypeWithAlias(distributionType, (t) => getConditionalType(root, prependTypeMapping(checkType, t, newMapper), forConstraint), aliasSymbol, aliasTypeArguments);
|
|
67337
|
-
}
|
|
67338
|
-
} else {
|
|
67339
|
-
result = getConditionalType(root, newMapper, forConstraint, aliasSymbol, aliasTypeArguments, forNarrowing);
|
|
67340
|
-
}
|
|
67870
|
+
const distributionType = root.isDistributive ? getReducedType(getMappedType(checkType, newMapper)) : void 0;
|
|
67871
|
+
result = distributionType && checkType !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapTypeWithAlias(distributionType, (t) => getConditionalType(root, prependTypeMapping(checkType, t, newMapper), forConstraint), aliasSymbol, aliasTypeArguments) : getConditionalType(root, newMapper, forConstraint, aliasSymbol, aliasTypeArguments);
|
|
67341
67872
|
root.instantiations.set(id, result);
|
|
67342
67873
|
}
|
|
67343
67874
|
return result;
|
|
@@ -67364,10 +67895,25 @@ function createTypeChecker(host) {
|
|
|
67364
67895
|
error2(currentNode, Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
|
|
67365
67896
|
return errorType;
|
|
67366
67897
|
}
|
|
67898
|
+
const index = findActiveMapper(mapper);
|
|
67899
|
+
if (index === -1) {
|
|
67900
|
+
pushActiveMapper(mapper);
|
|
67901
|
+
}
|
|
67902
|
+
const key = type.id + getAliasId(aliasSymbol, aliasTypeArguments);
|
|
67903
|
+
const mapperCache = activeTypeMappersCaches[index !== -1 ? index : activeTypeMappersCount - 1];
|
|
67904
|
+
const cached = mapperCache.get(key);
|
|
67905
|
+
if (cached) {
|
|
67906
|
+
return cached;
|
|
67907
|
+
}
|
|
67367
67908
|
totalInstantiationCount++;
|
|
67368
67909
|
instantiationCount++;
|
|
67369
67910
|
instantiationDepth++;
|
|
67370
67911
|
const result = instantiateTypeWorker(type, mapper, aliasSymbol, aliasTypeArguments);
|
|
67912
|
+
if (index === -1) {
|
|
67913
|
+
popActiveMapper();
|
|
67914
|
+
} else {
|
|
67915
|
+
mapperCache.set(key, result);
|
|
67916
|
+
}
|
|
67371
67917
|
instantiationDepth--;
|
|
67372
67918
|
return result;
|
|
67373
67919
|
}
|
|
@@ -68480,12 +69026,10 @@ function createTypeChecker(host) {
|
|
|
68480
69026
|
function shouldNormalizeIntersection(type) {
|
|
68481
69027
|
let hasInstantiable = false;
|
|
68482
69028
|
let hasNullableOrEmpty = false;
|
|
68483
|
-
let hasSubstitution = false;
|
|
68484
69029
|
for (const t of type.types) {
|
|
68485
69030
|
hasInstantiable || (hasInstantiable = !!(t.flags & 465829888 /* Instantiable */));
|
|
68486
69031
|
hasNullableOrEmpty || (hasNullableOrEmpty = !!(t.flags & 98304 /* Nullable */) || isEmptyAnonymousObjectType(t));
|
|
68487
|
-
|
|
68488
|
-
if (hasInstantiable && hasNullableOrEmpty || hasSubstitution) return true;
|
|
69032
|
+
if (hasInstantiable && hasNullableOrEmpty) return true;
|
|
68489
69033
|
}
|
|
68490
69034
|
return false;
|
|
68491
69035
|
}
|
|
@@ -69992,7 +70536,7 @@ function createTypeChecker(host) {
|
|
|
69992
70536
|
0 /* None */,
|
|
69993
70537
|
isRelatedToWorker
|
|
69994
70538
|
);
|
|
69995
|
-
inferTypes(ctx.inferences, target2.extendsType, sourceExtends, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */);
|
|
70539
|
+
inferTypes(ctx, ctx.inferences, target2.extendsType, sourceExtends, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */);
|
|
69996
70540
|
sourceExtends = instantiateType(sourceExtends, ctx.mapper);
|
|
69997
70541
|
mapper = ctx.mapper;
|
|
69998
70542
|
}
|
|
@@ -71872,7 +72416,7 @@ function createTypeChecker(host) {
|
|
|
71872
72416
|
map(context.inferences, (inference, i) => () => {
|
|
71873
72417
|
if (!inference.isFixed) {
|
|
71874
72418
|
inferFromIntraExpressionSites(context);
|
|
71875
|
-
clearCachedInferences(context.inferences);
|
|
72419
|
+
clearCachedInferences(context, context.inferences);
|
|
71876
72420
|
inference.isFixed = true;
|
|
71877
72421
|
}
|
|
71878
72422
|
return getInferredType(context, i);
|
|
@@ -71887,7 +72431,10 @@ function createTypeChecker(host) {
|
|
|
71887
72431
|
})
|
|
71888
72432
|
);
|
|
71889
72433
|
}
|
|
71890
|
-
function clearCachedInferences(inferences) {
|
|
72434
|
+
function clearCachedInferences(context, inferences) {
|
|
72435
|
+
if (context) {
|
|
72436
|
+
clearActiveMapperCache(context.nonFixingMapper);
|
|
72437
|
+
}
|
|
71891
72438
|
for (const inference of inferences) {
|
|
71892
72439
|
if (!inference.isFixed) {
|
|
71893
72440
|
inference.inferredType = void 0;
|
|
@@ -71902,7 +72449,7 @@ function createTypeChecker(host) {
|
|
|
71902
72449
|
for (const { node, type } of context.intraExpressionInferenceSites) {
|
|
71903
72450
|
const contextualType = node.kind === 174 /* MethodDeclaration */ ? getContextualTypeForObjectLiteralMethod(node, 2 /* NoConstraints */) : getContextualType2(node, 2 /* NoConstraints */);
|
|
71904
72451
|
if (contextualType) {
|
|
71905
|
-
inferTypes(context.inferences, type, contextualType);
|
|
72452
|
+
inferTypes(context, context.inferences, type, contextualType);
|
|
71906
72453
|
}
|
|
71907
72454
|
}
|
|
71908
72455
|
context.intraExpressionInferenceSites = void 0;
|
|
@@ -72046,7 +72593,13 @@ function createTypeChecker(host) {
|
|
|
72046
72593
|
const typeParameter = getIndexedAccessType(constraint.type, getTypeParameterFromMappedType(target));
|
|
72047
72594
|
const templateType = getTemplateTypeFromMappedType(target);
|
|
72048
72595
|
const inference = createInferenceInfo(typeParameter);
|
|
72049
|
-
inferTypes(
|
|
72596
|
+
inferTypes(
|
|
72597
|
+
/*context*/
|
|
72598
|
+
void 0,
|
|
72599
|
+
[inference],
|
|
72600
|
+
sourceType,
|
|
72601
|
+
templateType
|
|
72602
|
+
);
|
|
72050
72603
|
return getTypeFromInference(inference) || unknownType;
|
|
72051
72604
|
}
|
|
72052
72605
|
function inferReverseMappedType(source, target, constraint) {
|
|
@@ -72248,7 +72801,7 @@ function createTypeChecker(host) {
|
|
|
72248
72801
|
function isTupleOfSelf(typeParameter, type) {
|
|
72249
72802
|
return isTupleType(type) && getTupleElementType(type, 0) === getIndexedAccessType(typeParameter, getNumberLiteralType(0)) && !getTypeOfPropertyOfType(type, "1");
|
|
72250
72803
|
}
|
|
72251
|
-
function inferTypes(inferences, originalSource, originalTarget, priority = 0 /* None */, contravariant = false) {
|
|
72804
|
+
function inferTypes(context, inferences, originalSource, originalTarget, priority = 0 /* None */, contravariant = false) {
|
|
72252
72805
|
let bivariant = false;
|
|
72253
72806
|
let propagationType;
|
|
72254
72807
|
let inferencePriority = 2048 /* MaxValue */;
|
|
@@ -72339,16 +72892,16 @@ function createTypeChecker(host) {
|
|
|
72339
72892
|
if (contravariant && !bivariant) {
|
|
72340
72893
|
if (!contains(inference.contraCandidates, candidate)) {
|
|
72341
72894
|
inference.contraCandidates = append(inference.contraCandidates, candidate);
|
|
72342
|
-
clearCachedInferences(inferences);
|
|
72895
|
+
clearCachedInferences(context, inferences);
|
|
72343
72896
|
}
|
|
72344
72897
|
} else if (!contains(inference.candidates, candidate)) {
|
|
72345
72898
|
inference.candidates = append(inference.candidates, candidate);
|
|
72346
|
-
clearCachedInferences(inferences);
|
|
72899
|
+
clearCachedInferences(context, inferences);
|
|
72347
72900
|
}
|
|
72348
72901
|
}
|
|
72349
72902
|
if (!(priority & 128 /* ReturnType */) && target.flags & 262144 /* TypeParameter */ && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) {
|
|
72350
72903
|
inference.topLevel = false;
|
|
72351
|
-
clearCachedInferences(inferences);
|
|
72904
|
+
clearCachedInferences(context, inferences);
|
|
72352
72905
|
}
|
|
72353
72906
|
}
|
|
72354
72907
|
inferencePriority = Math.min(inferencePriority, priority);
|
|
@@ -72914,6 +73467,7 @@ function createTypeChecker(host) {
|
|
|
72914
73467
|
const instantiatedConstraint = instantiateType(constraint, context.nonFixingMapper);
|
|
72915
73468
|
if (!inferredType || !context.compareTypes(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) {
|
|
72916
73469
|
inference.inferredType = fallbackType && context.compareTypes(fallbackType, getTypeWithThisArgument(instantiatedConstraint, fallbackType)) ? fallbackType : instantiatedConstraint;
|
|
73470
|
+
clearActiveMapperCache(context.nonFixingMapper);
|
|
72917
73471
|
}
|
|
72918
73472
|
}
|
|
72919
73473
|
}
|
|
@@ -73645,18 +74199,6 @@ function createTypeChecker(host) {
|
|
|
73645
74199
|
}
|
|
73646
74200
|
return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* None */ : 1 /* Literal */) : type;
|
|
73647
74201
|
}
|
|
73648
|
-
function mapTypeToIntersection(type, mapper) {
|
|
73649
|
-
if (type.flags & 131072 /* Never */) {
|
|
73650
|
-
return type;
|
|
73651
|
-
}
|
|
73652
|
-
if (!(type.flags & 1048576 /* Union */)) {
|
|
73653
|
-
return mapper(type);
|
|
73654
|
-
}
|
|
73655
|
-
const origin = type.origin;
|
|
73656
|
-
const types = origin && origin.flags & 1048576 /* Union */ ? origin.types : type.types;
|
|
73657
|
-
const mappedTypes = types.map((t) => t.flags & 1048576 /* Union */ ? mapTypeToIntersection(t, mapper) : mapper(t));
|
|
73658
|
-
return getIntersectionType(mappedTypes);
|
|
73659
|
-
}
|
|
73660
74202
|
function mapTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) {
|
|
73661
74203
|
return type.flags & 1048576 /* Union */ && aliasSymbol ? getUnionType(map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments) : mapType(type, mapper);
|
|
73662
74204
|
}
|
|
@@ -75241,11 +75783,11 @@ function createTypeChecker(host) {
|
|
|
75241
75783
|
));
|
|
75242
75784
|
return contextualType && !isGenericType(contextualType);
|
|
75243
75785
|
}
|
|
75244
|
-
function getNarrowableTypeForReference(type, reference, checkMode
|
|
75786
|
+
function getNarrowableTypeForReference(type, reference, checkMode) {
|
|
75245
75787
|
if (isNoInferType(type)) {
|
|
75246
75788
|
type = type.baseType;
|
|
75247
75789
|
}
|
|
75248
|
-
const substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) && someType(type, isGenericTypeWithUnionConstraint) && (
|
|
75790
|
+
const substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) && someType(type, isGenericTypeWithUnionConstraint) && (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
|
|
75249
75791
|
return substituteConstraints ? mapType(type, getBaseConstraintOrType) : type;
|
|
75250
75792
|
}
|
|
75251
75793
|
function isExportOrExportExpression(location) {
|
|
@@ -76372,16 +76914,9 @@ function createTypeChecker(host) {
|
|
|
76372
76914
|
function getContextualTypeForReturnExpression(node, contextFlags) {
|
|
76373
76915
|
const func = getContainingFunction(node);
|
|
76374
76916
|
if (func) {
|
|
76375
|
-
const functionFlags = getFunctionFlags(func);
|
|
76376
|
-
const links = getNodeLinks(node);
|
|
76377
|
-
if (links.contextualReturnType) {
|
|
76378
|
-
if (functionFlags & 2 /* Async */) {
|
|
76379
|
-
return getUnionType([links.contextualReturnType, createPromiseLikeType(links.contextualReturnType)]);
|
|
76380
|
-
}
|
|
76381
|
-
return links.contextualReturnType;
|
|
76382
|
-
}
|
|
76383
76917
|
let contextualReturnType = getContextualReturnType(func, contextFlags);
|
|
76384
76918
|
if (contextualReturnType) {
|
|
76919
|
+
const functionFlags = getFunctionFlags(func);
|
|
76385
76920
|
if (functionFlags & 1 /* Generator */) {
|
|
76386
76921
|
const isAsyncGenerator = (functionFlags & 2 /* Async */) !== 0;
|
|
76387
76922
|
if (contextualReturnType.flags & 1048576 /* Union */) {
|
|
@@ -77079,13 +77614,6 @@ function createTypeChecker(host) {
|
|
|
77079
77614
|
if (index >= 0) {
|
|
77080
77615
|
return contextualTypes[index];
|
|
77081
77616
|
}
|
|
77082
|
-
const links = getNodeLinks(node);
|
|
77083
|
-
if (links.contextualReturnType) {
|
|
77084
|
-
if (node.flags & 65536 /* AwaitContext */) {
|
|
77085
|
-
return getUnionType([links.contextualReturnType, createPromiseLikeType(links.contextualReturnType)]);
|
|
77086
|
-
}
|
|
77087
|
-
return links.contextualReturnType;
|
|
77088
|
-
}
|
|
77089
77617
|
const { parent: parent2 } = node;
|
|
77090
77618
|
switch (parent2.kind) {
|
|
77091
77619
|
case 260 /* VariableDeclaration */:
|
|
@@ -77203,6 +77731,28 @@ function createTypeChecker(host) {
|
|
|
77203
77731
|
}
|
|
77204
77732
|
}
|
|
77205
77733
|
}
|
|
77734
|
+
function pushActiveMapper(mapper) {
|
|
77735
|
+
activeTypeMappers[activeTypeMappersCount] = mapper;
|
|
77736
|
+
activeTypeMappersCaches[activeTypeMappersCount] = /* @__PURE__ */ new Map();
|
|
77737
|
+
activeTypeMappersCount++;
|
|
77738
|
+
}
|
|
77739
|
+
function popActiveMapper() {
|
|
77740
|
+
activeTypeMappersCount--;
|
|
77741
|
+
}
|
|
77742
|
+
function findActiveMapper(mapper) {
|
|
77743
|
+
for (let i = activeTypeMappersCount - 1; i >= 0; i--) {
|
|
77744
|
+
if (mapper === activeTypeMappers[i]) {
|
|
77745
|
+
return i;
|
|
77746
|
+
}
|
|
77747
|
+
}
|
|
77748
|
+
return -1;
|
|
77749
|
+
}
|
|
77750
|
+
function clearActiveMapperCache(mapper) {
|
|
77751
|
+
const index = findActiveMapper(mapper);
|
|
77752
|
+
if (index !== -1) {
|
|
77753
|
+
activeTypeMappersCaches[index] = /* @__PURE__ */ new Map();
|
|
77754
|
+
}
|
|
77755
|
+
}
|
|
77206
77756
|
function getContextualImportAttributeType(node) {
|
|
77207
77757
|
return getTypeOfPropertyOfContextualType(getGlobalImportAttributesType(
|
|
77208
77758
|
/*reportErrors*/
|
|
@@ -79067,7 +79617,7 @@ function createTypeChecker(host) {
|
|
|
79067
79617
|
addErrorOrSuggestion(!isUncheckedJS || errorInfo.code !== Diagnostics.Property_0_may_not_exist_on_type_1_Did_you_mean_2.code, resultDiagnostic);
|
|
79068
79618
|
}
|
|
79069
79619
|
function containerSeemsToBeEmptyDomElement(containingType) {
|
|
79070
|
-
return compilerOptions.lib && !compilerOptions.lib.includes("dom") && everyContainedType(containingType, (type) => type.symbol && /^(?:EventTarget|Node|(?:HTML[a-zA-Z]*)?Element)$/.test(unescapeLeadingUnderscores(type.symbol.escapedName))) && isEmptyObjectType(containingType);
|
|
79620
|
+
return compilerOptions.lib && !compilerOptions.lib.includes("lib.dom.d.ts") && everyContainedType(containingType, (type) => type.symbol && /^(?:EventTarget|Node|(?:HTML[a-zA-Z]*)?Element)$/.test(unescapeLeadingUnderscores(type.symbol.escapedName))) && isEmptyObjectType(containingType);
|
|
79071
79621
|
}
|
|
79072
79622
|
function typeHasStaticProperty(propName, containingType) {
|
|
79073
79623
|
const prop = containingType.symbol && getPropertyOfType(getTypeOfSymbol(containingType.symbol), propName);
|
|
@@ -79514,11 +80064,11 @@ function createTypeChecker(host) {
|
|
|
79514
80064
|
const mapper = inferenceContext && (restType && restType.flags & 262144 /* TypeParameter */ ? inferenceContext.nonFixingMapper : inferenceContext.mapper);
|
|
79515
80065
|
const sourceSignature = mapper ? instantiateSignature(contextualSignature, mapper) : contextualSignature;
|
|
79516
80066
|
applyToParameterTypes(sourceSignature, signature, (source, target) => {
|
|
79517
|
-
inferTypes(context.inferences, source, target);
|
|
80067
|
+
inferTypes(context, context.inferences, source, target);
|
|
79518
80068
|
});
|
|
79519
80069
|
if (!inferenceContext) {
|
|
79520
80070
|
applyToReturnTypes(contextualSignature, signature, (source, target) => {
|
|
79521
|
-
inferTypes(context.inferences, source, target, 128 /* ReturnType */);
|
|
80071
|
+
inferTypes(context, context.inferences, source, target, 128 /* ReturnType */);
|
|
79522
80072
|
});
|
|
79523
80073
|
}
|
|
79524
80074
|
return getSignatureInstantiation(signature, getInferredTypes(context), isInJSFile(contextualSignature.declaration));
|
|
@@ -79526,7 +80076,7 @@ function createTypeChecker(host) {
|
|
|
79526
80076
|
function inferJsxTypeArguments(node, signature, checkMode, context) {
|
|
79527
80077
|
const paramType = getEffectiveFirstArgumentForJsxSignature(signature, node);
|
|
79528
80078
|
const checkAttrType = checkExpressionWithContextualType(node.attributes, paramType, context, checkMode);
|
|
79529
|
-
inferTypes(context.inferences, checkAttrType, paramType);
|
|
80079
|
+
inferTypes(context, context.inferences, checkAttrType, paramType);
|
|
79530
80080
|
return getInferredTypes(context);
|
|
79531
80081
|
}
|
|
79532
80082
|
function getThisArgumentType(thisArgumentNode) {
|
|
@@ -79553,11 +80103,11 @@ function createTypeChecker(host) {
|
|
|
79553
80103
|
const instantiatedType = instantiateType(contextualType, outerMapper);
|
|
79554
80104
|
const contextualSignature = getSingleCallSignature(instantiatedType);
|
|
79555
80105
|
const inferenceSourceType = contextualSignature && contextualSignature.typeParameters ? getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) : instantiatedType;
|
|
79556
|
-
inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* ReturnType */);
|
|
80106
|
+
inferTypes(context, context.inferences, inferenceSourceType, inferenceTargetType, 128 /* ReturnType */);
|
|
79557
80107
|
}
|
|
79558
80108
|
const returnContext = createInferenceContext(signature.typeParameters, signature, context.flags);
|
|
79559
80109
|
const returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper);
|
|
79560
|
-
inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType);
|
|
80110
|
+
inferTypes(returnContext, returnContext.inferences, returnSourceType, inferenceTargetType);
|
|
79561
80111
|
context.returnMapper = some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(cloneInferredPartOfContext(returnContext)) : void 0;
|
|
79562
80112
|
}
|
|
79563
80113
|
}
|
|
@@ -79573,7 +80123,7 @@ function createTypeChecker(host) {
|
|
|
79573
80123
|
const thisType = getThisTypeOfSignature(signature);
|
|
79574
80124
|
if (thisType && couldContainTypeVariables(thisType)) {
|
|
79575
80125
|
const thisArgumentNode = getThisArgumentOfCall(node);
|
|
79576
|
-
inferTypes(context.inferences, getThisArgumentType(thisArgumentNode), thisType);
|
|
80126
|
+
inferTypes(context, context.inferences, getThisArgumentType(thisArgumentNode), thisType);
|
|
79577
80127
|
}
|
|
79578
80128
|
for (let i = 0; i < argCount; i++) {
|
|
79579
80129
|
const arg = args[i];
|
|
@@ -79581,13 +80131,13 @@ function createTypeChecker(host) {
|
|
|
79581
80131
|
const paramType = getTypeAtPosition(signature, i);
|
|
79582
80132
|
if (couldContainTypeVariables(paramType)) {
|
|
79583
80133
|
const argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
|
|
79584
|
-
inferTypes(context.inferences, argType, paramType);
|
|
80134
|
+
inferTypes(context, context.inferences, argType, paramType);
|
|
79585
80135
|
}
|
|
79586
80136
|
}
|
|
79587
80137
|
}
|
|
79588
80138
|
if (restType && couldContainTypeVariables(restType)) {
|
|
79589
80139
|
const spreadType = getSpreadArgumentType(args, argCount, args.length, restType, context, checkMode);
|
|
79590
|
-
inferTypes(context.inferences, spreadType, restType);
|
|
80140
|
+
inferTypes(context, context.inferences, spreadType, restType);
|
|
79591
80141
|
}
|
|
79592
80142
|
return getInferredTypes(context);
|
|
79593
80143
|
}
|
|
@@ -81960,14 +82510,14 @@ function createTypeChecker(host) {
|
|
|
81960
82510
|
isOptionalDeclaration(declaration)
|
|
81961
82511
|
);
|
|
81962
82512
|
const target = getTypeAtPosition(context, i);
|
|
81963
|
-
inferTypes(inferenceContext.inferences, source, target);
|
|
82513
|
+
inferTypes(inferenceContext, inferenceContext.inferences, source, target);
|
|
81964
82514
|
}
|
|
81965
82515
|
}
|
|
81966
82516
|
const typeNode = signature.declaration && getEffectiveReturnTypeNode(signature.declaration);
|
|
81967
82517
|
if (typeNode) {
|
|
81968
82518
|
const source = getTypeFromTypeNode(typeNode);
|
|
81969
82519
|
const target = getReturnTypeOfSignature(context);
|
|
81970
|
-
inferTypes(inferenceContext.inferences, source, target);
|
|
82520
|
+
inferTypes(inferenceContext, inferenceContext.inferences, source, target);
|
|
81971
82521
|
}
|
|
81972
82522
|
}
|
|
81973
82523
|
function assignContextualParameterTypes(signature, context) {
|
|
@@ -84383,6 +84933,7 @@ function createTypeChecker(host) {
|
|
|
84383
84933
|
const inferences = map(context.inferences, (info) => createInferenceInfo(info.typeParameter));
|
|
84384
84934
|
applyToParameterTypes(instantiatedSignature, contextualSignature, (source, target) => {
|
|
84385
84935
|
inferTypes(
|
|
84936
|
+
context,
|
|
84386
84937
|
inferences,
|
|
84387
84938
|
source,
|
|
84388
84939
|
target,
|
|
@@ -84394,7 +84945,7 @@ function createTypeChecker(host) {
|
|
|
84394
84945
|
});
|
|
84395
84946
|
if (some(inferences, hasInferenceCandidates)) {
|
|
84396
84947
|
applyToReturnTypes(instantiatedSignature, contextualSignature, (source, target) => {
|
|
84397
|
-
inferTypes(inferences, source, target);
|
|
84948
|
+
inferTypes(context, inferences, source, target);
|
|
84398
84949
|
});
|
|
84399
84950
|
if (!hasOverlappingInferences(context.inferences, inferences)) {
|
|
84400
84951
|
mergeInferences(context.inferences, inferences);
|
|
@@ -88100,374 +88651,7 @@ function createTypeChecker(host) {
|
|
|
88100
88651
|
) : exprType;
|
|
88101
88652
|
const effectiveExpr = expr && getEffectiveCheckNode(expr);
|
|
88102
88653
|
const errorNode = inReturnStatement && !inConditionalExpression ? node : effectiveExpr;
|
|
88103
|
-
|
|
88104
|
-
checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, errorNode, effectiveExpr);
|
|
88105
|
-
return;
|
|
88106
|
-
}
|
|
88107
|
-
if (checkTypeAssignableTo(
|
|
88108
|
-
unwrappedExprType,
|
|
88109
|
-
unwrappedReturnType,
|
|
88110
|
-
/*errorNode*/
|
|
88111
|
-
void 0
|
|
88112
|
-
)) {
|
|
88113
|
-
return;
|
|
88114
|
-
}
|
|
88115
|
-
let narrowPosition = node;
|
|
88116
|
-
let narrowFlowNode = inReturnStatement && node.flowNode;
|
|
88117
|
-
if (expr && isConditionalExpression(expr.parent)) {
|
|
88118
|
-
narrowFlowNode = expr.parent.whenTrue === expr ? expr.parent.flowNodeWhenTrue : expr.parent.flowNodeWhenFalse;
|
|
88119
|
-
narrowPosition = expr;
|
|
88120
|
-
}
|
|
88121
|
-
if (!narrowFlowNode) {
|
|
88122
|
-
checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, errorNode, effectiveExpr);
|
|
88123
|
-
return;
|
|
88124
|
-
}
|
|
88125
|
-
const allTypeParameters = appendTypeParameters(getOuterTypeParameters(
|
|
88126
|
-
container,
|
|
88127
|
-
/*includeThisTypes*/
|
|
88128
|
-
false
|
|
88129
|
-
), getEffectiveTypeParameterDeclarations(container));
|
|
88130
|
-
const narrowableTypeParameters = allTypeParameters && getNarrowableTypeParameters(allTypeParameters);
|
|
88131
|
-
if (!narrowableTypeParameters || !narrowableTypeParameters.length || !isNarrowableReturnType(unwrappedReturnType)) {
|
|
88132
|
-
checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, errorNode, effectiveExpr);
|
|
88133
|
-
return;
|
|
88134
|
-
}
|
|
88135
|
-
const narrowedTypeParameters = [];
|
|
88136
|
-
const narrowedTypes = [];
|
|
88137
|
-
for (const [typeParam, symbol, narrowReference] of narrowableTypeParameters) {
|
|
88138
|
-
resetNodeId(narrowReference);
|
|
88139
|
-
let baseReference = narrowReference;
|
|
88140
|
-
while (isAccessExpression(baseReference)) {
|
|
88141
|
-
baseReference = baseReference.expression;
|
|
88142
|
-
}
|
|
88143
|
-
getNodeLinks(baseReference).resolvedSymbol = symbol;
|
|
88144
|
-
setParent(narrowReference, narrowPosition.parent);
|
|
88145
|
-
narrowReference.flowNode = narrowFlowNode;
|
|
88146
|
-
const initialType = getNarrowableTypeForReference(
|
|
88147
|
-
typeParam,
|
|
88148
|
-
narrowReference,
|
|
88149
|
-
/*checkMode*/
|
|
88150
|
-
void 0,
|
|
88151
|
-
/*forReturnTypeNarrowing*/
|
|
88152
|
-
true
|
|
88153
|
-
);
|
|
88154
|
-
if (initialType === typeParam) {
|
|
88155
|
-
continue;
|
|
88156
|
-
}
|
|
88157
|
-
const flowType = getFlowTypeOfReference(narrowReference, initialType);
|
|
88158
|
-
const exprType2 = getTypeFromFlowType(flowType);
|
|
88159
|
-
if (exprType2.flags & 3 /* AnyOrUnknown */ || isErrorType(exprType2) || exprType2 === typeParam || exprType2 === mapType(typeParam, getBaseConstraintOrType)) {
|
|
88160
|
-
continue;
|
|
88161
|
-
}
|
|
88162
|
-
const narrowedType = getSubstitutionType(
|
|
88163
|
-
typeParam,
|
|
88164
|
-
exprType2,
|
|
88165
|
-
/*isNarrowed*/
|
|
88166
|
-
true
|
|
88167
|
-
);
|
|
88168
|
-
narrowedTypeParameters.push(typeParam);
|
|
88169
|
-
narrowedTypes.push(narrowedType);
|
|
88170
|
-
}
|
|
88171
|
-
const narrowMapper = createTypeMapper(narrowedTypeParameters, narrowedTypes);
|
|
88172
|
-
const narrowedReturnType = instantiateType(
|
|
88173
|
-
unwrappedReturnType,
|
|
88174
|
-
narrowMapper
|
|
88175
|
-
);
|
|
88176
|
-
if (expr) {
|
|
88177
|
-
const links = getNodeLinks(expr);
|
|
88178
|
-
if (!links.contextualReturnType) {
|
|
88179
|
-
links.contextualReturnType = narrowedReturnType;
|
|
88180
|
-
}
|
|
88181
|
-
}
|
|
88182
|
-
const narrowedExprType = expr ? checkExpression(expr) : undefinedType;
|
|
88183
|
-
const narrowedUnwrappedExprType = functionFlags & 2 /* Async */ ? checkAwaitedType(
|
|
88184
|
-
narrowedExprType,
|
|
88185
|
-
/*withAlias*/
|
|
88186
|
-
false,
|
|
88187
|
-
node,
|
|
88188
|
-
Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member
|
|
88189
|
-
) : narrowedExprType;
|
|
88190
|
-
checkTypeAssignableToAndOptionallyElaborate(narrowedUnwrappedExprType, narrowedReturnType, errorNode, effectiveExpr);
|
|
88191
|
-
}
|
|
88192
|
-
function resetNodeId(node) {
|
|
88193
|
-
node.id = void 0;
|
|
88194
|
-
forEachChildRecursively(node, resetNodeId);
|
|
88195
|
-
}
|
|
88196
|
-
function getNarrowableTypeParameters(candidates) {
|
|
88197
|
-
const narrowableParams = [];
|
|
88198
|
-
for (const typeParam of candidates) {
|
|
88199
|
-
const constraint = getConstraintOfTypeParameter(typeParam);
|
|
88200
|
-
if (!constraint || !(constraint.flags & 1048576 /* Union */)) continue;
|
|
88201
|
-
if (typeParam.symbol && typeParam.symbol.declarations && typeParam.symbol.declarations.length === 1) {
|
|
88202
|
-
const declaration = typeParam.symbol.declarations[0];
|
|
88203
|
-
const container = isJSDocTemplateTag(declaration.parent) ? getJSDocHost(declaration.parent) : declaration.parent;
|
|
88204
|
-
if (!isFunctionLike(container)) continue;
|
|
88205
|
-
let paramReference;
|
|
88206
|
-
let referencePath;
|
|
88207
|
-
let hasInvalidReference = false;
|
|
88208
|
-
for (const paramDecl of container.parameters) {
|
|
88209
|
-
const typeNode = getEffectiveTypeAnnotationNode(paramDecl);
|
|
88210
|
-
if (!typeNode) continue;
|
|
88211
|
-
const result = getValidTypeParameterReference(typeNode, typeParam, []);
|
|
88212
|
-
if (!result) {
|
|
88213
|
-
hasInvalidReference = true;
|
|
88214
|
-
break;
|
|
88215
|
-
}
|
|
88216
|
-
if (isArray(result)) {
|
|
88217
|
-
if (referencePath) {
|
|
88218
|
-
hasInvalidReference = true;
|
|
88219
|
-
break;
|
|
88220
|
-
}
|
|
88221
|
-
referencePath = result;
|
|
88222
|
-
paramReference = paramDecl;
|
|
88223
|
-
}
|
|
88224
|
-
}
|
|
88225
|
-
if (!hasInvalidReference && referencePath && validateOptionality(paramReference, constraint, referencePath)) {
|
|
88226
|
-
const symbolAndReference = constructNarrowableReference(paramReference, referencePath);
|
|
88227
|
-
if (symbolAndReference) {
|
|
88228
|
-
if (symbolAndReference[0] && symbolAndReference[0] !== unknownSymbol) {
|
|
88229
|
-
narrowableParams.push([typeParam, symbolAndReference[0], symbolAndReference[1]]);
|
|
88230
|
-
}
|
|
88231
|
-
}
|
|
88232
|
-
}
|
|
88233
|
-
}
|
|
88234
|
-
}
|
|
88235
|
-
return narrowableParams;
|
|
88236
|
-
function isReferenceToTypeParameter(typeParam, node) {
|
|
88237
|
-
return getTypeFromTypeReference(node) === typeParam;
|
|
88238
|
-
}
|
|
88239
|
-
function isTypeParameterReferenced(typeParam, node) {
|
|
88240
|
-
return isReferenced(node);
|
|
88241
|
-
function isReferenced(node2) {
|
|
88242
|
-
if (isTypeReferenceNode(node2)) {
|
|
88243
|
-
return isReferenceToTypeParameter(typeParam, node2) || some(node2.typeArguments, isReferenced);
|
|
88244
|
-
}
|
|
88245
|
-
if (isTypeQueryNode(node2)) {
|
|
88246
|
-
return isTypeParameterPossiblyReferenced(typeParam, node2);
|
|
88247
|
-
}
|
|
88248
|
-
return !!forEachChild(node2, isReferenced);
|
|
88249
|
-
}
|
|
88250
|
-
}
|
|
88251
|
-
function getValidTypeParameterReference(typeNode, typeParam, path) {
|
|
88252
|
-
var _a;
|
|
88253
|
-
switch (typeNode.kind) {
|
|
88254
|
-
case 183 /* TypeReference */:
|
|
88255
|
-
const type = getTypeFromTypeReference(typeNode);
|
|
88256
|
-
if (type === typeParam) {
|
|
88257
|
-
return path;
|
|
88258
|
-
}
|
|
88259
|
-
const typeArgs = typeNode.typeArguments;
|
|
88260
|
-
const typeArgsReferencingT = typeArgs == null ? void 0 : typeArgs.filter((node) => isTypeParameterReferenced(typeParam, node));
|
|
88261
|
-
if (!typeArgsReferencingT || typeArgsReferencingT.length === 0) return true;
|
|
88262
|
-
if (typeArgsReferencingT && typeArgsReferencingT.length > 1) return false;
|
|
88263
|
-
const typeArg = typeArgsReferencingT[0];
|
|
88264
|
-
if (!(typeArg.kind & 183 /* TypeReference */)) return false;
|
|
88265
|
-
if (!type.symbol || !type.symbol.declarations || type.symbol.declarations.length !== 1) return false;
|
|
88266
|
-
const typeDeclaration = type.symbol.declarations[0];
|
|
88267
|
-
let aliasDeclaration;
|
|
88268
|
-
if (isTypeLiteralNode(typeDeclaration)) {
|
|
88269
|
-
aliasDeclaration = walkUpParenthesizedTypes(typeDeclaration.parent);
|
|
88270
|
-
if (!isTypeAliasDeclaration(aliasDeclaration)) return false;
|
|
88271
|
-
} else if (isInterfaceDeclaration(typeDeclaration)) {
|
|
88272
|
-
aliasDeclaration = typeDeclaration;
|
|
88273
|
-
} else {
|
|
88274
|
-
return false;
|
|
88275
|
-
}
|
|
88276
|
-
const typeArgIndex = typeArgs.findIndex((arg) => arg === typeArg);
|
|
88277
|
-
const matchingTypeParamDecl = (_a = aliasDeclaration.typeParameters) == null ? void 0 : _a[typeArgIndex];
|
|
88278
|
-
if (!matchingTypeParamDecl) return false;
|
|
88279
|
-
const matchingTypeParam = getDeclaredTypeOfTypeParameter(matchingTypeParamDecl.symbol);
|
|
88280
|
-
return getValidTypeParameterReference(typeDeclaration, matchingTypeParam, path);
|
|
88281
|
-
case 264 /* InterfaceDeclaration */:
|
|
88282
|
-
const extendsTypes = flatMap(typeNode.heritageClauses, (clause) => clause.types);
|
|
88283
|
-
const relevantExtendsTypes = extendsTypes.filter((node) => isTypeParameterReferenced(typeParam, node));
|
|
88284
|
-
if (relevantExtendsTypes && relevantExtendsTypes.length > 1) {
|
|
88285
|
-
return false;
|
|
88286
|
-
}
|
|
88287
|
-
const result = getValidTypeParameterReferenceFromTypeElements(typeNode.members, typeParam, path);
|
|
88288
|
-
if (relevantExtendsTypes && relevantExtendsTypes.length === 1) {
|
|
88289
|
-
if (result !== true) {
|
|
88290
|
-
return false;
|
|
88291
|
-
}
|
|
88292
|
-
return getValidTypeParameterReference(relevantExtendsTypes[0], typeParam, path);
|
|
88293
|
-
}
|
|
88294
|
-
return result;
|
|
88295
|
-
case 187 /* TypeLiteral */:
|
|
88296
|
-
return getValidTypeParameterReferenceFromTypeElements(typeNode.members, typeParam, path);
|
|
88297
|
-
case 193 /* IntersectionType */:
|
|
88298
|
-
let validPath;
|
|
88299
|
-
for (const type2 of typeNode.types) {
|
|
88300
|
-
const result2 = getValidTypeParameterReference(type2, typeParam, path);
|
|
88301
|
-
if (!result2) {
|
|
88302
|
-
return false;
|
|
88303
|
-
}
|
|
88304
|
-
if (isArray(result2)) {
|
|
88305
|
-
if (validPath) {
|
|
88306
|
-
return false;
|
|
88307
|
-
}
|
|
88308
|
-
validPath = result2;
|
|
88309
|
-
}
|
|
88310
|
-
}
|
|
88311
|
-
return validPath ?? true;
|
|
88312
|
-
default:
|
|
88313
|
-
return !isTypeParameterReferenced(typeParam, typeNode);
|
|
88314
|
-
}
|
|
88315
|
-
}
|
|
88316
|
-
function getValidTypeParameterReferenceFromTypeElements(members, typeParam, path) {
|
|
88317
|
-
let validPath;
|
|
88318
|
-
for (const member of members) {
|
|
88319
|
-
if (!isTypeParameterReferenced(typeParam, member)) {
|
|
88320
|
-
continue;
|
|
88321
|
-
}
|
|
88322
|
-
if (!isPropertySignature(member)) {
|
|
88323
|
-
return false;
|
|
88324
|
-
}
|
|
88325
|
-
if (!isIdentifier(member.name) && !isStringLiteral(member.name)) {
|
|
88326
|
-
return false;
|
|
88327
|
-
}
|
|
88328
|
-
const result = getValidTypeParameterReference(member.type, typeParam, [...path, member]);
|
|
88329
|
-
if (!result) {
|
|
88330
|
-
return false;
|
|
88331
|
-
}
|
|
88332
|
-
if (isArray(result)) {
|
|
88333
|
-
if (validPath) {
|
|
88334
|
-
return false;
|
|
88335
|
-
}
|
|
88336
|
-
validPath = result;
|
|
88337
|
-
}
|
|
88338
|
-
}
|
|
88339
|
-
return validPath ?? true;
|
|
88340
|
-
}
|
|
88341
|
-
function validateOptionality(paramDecl, constraint, path) {
|
|
88342
|
-
for (let i = 0; i < path.length - 1; i++) {
|
|
88343
|
-
if (path[i].questionToken) {
|
|
88344
|
-
return false;
|
|
88345
|
-
}
|
|
88346
|
-
}
|
|
88347
|
-
const paramIsOptional = !!paramDecl.questionToken || isJSDocOptionalParameter(paramDecl);
|
|
88348
|
-
if (paramIsOptional && path.length > 0) {
|
|
88349
|
-
return false;
|
|
88350
|
-
}
|
|
88351
|
-
const isOptional = paramIsOptional || path.length > 0 && path[path.length - 1].questionToken;
|
|
88352
|
-
if (isOptional && strictNullChecks && !containsUndefinedType(constraint)) {
|
|
88353
|
-
return false;
|
|
88354
|
-
}
|
|
88355
|
-
return true;
|
|
88356
|
-
}
|
|
88357
|
-
function constructNarrowableReference(paramDecl, path) {
|
|
88358
|
-
let currentName = paramDecl.name;
|
|
88359
|
-
let i = 0;
|
|
88360
|
-
for (; i < path.length; i++) {
|
|
88361
|
-
if (isIdentifier(currentName)) {
|
|
88362
|
-
break;
|
|
88363
|
-
} else if (isObjectBindingPattern(currentName)) {
|
|
88364
|
-
const name = path[i].name;
|
|
88365
|
-
let nameText;
|
|
88366
|
-
if (isIdentifier(name)) nameText = name.escapedText;
|
|
88367
|
-
else {
|
|
88368
|
-
const rawText = getLiteralPropertyNameText(name);
|
|
88369
|
-
if (rawText) nameText = escapeLeadingUnderscores(rawText);
|
|
88370
|
-
}
|
|
88371
|
-
const element = currentName.elements.find((element2) => {
|
|
88372
|
-
const propertyName = getDestructuringPropertyName(element2);
|
|
88373
|
-
const propertyNameText = propertyName && escapeLeadingUnderscores(propertyName);
|
|
88374
|
-
return nameText && propertyNameText && nameText === propertyNameText;
|
|
88375
|
-
});
|
|
88376
|
-
if (!element) {
|
|
88377
|
-
return void 0;
|
|
88378
|
-
}
|
|
88379
|
-
currentName = element.name;
|
|
88380
|
-
} else {
|
|
88381
|
-
return void 0;
|
|
88382
|
-
}
|
|
88383
|
-
}
|
|
88384
|
-
if (!isIdentifier(currentName)) {
|
|
88385
|
-
return void 0;
|
|
88386
|
-
}
|
|
88387
|
-
let result = factory.cloneNode(currentName);
|
|
88388
|
-
const initialSymbol = getSymbolOfDeclaration(currentName.parent);
|
|
88389
|
-
for (let j = i; j < path.length; j++) {
|
|
88390
|
-
result = addName(result, path[j].name);
|
|
88391
|
-
}
|
|
88392
|
-
return [initialSymbol, result];
|
|
88393
|
-
}
|
|
88394
|
-
function addName(exp, name) {
|
|
88395
|
-
name = factory.cloneNode(name);
|
|
88396
|
-
if (isIdentifier(name)) {
|
|
88397
|
-
const accessExp = factory.createPropertyAccessExpression(exp, name);
|
|
88398
|
-
setParent(name, accessExp);
|
|
88399
|
-
setParent(exp, accessExp);
|
|
88400
|
-
return accessExp;
|
|
88401
|
-
} else {
|
|
88402
|
-
const accessExp = factory.createElementAccessExpression(exp, name);
|
|
88403
|
-
setParent(name, accessExp);
|
|
88404
|
-
setParent(exp, accessExp);
|
|
88405
|
-
return accessExp;
|
|
88406
|
-
}
|
|
88407
|
-
}
|
|
88408
|
-
}
|
|
88409
|
-
function isNarrowableReturnType(returnType) {
|
|
88410
|
-
return isConditionalType(returnType) ? isNarrowableConditionalType(
|
|
88411
|
-
returnType,
|
|
88412
|
-
/*hadNonPrimitiveExtendsType*/
|
|
88413
|
-
[]
|
|
88414
|
-
) : !!(returnType.indexType.flags & 262144 /* TypeParameter */);
|
|
88415
|
-
}
|
|
88416
|
-
function isNarrowableConditionalType(type, hadNonPrimitiveExtendsType, mapper) {
|
|
88417
|
-
const typeArguments = mapper && map(type.root.outerTypeParameters, (t) => {
|
|
88418
|
-
const mapped = getMappedType(t, mapper);
|
|
88419
|
-
if (isNarrowingSubstitutionType(mapped)) {
|
|
88420
|
-
return mapped.baseType;
|
|
88421
|
-
}
|
|
88422
|
-
return mapped;
|
|
88423
|
-
});
|
|
88424
|
-
const id = `${type.id}:${getTypeListId(typeArguments)}:${getTypeListId(hadNonPrimitiveExtendsType)}`;
|
|
88425
|
-
let result = narrowableReturnTypeCache.get(id);
|
|
88426
|
-
if (result === void 0) {
|
|
88427
|
-
const nonNarrowingMapper = type.root.outerTypeParameters && typeArguments && createTypeMapper(type.root.outerTypeParameters, typeArguments);
|
|
88428
|
-
const instantiatedType = instantiateType(type, nonNarrowingMapper);
|
|
88429
|
-
result = isConditionalType(instantiatedType) && isNarrowableConditionalTypeWorker(instantiatedType, hadNonPrimitiveExtendsType);
|
|
88430
|
-
narrowableReturnTypeCache.set(id, result);
|
|
88431
|
-
}
|
|
88432
|
-
return result;
|
|
88433
|
-
}
|
|
88434
|
-
function isNarrowableConditionalTypeWorker(type, hadNonPrimitiveExtendsType) {
|
|
88435
|
-
if (!type.root.isDistributive) {
|
|
88436
|
-
return false;
|
|
88437
|
-
}
|
|
88438
|
-
if (type.root.inferTypeParameters) {
|
|
88439
|
-
return false;
|
|
88440
|
-
}
|
|
88441
|
-
if (!(type.checkType.flags & 262144 /* TypeParameter */)) {
|
|
88442
|
-
return false;
|
|
88443
|
-
}
|
|
88444
|
-
const constraintType = getConstraintOfTypeParameter(type.checkType);
|
|
88445
|
-
if (!constraintType || !(constraintType.flags & 1048576 /* Union */)) {
|
|
88446
|
-
return false;
|
|
88447
|
-
}
|
|
88448
|
-
if (!everyType(type.extendsType, (extendsType) => some(
|
|
88449
|
-
constraintType.types,
|
|
88450
|
-
(constraintType2) => isTypeAssignableTo(constraintType2, extendsType)
|
|
88451
|
-
))) {
|
|
88452
|
-
return false;
|
|
88453
|
-
}
|
|
88454
|
-
const hasNonPrimitive = someType(type.extendsType, (type2) => (type2.flags & 402784252 /* Primitive */) === 0);
|
|
88455
|
-
if (hasNonPrimitive && hadNonPrimitiveExtendsType.includes(type.checkType)) {
|
|
88456
|
-
return false;
|
|
88457
|
-
}
|
|
88458
|
-
if (hasNonPrimitive) {
|
|
88459
|
-
hadNonPrimitiveExtendsType = hadNonPrimitiveExtendsType.slice();
|
|
88460
|
-
hadNonPrimitiveExtendsType.push(type.checkType);
|
|
88461
|
-
}
|
|
88462
|
-
const trueType2 = getTrueTypeFromConditionalType(type);
|
|
88463
|
-
const isValidTrueType = isConditionalType(trueType2) ? isNarrowableConditionalType(trueType2, hadNonPrimitiveExtendsType) : true;
|
|
88464
|
-
if (!isValidTrueType) return false;
|
|
88465
|
-
const falseType2 = getFalseTypeFromConditionalType(type);
|
|
88466
|
-
const isValidFalseType = isConditionalType(falseType2) ? isNarrowableConditionalType(falseType2, hadNonPrimitiveExtendsType) : falseType2 === neverType;
|
|
88467
|
-
return isValidFalseType;
|
|
88468
|
-
}
|
|
88469
|
-
function isConditionalType(type) {
|
|
88470
|
-
return !!(type.flags & 16777216 /* Conditional */);
|
|
88654
|
+
checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, errorNode, effectiveExpr);
|
|
88471
88655
|
}
|
|
88472
88656
|
function checkWithStatement(node) {
|
|
88473
88657
|
if (!checkGrammarStatementInAmbientContext(node)) {
|
|
@@ -92489,6 +92673,9 @@ function createTypeChecker(host) {
|
|
|
92489
92673
|
tracker.trackSymbol(name, enclosing, 111551 /* Value */);
|
|
92490
92674
|
}
|
|
92491
92675
|
}
|
|
92676
|
+
},
|
|
92677
|
+
symbolToDeclarations: (symbol, meaning, flags, verbosityLevel, out) => {
|
|
92678
|
+
return nodeBuilder.symbolToDeclarations(symbol, meaning, flags, verbosityLevel, out);
|
|
92492
92679
|
}
|
|
92493
92680
|
};
|
|
92494
92681
|
function isImportRequiredByAugmentation(node) {
|
|
@@ -120585,7 +120772,8 @@ var notImplementedResolver = {
|
|
|
120585
120772
|
getDeclarationStatementsForSourceFile: notImplemented,
|
|
120586
120773
|
isImportRequiredByAugmentation: notImplemented,
|
|
120587
120774
|
isDefinitelyReferenceToGlobalSymbolObject: notImplemented,
|
|
120588
|
-
createLateBoundIndexSignatures: notImplemented
|
|
120775
|
+
createLateBoundIndexSignatures: notImplemented,
|
|
120776
|
+
symbolToDeclarations: notImplemented
|
|
120589
120777
|
};
|
|
120590
120778
|
var createPrinterWithDefaults = /* @__PURE__ */ memoize(() => createPrinter({}));
|
|
120591
120779
|
var createPrinterWithRemoveComments = /* @__PURE__ */ memoize(() => createPrinter({ removeComments: true }));
|
|
@@ -140720,9 +140908,9 @@ function mapToDisplayParts(writeDisplayParts) {
|
|
|
140720
140908
|
displayPartWriter.clear();
|
|
140721
140909
|
}
|
|
140722
140910
|
}
|
|
140723
|
-
function typeToDisplayParts(typechecker, type, enclosingDeclaration, flags = 0 /* None
|
|
140911
|
+
function typeToDisplayParts(typechecker, type, enclosingDeclaration, flags = 0 /* None */, verbosityLevel, out) {
|
|
140724
140912
|
return mapToDisplayParts((writer) => {
|
|
140725
|
-
typechecker.writeType(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */ | 16384 /* UseAliasDefinedOutsideCurrentScope */, writer);
|
|
140913
|
+
typechecker.writeType(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */ | 16384 /* UseAliasDefinedOutsideCurrentScope */, writer, verbosityLevel, out);
|
|
140726
140914
|
});
|
|
140727
140915
|
}
|
|
140728
140916
|
function symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration, meaning, flags = 0 /* None */) {
|
|
@@ -140730,7 +140918,7 @@ function symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration, meaning
|
|
|
140730
140918
|
typeChecker.writeSymbol(symbol, enclosingDeclaration, meaning, flags | 8 /* UseAliasDefinedOutsideCurrentScope */, writer);
|
|
140731
140919
|
});
|
|
140732
140920
|
}
|
|
140733
|
-
function signatureToDisplayParts(typechecker, signature, enclosingDeclaration, flags = 0 /* None
|
|
140921
|
+
function signatureToDisplayParts(typechecker, signature, enclosingDeclaration, flags = 0 /* None */, verbosityLevel, out) {
|
|
140734
140922
|
flags |= 16384 /* UseAliasDefinedOutsideCurrentScope */ | 1024 /* MultilineObjectLiterals */ | 32 /* WriteTypeArgumentsOfSignature */ | 8192 /* OmitParameterModifiers */;
|
|
140735
140923
|
return mapToDisplayParts((writer) => {
|
|
140736
140924
|
typechecker.writeSignature(
|
|
@@ -140739,7 +140927,9 @@ function signatureToDisplayParts(typechecker, signature, enclosingDeclaration, f
|
|
|
140739
140927
|
flags,
|
|
140740
140928
|
/*kind*/
|
|
140741
140929
|
void 0,
|
|
140742
|
-
writer
|
|
140930
|
+
writer,
|
|
140931
|
+
verbosityLevel,
|
|
140932
|
+
out
|
|
140743
140933
|
);
|
|
140744
140934
|
});
|
|
140745
140935
|
}
|
|
@@ -140778,74 +140968,6 @@ function getPrecedingNonSpaceCharacterPosition(text, position) {
|
|
|
140778
140968
|
}
|
|
140779
140969
|
return position + 1;
|
|
140780
140970
|
}
|
|
140781
|
-
function getSynthesizedDeepClone(node, includeTrivia = true) {
|
|
140782
|
-
const clone2 = node && getSynthesizedDeepCloneWorker(node);
|
|
140783
|
-
if (clone2 && !includeTrivia) suppressLeadingAndTrailingTrivia(clone2);
|
|
140784
|
-
return setParentRecursive(
|
|
140785
|
-
clone2,
|
|
140786
|
-
/*incremental*/
|
|
140787
|
-
false
|
|
140788
|
-
);
|
|
140789
|
-
}
|
|
140790
|
-
function getSynthesizedDeepCloneWithReplacements(node, includeTrivia, replaceNode) {
|
|
140791
|
-
let clone2 = replaceNode(node);
|
|
140792
|
-
if (clone2) {
|
|
140793
|
-
setOriginalNode(clone2, node);
|
|
140794
|
-
} else {
|
|
140795
|
-
clone2 = getSynthesizedDeepCloneWorker(node, replaceNode);
|
|
140796
|
-
}
|
|
140797
|
-
if (clone2 && !includeTrivia) suppressLeadingAndTrailingTrivia(clone2);
|
|
140798
|
-
return clone2;
|
|
140799
|
-
}
|
|
140800
|
-
function getSynthesizedDeepCloneWorker(node, replaceNode) {
|
|
140801
|
-
const nodeClone = replaceNode ? (n) => getSynthesizedDeepCloneWithReplacements(
|
|
140802
|
-
n,
|
|
140803
|
-
/*includeTrivia*/
|
|
140804
|
-
true,
|
|
140805
|
-
replaceNode
|
|
140806
|
-
) : getSynthesizedDeepClone;
|
|
140807
|
-
const nodesClone = replaceNode ? (ns) => ns && getSynthesizedDeepClonesWithReplacements(
|
|
140808
|
-
ns,
|
|
140809
|
-
/*includeTrivia*/
|
|
140810
|
-
true,
|
|
140811
|
-
replaceNode
|
|
140812
|
-
) : (ns) => ns && getSynthesizedDeepClones(ns);
|
|
140813
|
-
const visited = visitEachChild(
|
|
140814
|
-
node,
|
|
140815
|
-
nodeClone,
|
|
140816
|
-
/*context*/
|
|
140817
|
-
void 0,
|
|
140818
|
-
nodesClone,
|
|
140819
|
-
nodeClone
|
|
140820
|
-
);
|
|
140821
|
-
if (visited === node) {
|
|
140822
|
-
const clone2 = isStringLiteral(node) ? setOriginalNode(factory.createStringLiteralFromNode(node), node) : isNumericLiteral(node) ? setOriginalNode(factory.createNumericLiteral(node.text, node.numericLiteralFlags), node) : factory.cloneNode(node);
|
|
140823
|
-
return setTextRange(clone2, node);
|
|
140824
|
-
}
|
|
140825
|
-
visited.parent = void 0;
|
|
140826
|
-
return visited;
|
|
140827
|
-
}
|
|
140828
|
-
function getSynthesizedDeepClones(nodes, includeTrivia = true) {
|
|
140829
|
-
if (nodes) {
|
|
140830
|
-
const cloned = factory.createNodeArray(nodes.map((n) => getSynthesizedDeepClone(n, includeTrivia)), nodes.hasTrailingComma);
|
|
140831
|
-
setTextRange(cloned, nodes);
|
|
140832
|
-
return cloned;
|
|
140833
|
-
}
|
|
140834
|
-
return nodes;
|
|
140835
|
-
}
|
|
140836
|
-
function getSynthesizedDeepClonesWithReplacements(nodes, includeTrivia, replaceNode) {
|
|
140837
|
-
return factory.createNodeArray(nodes.map((n) => getSynthesizedDeepCloneWithReplacements(n, includeTrivia, replaceNode)), nodes.hasTrailingComma);
|
|
140838
|
-
}
|
|
140839
|
-
function suppressLeadingAndTrailingTrivia(node) {
|
|
140840
|
-
suppressLeadingTrivia(node);
|
|
140841
|
-
suppressTrailingTrivia(node);
|
|
140842
|
-
}
|
|
140843
|
-
function suppressLeadingTrivia(node) {
|
|
140844
|
-
addEmitFlagsRecursively(node, 1024 /* NoLeadingComments */, getFirstChild);
|
|
140845
|
-
}
|
|
140846
|
-
function suppressTrailingTrivia(node) {
|
|
140847
|
-
addEmitFlagsRecursively(node, 2048 /* NoTrailingComments */, getLastChild);
|
|
140848
|
-
}
|
|
140849
140971
|
function copyComments(sourceNode, targetNode) {
|
|
140850
140972
|
const sourceFile = sourceNode.getSourceFile();
|
|
140851
140973
|
const text = sourceFile.text;
|
|
@@ -140864,14 +140986,6 @@ function hasLeadingLineBreak(node, text) {
|
|
|
140864
140986
|
}
|
|
140865
140987
|
return false;
|
|
140866
140988
|
}
|
|
140867
|
-
function addEmitFlagsRecursively(node, flag, getChild) {
|
|
140868
|
-
addEmitFlags(node, flag);
|
|
140869
|
-
const child = getChild(node);
|
|
140870
|
-
if (child) addEmitFlagsRecursively(child, flag, getChild);
|
|
140871
|
-
}
|
|
140872
|
-
function getFirstChild(node) {
|
|
140873
|
-
return node.forEachChild((child) => child);
|
|
140874
|
-
}
|
|
140875
140989
|
function getUniqueName(baseName, sourceFile) {
|
|
140876
140990
|
let nameText = baseName;
|
|
140877
140991
|
for (let i = 1; !isFileLevelUniqueName(sourceFile, nameText); i++) {
|
|
@@ -152688,7 +152802,7 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
|
|
|
152688
152802
|
synchronizeHostData();
|
|
152689
152803
|
return ts_Completions_exports.getCompletionEntrySymbol(program, log, getValidSourceFile(fileName), position, { name, source }, host, preferences);
|
|
152690
152804
|
}
|
|
152691
|
-
function getQuickInfoAtPosition(fileName, position) {
|
|
152805
|
+
function getQuickInfoAtPosition(fileName, position, verbosityLevel) {
|
|
152692
152806
|
synchronizeHostData();
|
|
152693
152807
|
const sourceFile = getValidSourceFile(fileName);
|
|
152694
152808
|
const node = getTouchingPropertyName(sourceFile, position);
|
|
@@ -152704,19 +152818,41 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
|
|
|
152704
152818
|
kind: "" /* unknown */,
|
|
152705
152819
|
kindModifiers: "" /* none */,
|
|
152706
152820
|
textSpan: createTextSpanFromNode(nodeForQuickInfo, sourceFile),
|
|
152707
|
-
displayParts: typeChecker.runWithCancellationToken(cancellationToken, (typeChecker2) => typeToDisplayParts(
|
|
152821
|
+
displayParts: typeChecker.runWithCancellationToken(cancellationToken, (typeChecker2) => typeToDisplayParts(
|
|
152822
|
+
typeChecker2,
|
|
152823
|
+
type,
|
|
152824
|
+
getContainerNode(nodeForQuickInfo),
|
|
152825
|
+
/*flags*/
|
|
152826
|
+
void 0,
|
|
152827
|
+
verbosityLevel
|
|
152828
|
+
)),
|
|
152708
152829
|
documentation: type.symbol ? type.symbol.getDocumentationComment(typeChecker) : void 0,
|
|
152709
152830
|
tags: type.symbol ? type.symbol.getJsDocTags(typeChecker) : void 0
|
|
152710
152831
|
};
|
|
152711
152832
|
}
|
|
152712
|
-
const { symbolKind, displayParts, documentation, tags } = typeChecker.runWithCancellationToken(
|
|
152833
|
+
const { symbolKind, displayParts, documentation, tags, canIncreaseVerbosityLevel } = typeChecker.runWithCancellationToken(
|
|
152834
|
+
cancellationToken,
|
|
152835
|
+
(typeChecker2) => ts_SymbolDisplay_exports.getSymbolDisplayPartsDocumentationAndSymbolKind(
|
|
152836
|
+
typeChecker2,
|
|
152837
|
+
symbol,
|
|
152838
|
+
sourceFile,
|
|
152839
|
+
getContainerNode(nodeForQuickInfo),
|
|
152840
|
+
nodeForQuickInfo,
|
|
152841
|
+
/*semanticMeaning*/
|
|
152842
|
+
void 0,
|
|
152843
|
+
/*alias*/
|
|
152844
|
+
void 0,
|
|
152845
|
+
verbosityLevel
|
|
152846
|
+
)
|
|
152847
|
+
);
|
|
152713
152848
|
return {
|
|
152714
152849
|
kind: symbolKind,
|
|
152715
152850
|
kindModifiers: ts_SymbolDisplay_exports.getSymbolModifiers(typeChecker, symbol),
|
|
152716
152851
|
textSpan: createTextSpanFromNode(nodeForQuickInfo, sourceFile),
|
|
152717
152852
|
displayParts,
|
|
152718
152853
|
documentation,
|
|
152719
|
-
tags
|
|
152854
|
+
tags,
|
|
152855
|
+
canIncreaseVerbosityLevel
|
|
152720
152856
|
};
|
|
152721
152857
|
}
|
|
152722
152858
|
function preparePasteEditsForFile(fileName, copiedTextRange) {
|
|
@@ -167954,8 +168090,13 @@ function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, con
|
|
|
167954
168090
|
if (isExportAssignment(location.parent)) {
|
|
167955
168091
|
return true;
|
|
167956
168092
|
}
|
|
167957
|
-
if (tryCast(closestSymbolDeclaration, isVariableDeclaration)
|
|
167958
|
-
|
|
168093
|
+
if (closestSymbolDeclaration && tryCast(closestSymbolDeclaration, isVariableDeclaration)) {
|
|
168094
|
+
if (symbol.valueDeclaration === closestSymbolDeclaration) {
|
|
168095
|
+
return false;
|
|
168096
|
+
}
|
|
168097
|
+
if (isBindingPattern(closestSymbolDeclaration.name) && closestSymbolDeclaration.name.elements.some((e) => e === symbol.valueDeclaration)) {
|
|
168098
|
+
return false;
|
|
168099
|
+
}
|
|
167959
168100
|
}
|
|
167960
168101
|
const symbolDeclaration = symbol.valueDeclaration ?? ((_a = symbol.declarations) == null ? void 0 : _a[0]);
|
|
167961
168102
|
if (closestSymbolDeclaration && symbolDeclaration) {
|
|
@@ -177807,7 +177948,7 @@ function getSymbolModifiers(typeChecker, symbol) {
|
|
|
177807
177948
|
}
|
|
177808
177949
|
return modifiers.size > 0 ? arrayFrom(modifiers.values()).join(",") : "" /* none */;
|
|
177809
177950
|
}
|
|
177810
|
-
function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker, symbol, sourceFile, enclosingDeclaration, location, type, semanticMeaning, alias) {
|
|
177951
|
+
function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker, symbol, sourceFile, enclosingDeclaration, location, type, semanticMeaning, alias, verbosityLevel) {
|
|
177811
177952
|
var _a;
|
|
177812
177953
|
const displayParts = [];
|
|
177813
177954
|
let documentation = [];
|
|
@@ -177819,12 +177960,17 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker, symb
|
|
|
177819
177960
|
let documentationFromAlias;
|
|
177820
177961
|
let tagsFromAlias;
|
|
177821
177962
|
let hasMultipleSignatures = false;
|
|
177963
|
+
const typeWriterOut = { canIncreaseExpansionDepth: false, truncated: false };
|
|
177964
|
+
let symbolWasExpanded = false;
|
|
177822
177965
|
if (location.kind === 110 /* ThisKeyword */ && !isThisExpression) {
|
|
177823
177966
|
return { displayParts: [keywordPart(110 /* ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* primitiveType */, tags: void 0 };
|
|
177824
177967
|
}
|
|
177825
177968
|
if (symbolKind !== "" /* unknown */ || symbolFlags & 32 /* Class */ || symbolFlags & 2097152 /* Alias */) {
|
|
177826
177969
|
if (symbolKind === "getter" /* memberGetAccessorElement */ || symbolKind === "setter" /* memberSetAccessorElement */) {
|
|
177827
|
-
const declaration = find(
|
|
177970
|
+
const declaration = find(
|
|
177971
|
+
symbol.declarations,
|
|
177972
|
+
(declaration2) => declaration2.name === location && declaration2.kind !== 211 /* PropertyAccessExpression */
|
|
177973
|
+
);
|
|
177828
177974
|
if (declaration) {
|
|
177829
177975
|
switch (declaration.kind) {
|
|
177830
177976
|
case 177 /* GetAccessor */:
|
|
@@ -177953,21 +178099,28 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker, symb
|
|
|
177953
178099
|
}
|
|
177954
178100
|
if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) {
|
|
177955
178101
|
addAliasPrefixIfNecessary();
|
|
177956
|
-
|
|
178102
|
+
const classExpression = getDeclarationOfKind(symbol, 231 /* ClassExpression */);
|
|
178103
|
+
if (classExpression) {
|
|
177957
178104
|
pushSymbolKind("local class" /* localClassElement */);
|
|
177958
|
-
|
|
177959
|
-
|
|
178105
|
+
displayParts.push(spacePart());
|
|
178106
|
+
}
|
|
178107
|
+
if (!tryExpandSymbol(symbol, semanticMeaning)) {
|
|
178108
|
+
if (!classExpression) {
|
|
178109
|
+
displayParts.push(keywordPart(86 /* ClassKeyword */));
|
|
178110
|
+
displayParts.push(spacePart());
|
|
178111
|
+
}
|
|
178112
|
+
addFullSymbolName(symbol);
|
|
178113
|
+
writeTypeParametersOfSymbol(symbol, sourceFile);
|
|
177960
178114
|
}
|
|
177961
|
-
displayParts.push(spacePart());
|
|
177962
|
-
addFullSymbolName(symbol);
|
|
177963
|
-
writeTypeParametersOfSymbol(symbol, sourceFile);
|
|
177964
178115
|
}
|
|
177965
178116
|
if (symbolFlags & 64 /* Interface */ && semanticMeaning & 2 /* Type */) {
|
|
177966
178117
|
prefixNextMeaning();
|
|
177967
|
-
|
|
177968
|
-
|
|
177969
|
-
|
|
177970
|
-
|
|
178118
|
+
if (!tryExpandSymbol(symbol, semanticMeaning)) {
|
|
178119
|
+
displayParts.push(keywordPart(120 /* InterfaceKeyword */));
|
|
178120
|
+
displayParts.push(spacePart());
|
|
178121
|
+
addFullSymbolName(symbol);
|
|
178122
|
+
writeTypeParametersOfSymbol(symbol, sourceFile);
|
|
178123
|
+
}
|
|
177971
178124
|
}
|
|
177972
178125
|
if (symbolFlags & 524288 /* TypeAlias */ && semanticMeaning & 2 /* Type */) {
|
|
177973
178126
|
prefixNextMeaning();
|
|
@@ -177978,25 +178131,43 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker, symb
|
|
|
177978
178131
|
displayParts.push(spacePart());
|
|
177979
178132
|
displayParts.push(operatorPart(64 /* EqualsToken */));
|
|
177980
178133
|
displayParts.push(spacePart());
|
|
177981
|
-
addRange(
|
|
178134
|
+
addRange(
|
|
178135
|
+
displayParts,
|
|
178136
|
+
typeToDisplayParts(
|
|
178137
|
+
typeChecker,
|
|
178138
|
+
location.parent && isConstTypeReference(location.parent) ? typeChecker.getTypeAtLocation(location.parent) : typeChecker.getDeclaredTypeOfSymbol(symbol),
|
|
178139
|
+
enclosingDeclaration,
|
|
178140
|
+
8388608 /* InTypeAlias */,
|
|
178141
|
+
verbosityLevel,
|
|
178142
|
+
typeWriterOut
|
|
178143
|
+
)
|
|
178144
|
+
);
|
|
177982
178145
|
}
|
|
177983
178146
|
if (symbolFlags & 384 /* Enum */) {
|
|
177984
178147
|
prefixNextMeaning();
|
|
177985
|
-
if (
|
|
177986
|
-
|
|
178148
|
+
if (!tryExpandSymbol(symbol, semanticMeaning)) {
|
|
178149
|
+
if (some(symbol.declarations, (d) => isEnumDeclaration(d) && isEnumConst(d))) {
|
|
178150
|
+
displayParts.push(keywordPart(87 /* ConstKeyword */));
|
|
178151
|
+
displayParts.push(spacePart());
|
|
178152
|
+
}
|
|
178153
|
+
displayParts.push(keywordPart(94 /* EnumKeyword */));
|
|
177987
178154
|
displayParts.push(spacePart());
|
|
178155
|
+
addFullSymbolName(
|
|
178156
|
+
symbol,
|
|
178157
|
+
/*enclosingDeclaration*/
|
|
178158
|
+
void 0
|
|
178159
|
+
);
|
|
177988
178160
|
}
|
|
177989
|
-
displayParts.push(keywordPart(94 /* EnumKeyword */));
|
|
177990
|
-
displayParts.push(spacePart());
|
|
177991
|
-
addFullSymbolName(symbol);
|
|
177992
178161
|
}
|
|
177993
178162
|
if (symbolFlags & 1536 /* Module */ && !isThisExpression) {
|
|
177994
178163
|
prefixNextMeaning();
|
|
177995
|
-
|
|
177996
|
-
|
|
177997
|
-
|
|
177998
|
-
|
|
177999
|
-
|
|
178164
|
+
if (!tryExpandSymbol(symbol, semanticMeaning)) {
|
|
178165
|
+
const declaration = getDeclarationOfKind(symbol, 267 /* ModuleDeclaration */);
|
|
178166
|
+
const isNamespace = declaration && declaration.name && declaration.name.kind === 80 /* Identifier */;
|
|
178167
|
+
displayParts.push(keywordPart(isNamespace ? 145 /* NamespaceKeyword */ : 144 /* ModuleKeyword */));
|
|
178168
|
+
displayParts.push(spacePart());
|
|
178169
|
+
addFullSymbolName(symbol);
|
|
178170
|
+
}
|
|
178000
178171
|
}
|
|
178001
178172
|
if (symbolFlags & 262144 /* TypeParameter */ && semanticMeaning & 2 /* Type */) {
|
|
178002
178173
|
prefixNextMeaning();
|
|
@@ -178066,12 +178237,16 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker, symb
|
|
|
178066
178237
|
declarationName,
|
|
178067
178238
|
type,
|
|
178068
178239
|
semanticMeaning,
|
|
178069
|
-
shouldUseAliasName ? symbol : resolvedSymbol
|
|
178240
|
+
shouldUseAliasName ? symbol : resolvedSymbol,
|
|
178241
|
+
verbosityLevel
|
|
178070
178242
|
);
|
|
178071
178243
|
displayParts.push(...resolvedInfo.displayParts);
|
|
178072
178244
|
displayParts.push(lineBreakPart());
|
|
178073
178245
|
documentationFromAlias = resolvedInfo.documentation;
|
|
178074
178246
|
tagsFromAlias = resolvedInfo.tags;
|
|
178247
|
+
if (typeWriterOut && resolvedInfo.canIncreaseVerbosityLevel) {
|
|
178248
|
+
typeWriterOut.canIncreaseExpansionDepth = true;
|
|
178249
|
+
}
|
|
178075
178250
|
} else {
|
|
178076
178251
|
documentationFromAlias = resolvedSymbol.getContextualDocumentationComment(resolvedNode, typeChecker);
|
|
178077
178252
|
tagsFromAlias = resolvedSymbol.getJsDocTags(typeChecker);
|
|
@@ -178137,12 +178312,33 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker, symb
|
|
|
178137
178312
|
displayParts.push(spacePart());
|
|
178138
178313
|
if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */ && symbolKind !== "index" /* indexSignatureElement */) {
|
|
178139
178314
|
const typeParameterParts = mapToDisplayParts((writer) => {
|
|
178140
|
-
const param = typeChecker.typeParameterToDeclaration(
|
|
178315
|
+
const param = typeChecker.typeParameterToDeclaration(
|
|
178316
|
+
type,
|
|
178317
|
+
enclosingDeclaration,
|
|
178318
|
+
symbolDisplayNodeBuilderFlags,
|
|
178319
|
+
/*internalFlags*/
|
|
178320
|
+
void 0,
|
|
178321
|
+
/*tracker*/
|
|
178322
|
+
void 0,
|
|
178323
|
+
verbosityLevel,
|
|
178324
|
+
typeWriterOut
|
|
178325
|
+
);
|
|
178141
178326
|
getPrinter().writeNode(4 /* Unspecified */, param, getSourceFileOfNode(getParseTreeNode(enclosingDeclaration)), writer);
|
|
178142
178327
|
});
|
|
178143
178328
|
addRange(displayParts, typeParameterParts);
|
|
178144
178329
|
} else {
|
|
178145
|
-
addRange(
|
|
178330
|
+
addRange(
|
|
178331
|
+
displayParts,
|
|
178332
|
+
typeToDisplayParts(
|
|
178333
|
+
typeChecker,
|
|
178334
|
+
type,
|
|
178335
|
+
enclosingDeclaration,
|
|
178336
|
+
/*flags*/
|
|
178337
|
+
void 0,
|
|
178338
|
+
verbosityLevel,
|
|
178339
|
+
typeWriterOut
|
|
178340
|
+
)
|
|
178341
|
+
);
|
|
178146
178342
|
}
|
|
178147
178343
|
if (isTransientSymbol(symbol) && symbol.links.target && isTransientSymbol(symbol.links.target) && symbol.links.target.links.tupleLabelDeclaration) {
|
|
178148
178344
|
const labelDecl = symbol.links.target.links.tupleLabelDeclaration;
|
|
@@ -178207,7 +178403,14 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker, symb
|
|
|
178207
178403
|
if (tags.length === 0 && tagsFromAlias) {
|
|
178208
178404
|
tags = tagsFromAlias;
|
|
178209
178405
|
}
|
|
178210
|
-
|
|
178406
|
+
const canIncreaseVerbosityLevel = !typeWriterOut.truncated && typeWriterOut.canIncreaseExpansionDepth;
|
|
178407
|
+
return {
|
|
178408
|
+
displayParts,
|
|
178409
|
+
documentation,
|
|
178410
|
+
symbolKind,
|
|
178411
|
+
tags: tags.length === 0 ? void 0 : tags,
|
|
178412
|
+
canIncreaseVerbosityLevel: verbosityLevel !== void 0 ? canIncreaseVerbosityLevel : void 0
|
|
178413
|
+
};
|
|
178211
178414
|
function getPrinter() {
|
|
178212
178415
|
return createPrinterWithRemoveComments();
|
|
178213
178416
|
}
|
|
@@ -178228,6 +178431,62 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker, symb
|
|
|
178228
178431
|
displayParts.push(keywordPart(103 /* InKeyword */));
|
|
178229
178432
|
displayParts.push(spacePart());
|
|
178230
178433
|
}
|
|
178434
|
+
function canExpandSymbol(symbol2, out) {
|
|
178435
|
+
if (verbosityLevel === void 0) {
|
|
178436
|
+
return false;
|
|
178437
|
+
}
|
|
178438
|
+
const type2 = symbol2.flags & (32 /* Class */ | 64 /* Interface */) ? typeChecker.getDeclaredTypeOfSymbol(symbol2) : typeChecker.getTypeOfSymbolAtLocation(symbol2, location);
|
|
178439
|
+
if (!type2 || typeChecker.isLibType(type2)) {
|
|
178440
|
+
return false;
|
|
178441
|
+
}
|
|
178442
|
+
if (0 < verbosityLevel) {
|
|
178443
|
+
return true;
|
|
178444
|
+
}
|
|
178445
|
+
if (out) {
|
|
178446
|
+
out.canIncreaseExpansionDepth = true;
|
|
178447
|
+
}
|
|
178448
|
+
return false;
|
|
178449
|
+
}
|
|
178450
|
+
function semanticToSymbolMeaning(meaning) {
|
|
178451
|
+
let symbolMeaning = 0 /* None */;
|
|
178452
|
+
if (meaning & 1 /* Value */) {
|
|
178453
|
+
symbolMeaning |= 111551 /* Value */;
|
|
178454
|
+
}
|
|
178455
|
+
if (meaning & 2 /* Type */) {
|
|
178456
|
+
symbolMeaning |= 788968 /* Type */;
|
|
178457
|
+
}
|
|
178458
|
+
if (meaning & 4 /* Namespace */) {
|
|
178459
|
+
symbolMeaning |= 1920 /* Namespace */;
|
|
178460
|
+
}
|
|
178461
|
+
return symbolMeaning;
|
|
178462
|
+
}
|
|
178463
|
+
function tryExpandSymbol(symbol2, meaning) {
|
|
178464
|
+
if (symbolWasExpanded) {
|
|
178465
|
+
return true;
|
|
178466
|
+
}
|
|
178467
|
+
if (canExpandSymbol(symbol2, typeWriterOut)) {
|
|
178468
|
+
const symbolMeaning = semanticToSymbolMeaning(meaning);
|
|
178469
|
+
const expandedDisplayParts = mapToDisplayParts((writer) => {
|
|
178470
|
+
const nodes = typeChecker.getEmitResolver().symbolToDeclarations(
|
|
178471
|
+
symbol2,
|
|
178472
|
+
symbolMeaning,
|
|
178473
|
+
1024 /* MultilineObjectLiterals */ | 16384 /* UseAliasDefinedOutsideCurrentScope */,
|
|
178474
|
+
verbosityLevel !== void 0 ? verbosityLevel - 1 : void 0,
|
|
178475
|
+
typeWriterOut
|
|
178476
|
+
);
|
|
178477
|
+
const printer = getPrinter();
|
|
178478
|
+
const sourceFile2 = symbol2.valueDeclaration && getSourceFileOfNode(symbol2.valueDeclaration);
|
|
178479
|
+
nodes.forEach((node, i) => {
|
|
178480
|
+
if (i > 0) writer.writeLine();
|
|
178481
|
+
printer.writeNode(4 /* Unspecified */, node, sourceFile2, writer);
|
|
178482
|
+
});
|
|
178483
|
+
});
|
|
178484
|
+
addRange(displayParts, expandedDisplayParts);
|
|
178485
|
+
symbolWasExpanded = true;
|
|
178486
|
+
return true;
|
|
178487
|
+
}
|
|
178488
|
+
return false;
|
|
178489
|
+
}
|
|
178231
178490
|
function addFullSymbolName(symbolToDisplay, enclosingDeclaration2) {
|
|
178232
178491
|
let indexInfos;
|
|
178233
178492
|
if (alias && symbolToDisplay === symbol) {
|
|
@@ -178295,7 +178554,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker, symb
|
|
|
178295
178554
|
}
|
|
178296
178555
|
}
|
|
178297
178556
|
function addSignatureDisplayParts(signature, allSignatures, flags = 0 /* None */) {
|
|
178298
|
-
addRange(displayParts, signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature
|
|
178557
|
+
addRange(displayParts, signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature */, verbosityLevel, typeWriterOut));
|
|
178299
178558
|
if (allSignatures.length > 1) {
|
|
178300
178559
|
displayParts.push(spacePart());
|
|
178301
178560
|
displayParts.push(punctuationPart(21 /* OpenParenToken */));
|
|
@@ -178320,7 +178579,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker, symb
|
|
|
178320
178579
|
addRange(displayParts, typeParameterParts);
|
|
178321
178580
|
}
|
|
178322
178581
|
}
|
|
178323
|
-
function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, enclosingDeclaration, location, semanticMeaning = getMeaningFromLocation(location), alias) {
|
|
178582
|
+
function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, enclosingDeclaration, location, semanticMeaning = getMeaningFromLocation(location), alias, verbosityLevel) {
|
|
178324
178583
|
return getSymbolDisplayPartsDocumentationAndSymbolKindWorker(
|
|
178325
178584
|
typeChecker,
|
|
178326
178585
|
symbol,
|
|
@@ -178330,7 +178589,8 @@ function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, so
|
|
|
178330
178589
|
/*type*/
|
|
178331
178590
|
void 0,
|
|
178332
178591
|
semanticMeaning,
|
|
178333
|
-
alias
|
|
178592
|
+
alias,
|
|
178593
|
+
verbosityLevel
|
|
178334
178594
|
);
|
|
178335
178595
|
}
|
|
178336
178596
|
function isLocalVariableOrFunction(symbol) {
|
|
@@ -195285,7 +195545,7 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
|
|
|
195285
195545
|
getQuickInfoWorker(args, simplifiedResult) {
|
|
195286
195546
|
const { file, project } = this.getFileAndProject(args);
|
|
195287
195547
|
const scriptInfo = this.projectService.getScriptInfoForNormalizedPath(file);
|
|
195288
|
-
const quickInfo = project.getLanguageService().getQuickInfoAtPosition(file, this.getPosition(args, scriptInfo));
|
|
195548
|
+
const quickInfo = project.getLanguageService().getQuickInfoAtPosition(file, this.getPosition(args, scriptInfo), args.verbosityLevel);
|
|
195289
195549
|
if (!quickInfo) {
|
|
195290
195550
|
return void 0;
|
|
195291
195551
|
}
|
|
@@ -195299,7 +195559,8 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
|
|
|
195299
195559
|
end: scriptInfo.positionToLineOffset(textSpanEnd(quickInfo.textSpan)),
|
|
195300
195560
|
displayString,
|
|
195301
195561
|
documentation: useDisplayParts ? this.mapDisplayParts(quickInfo.documentation, project) : displayPartsToString(quickInfo.documentation),
|
|
195302
|
-
tags: this.mapJSDocTagInfo(quickInfo.tags, project, useDisplayParts)
|
|
195562
|
+
tags: this.mapJSDocTagInfo(quickInfo.tags, project, useDisplayParts),
|
|
195563
|
+
canIncreaseVerbosityLevel: quickInfo.canIncreaseVerbosityLevel
|
|
195303
195564
|
};
|
|
195304
195565
|
} else {
|
|
195305
195566
|
return useDisplayParts ? quickInfo : {
|