typescript 5.8.0-dev.20250207 → 5.8.0-dev.20250209
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 +60 -465
- package/lib/typescript.d.ts +0 -9
- package/lib/typescript.js +75 -541
- package/package.json +2 -2
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.8";
|
2288
|
-
var version = `${versionMajorMinor}.0-dev.
|
2288
|
+
var version = `${versionMajorMinor}.0-dev.20250209`;
|
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";
|
@@ -50987,8 +50986,8 @@ function createTypeChecker(host) {
|
|
50987
50986
|
writeSignature: (signature, enclosingDeclaration, flags, kind, writer) => {
|
50988
50987
|
return signatureToString(signature, getParseTreeNode(enclosingDeclaration), flags, kind, writer);
|
50989
50988
|
},
|
50990
|
-
writeType: (type, enclosingDeclaration, flags, writer
|
50991
|
-
return typeToString(type, getParseTreeNode(enclosingDeclaration), flags, writer
|
50989
|
+
writeType: (type, enclosingDeclaration, flags, writer) => {
|
50990
|
+
return typeToString(type, getParseTreeNode(enclosingDeclaration), flags, writer);
|
50992
50991
|
},
|
50993
50992
|
writeSymbol: (symbol, enclosingDeclaration, meaning, flags, writer) => {
|
50994
50993
|
return symbolToString(symbol, getParseTreeNode(enclosingDeclaration), meaning, flags, writer);
|
@@ -51786,7 +51785,6 @@ function createTypeChecker(host) {
|
|
51786
51785
|
[".jsx", ".jsx"],
|
51787
51786
|
[".json", ".json"]
|
51788
51787
|
];
|
51789
|
-
var narrowableReturnTypeCache = /* @__PURE__ */ new Map();
|
51790
51788
|
initializeTypeChecker();
|
51791
51789
|
return checker;
|
51792
51790
|
function isDefinitelyReferenceToGlobalSymbolObject(node) {
|
@@ -54922,18 +54920,14 @@ function createTypeChecker(host) {
|
|
54922
54920
|
return writer2;
|
54923
54921
|
}
|
54924
54922
|
}
|
54925
|
-
function typeToString(type, enclosingDeclaration, flags = 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */, writer = createTextWriter("")
|
54926
|
-
const noTruncation = compilerOptions.noErrorTruncation || flags & 1 /* NoTruncation
|
54923
|
+
function typeToString(type, enclosingDeclaration, flags = 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */, writer = createTextWriter("")) {
|
54924
|
+
const noTruncation = compilerOptions.noErrorTruncation || flags & 1 /* NoTruncation */;
|
54927
54925
|
const typeNode = nodeBuilder.typeToTypeNode(
|
54928
54926
|
type,
|
54929
54927
|
enclosingDeclaration,
|
54930
|
-
toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | (noTruncation ? 1 /* NoTruncation */ : 0),
|
54928
|
+
toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | (noTruncation ? 1 /* NoTruncation */ : 0 /* None */),
|
54931
54929
|
/*internalFlags*/
|
54932
|
-
void 0
|
54933
|
-
/*tracker*/
|
54934
|
-
void 0,
|
54935
|
-
verbosityLevel,
|
54936
|
-
out
|
54930
|
+
void 0
|
54937
54931
|
);
|
54938
54932
|
if (typeNode === void 0) return Debug.fail("should always get typenode");
|
54939
54933
|
const printer = type !== unresolvedType ? createPrinterWithRemoveComments() : createPrinterWithDefaults();
|
@@ -55160,127 +55154,31 @@ function createTypeChecker(host) {
|
|
55160
55154
|
};
|
55161
55155
|
return {
|
55162
55156
|
syntacticBuilderResolver,
|
55163
|
-
typeToTypeNode: (type, enclosingDeclaration, flags, internalFlags, tracker
|
55164
|
-
typePredicateToTypePredicateNode: (typePredicate, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(
|
55165
|
-
|
55166
|
-
|
55167
|
-
|
55168
|
-
|
55169
|
-
|
55170
|
-
|
55171
|
-
|
55172
|
-
|
55173
|
-
|
55174
|
-
|
55175
|
-
|
55176
|
-
|
55177
|
-
|
55178
|
-
|
55179
|
-
|
55180
|
-
|
55181
|
-
),
|
55182
|
-
|
55183
|
-
|
55184
|
-
|
55185
|
-
|
55186
|
-
|
55187
|
-
|
55188
|
-
void 0,
|
55189
|
-
(context) => syntacticNodeBuilder.serializeReturnTypeForSignature(signature, getSymbolOfDeclaration(signature), context)
|
55190
|
-
),
|
55191
|
-
serializeTypeForExpression: (expr, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(
|
55192
|
-
enclosingDeclaration,
|
55193
|
-
flags,
|
55194
|
-
internalFlags,
|
55195
|
-
tracker,
|
55196
|
-
/*verbosityLevel*/
|
55197
|
-
void 0,
|
55198
|
-
(context) => syntacticNodeBuilder.serializeTypeOfExpression(expr, context)
|
55199
|
-
),
|
55200
|
-
indexInfoToIndexSignatureDeclaration: (indexInfo, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(
|
55201
|
-
enclosingDeclaration,
|
55202
|
-
flags,
|
55203
|
-
internalFlags,
|
55204
|
-
tracker,
|
55205
|
-
/*verbosityLevel*/
|
55206
|
-
void 0,
|
55207
|
-
(context) => indexInfoToIndexSignatureDeclarationHelper(
|
55208
|
-
indexInfo,
|
55209
|
-
context,
|
55210
|
-
/*typeNode*/
|
55211
|
-
void 0
|
55212
|
-
)
|
55213
|
-
),
|
55214
|
-
signatureToSignatureDeclaration: (signature, kind, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(
|
55215
|
-
enclosingDeclaration,
|
55216
|
-
flags,
|
55217
|
-
internalFlags,
|
55218
|
-
tracker,
|
55219
|
-
/*verbosityLevel*/
|
55220
|
-
void 0,
|
55221
|
-
(context) => signatureToSignatureDeclarationHelper(signature, kind, context)
|
55222
|
-
),
|
55223
|
-
symbolToEntityName: (symbol, meaning, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(
|
55224
|
-
enclosingDeclaration,
|
55225
|
-
flags,
|
55226
|
-
internalFlags,
|
55227
|
-
tracker,
|
55228
|
-
/*verbosityLevel*/
|
55229
|
-
void 0,
|
55230
|
-
(context) => symbolToName(
|
55231
|
-
symbol,
|
55232
|
-
context,
|
55233
|
-
meaning,
|
55234
|
-
/*expectsIdentifier*/
|
55235
|
-
false
|
55236
|
-
)
|
55237
|
-
),
|
55238
|
-
symbolToExpression: (symbol, meaning, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(
|
55239
|
-
enclosingDeclaration,
|
55240
|
-
flags,
|
55241
|
-
internalFlags,
|
55242
|
-
tracker,
|
55243
|
-
/*verbosityLevel*/
|
55244
|
-
void 0,
|
55245
|
-
(context) => symbolToExpression(symbol, context, meaning)
|
55246
|
-
),
|
55247
|
-
symbolToTypeParameterDeclarations: (symbol, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(
|
55248
|
-
enclosingDeclaration,
|
55249
|
-
flags,
|
55250
|
-
internalFlags,
|
55251
|
-
tracker,
|
55252
|
-
/*verbosityLevel*/
|
55253
|
-
void 0,
|
55254
|
-
(context) => typeParametersToTypeParameterDeclarations(symbol, context)
|
55255
|
-
),
|
55256
|
-
symbolToParameterDeclaration: (symbol, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(
|
55257
|
-
enclosingDeclaration,
|
55258
|
-
flags,
|
55259
|
-
internalFlags,
|
55260
|
-
tracker,
|
55261
|
-
/*verbosityLevel*/
|
55262
|
-
void 0,
|
55263
|
-
(context) => symbolToParameterDeclaration(symbol, context)
|
55264
|
-
),
|
55265
|
-
typeParameterToDeclaration: (parameter, enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel) => withContext2(enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, (context) => typeParameterToDeclaration(parameter, context)),
|
55266
|
-
symbolTableToDeclarationStatements: (symbolTable, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(
|
55267
|
-
enclosingDeclaration,
|
55268
|
-
flags,
|
55269
|
-
internalFlags,
|
55270
|
-
tracker,
|
55271
|
-
/*verbosityLevel*/
|
55272
|
-
void 0,
|
55273
|
-
(context) => symbolTableToDeclarationStatements(symbolTable, context)
|
55274
|
-
),
|
55275
|
-
symbolToNode: (symbol, meaning, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(
|
55276
|
-
enclosingDeclaration,
|
55277
|
-
flags,
|
55278
|
-
internalFlags,
|
55279
|
-
tracker,
|
55280
|
-
/*verbosityLevel*/
|
55281
|
-
void 0,
|
55282
|
-
(context) => symbolToNode(symbol, context, meaning)
|
55283
|
-
)
|
55157
|
+
typeToTypeNode: (type, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(enclosingDeclaration, flags, internalFlags, tracker, (context) => typeToTypeNodeHelper(type, context)),
|
55158
|
+
typePredicateToTypePredicateNode: (typePredicate, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(enclosingDeclaration, flags, internalFlags, tracker, (context) => typePredicateToTypePredicateNodeHelper(typePredicate, context)),
|
55159
|
+
serializeTypeForExpression: (expr, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(enclosingDeclaration, flags, internalFlags, tracker, (context) => syntacticNodeBuilder.serializeTypeOfExpression(expr, context)),
|
55160
|
+
serializeTypeForDeclaration: (declaration, symbol, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(enclosingDeclaration, flags, internalFlags, tracker, (context) => syntacticNodeBuilder.serializeTypeOfDeclaration(declaration, symbol, context)),
|
55161
|
+
serializeReturnTypeForSignature: (signature, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(enclosingDeclaration, flags, internalFlags, tracker, (context) => syntacticNodeBuilder.serializeReturnTypeForSignature(signature, getSymbolOfDeclaration(signature), context)),
|
55162
|
+
indexInfoToIndexSignatureDeclaration: (indexInfo, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(enclosingDeclaration, flags, internalFlags, tracker, (context) => indexInfoToIndexSignatureDeclarationHelper(
|
55163
|
+
indexInfo,
|
55164
|
+
context,
|
55165
|
+
/*typeNode*/
|
55166
|
+
void 0
|
55167
|
+
)),
|
55168
|
+
signatureToSignatureDeclaration: (signature, kind, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(enclosingDeclaration, flags, internalFlags, tracker, (context) => signatureToSignatureDeclarationHelper(signature, kind, context)),
|
55169
|
+
symbolToEntityName: (symbol, meaning, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(enclosingDeclaration, flags, internalFlags, tracker, (context) => symbolToName(
|
55170
|
+
symbol,
|
55171
|
+
context,
|
55172
|
+
meaning,
|
55173
|
+
/*expectsIdentifier*/
|
55174
|
+
false
|
55175
|
+
)),
|
55176
|
+
symbolToExpression: (symbol, meaning, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(enclosingDeclaration, flags, internalFlags, tracker, (context) => symbolToExpression(symbol, context, meaning)),
|
55177
|
+
symbolToTypeParameterDeclarations: (symbol, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(enclosingDeclaration, flags, internalFlags, tracker, (context) => typeParametersToTypeParameterDeclarations(symbol, context)),
|
55178
|
+
symbolToParameterDeclaration: (symbol, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(enclosingDeclaration, flags, internalFlags, tracker, (context) => symbolToParameterDeclaration(symbol, context)),
|
55179
|
+
typeParameterToDeclaration: (parameter, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(enclosingDeclaration, flags, internalFlags, tracker, (context) => typeParameterToDeclaration(parameter, context)),
|
55180
|
+
symbolTableToDeclarationStatements: (symbolTable, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(enclosingDeclaration, flags, internalFlags, tracker, (context) => symbolTableToDeclarationStatements(symbolTable, context)),
|
55181
|
+
symbolToNode: (symbol, meaning, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(enclosingDeclaration, flags, internalFlags, tracker, (context) => symbolToNode(symbol, context, meaning))
|
55284
55182
|
};
|
55285
55183
|
function getTypeFromTypeNode2(context, node, noMappedTypes) {
|
55286
55184
|
const type = getTypeFromTypeNodeWithoutContext(node);
|
@@ -55322,7 +55220,7 @@ function createTypeChecker(host) {
|
|
55322
55220
|
}
|
55323
55221
|
return symbolToExpression(symbol, context, meaning);
|
55324
55222
|
}
|
55325
|
-
function withContext2(enclosingDeclaration, flags, internalFlags, tracker,
|
55223
|
+
function withContext2(enclosingDeclaration, flags, internalFlags, tracker, cb) {
|
55326
55224
|
const moduleResolverHost = (tracker == null ? void 0 : tracker.trackSymbol) ? tracker.moduleResolverHost : (internalFlags || 0 /* None */) & 4 /* DoNotIncludeSymbolChain */ ? createBasicNodeBuilderModuleSpecifierResolutionHost(host) : void 0;
|
55327
55225
|
const context = {
|
55328
55226
|
enclosingDeclaration,
|
@@ -55330,7 +55228,6 @@ function createTypeChecker(host) {
|
|
55330
55228
|
flags: flags || 0 /* None */,
|
55331
55229
|
internalFlags: internalFlags || 0 /* None */,
|
55332
55230
|
tracker: void 0,
|
55333
|
-
unfoldDepth: verbosityLevel ?? -1,
|
55334
55231
|
encounteredError: false,
|
55335
55232
|
suppressReportInferenceFallback: false,
|
55336
55233
|
reportedDiagnostic: false,
|
@@ -55352,18 +55249,13 @@ function createTypeChecker(host) {
|
|
55352
55249
|
typeParameterNamesByText: void 0,
|
55353
55250
|
typeParameterNamesByTextNextNameCount: void 0,
|
55354
55251
|
enclosingSymbolTypes: /* @__PURE__ */ new Map(),
|
55355
|
-
mapper: void 0
|
55356
|
-
depth: 0,
|
55357
|
-
couldUnfoldMore: false
|
55252
|
+
mapper: void 0
|
55358
55253
|
};
|
55359
55254
|
context.tracker = new SymbolTrackerImpl(context, tracker, moduleResolverHost);
|
55360
55255
|
const resultingNode = cb(context);
|
55361
55256
|
if (context.truncating && context.flags & 1 /* NoTruncation */) {
|
55362
55257
|
context.tracker.reportTruncationError();
|
55363
55258
|
}
|
55364
|
-
if (out) {
|
55365
|
-
out.couldUnfoldMore = context.couldUnfoldMore;
|
55366
|
-
}
|
55367
55259
|
return context.encounteredError ? void 0 : resultingNode;
|
55368
55260
|
}
|
55369
55261
|
function addSymbolTypeToContext(context, symbol, type) {
|
@@ -55382,36 +55274,16 @@ function createTypeChecker(host) {
|
|
55382
55274
|
function saveRestoreFlags(context) {
|
55383
55275
|
const flags = context.flags;
|
55384
55276
|
const internalFlags = context.internalFlags;
|
55385
|
-
const depth = context.depth;
|
55386
55277
|
return restore;
|
55387
55278
|
function restore() {
|
55388
55279
|
context.flags = flags;
|
55389
55280
|
context.internalFlags = internalFlags;
|
55390
|
-
context.depth = depth;
|
55391
55281
|
}
|
55392
55282
|
}
|
55393
55283
|
function checkTruncationLength(context) {
|
55394
55284
|
if (context.truncating) return context.truncating;
|
55395
55285
|
return context.truncating = context.approximateLength > (context.flags & 1 /* NoTruncation */ ? noTruncationMaximumTruncationLength : defaultMaximumTruncationLength);
|
55396
55286
|
}
|
55397
|
-
function couldUnfoldType(type, context) {
|
55398
|
-
var _a;
|
55399
|
-
if ((_a = context.visitedTypes) == null ? void 0 : _a.has(type.id)) {
|
55400
|
-
return false;
|
55401
|
-
}
|
55402
|
-
return context.depth < context.unfoldDepth || context.depth === context.unfoldDepth && !context.couldUnfoldMore;
|
55403
|
-
}
|
55404
|
-
function canUnfoldType(type, context) {
|
55405
|
-
var _a;
|
55406
|
-
if ((_a = context.visitedTypes) == null ? void 0 : _a.has(type.id)) {
|
55407
|
-
return false;
|
55408
|
-
}
|
55409
|
-
const result = context.depth < context.unfoldDepth;
|
55410
|
-
if (!result) {
|
55411
|
-
context.couldUnfoldMore = true;
|
55412
|
-
}
|
55413
|
-
return result;
|
55414
|
-
}
|
55415
55287
|
function typeToTypeNodeHelper(type, context) {
|
55416
55288
|
const restoreFlags = saveRestoreFlags(context);
|
55417
55289
|
const typeNode = typeToTypeNodeWorker(type, context);
|
@@ -55559,27 +55431,16 @@ function createTypeChecker(host) {
|
|
55559
55431
|
return factory.createThisTypeNode();
|
55560
55432
|
}
|
55561
55433
|
if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) {
|
55562
|
-
|
55563
|
-
|
55564
|
-
|
55565
|
-
|
55566
|
-
return factory.createArrayTypeNode(typeArgumentNodes[0]);
|
55567
|
-
}
|
55568
|
-
return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes);
|
55434
|
+
const typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context);
|
55435
|
+
if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) return factory.createTypeReferenceNode(factory.createIdentifier(""), typeArgumentNodes);
|
55436
|
+
if (length(typeArgumentNodes) === 1 && type.aliasSymbol === globalArrayType.symbol) {
|
55437
|
+
return factory.createArrayTypeNode(typeArgumentNodes[0]);
|
55569
55438
|
}
|
55570
|
-
|
55439
|
+
return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes);
|
55571
55440
|
}
|
55572
55441
|
const objectFlags = getObjectFlags(type);
|
55573
55442
|
if (objectFlags & 4 /* Reference */) {
|
55574
55443
|
Debug.assert(!!(type.flags & 524288 /* Object */));
|
55575
|
-
if (canUnfoldType(type, context)) {
|
55576
|
-
context.depth += 1;
|
55577
|
-
return createAnonymousTypeNode(
|
55578
|
-
type,
|
55579
|
-
/*forceClassExpansion*/
|
55580
|
-
true
|
55581
|
-
);
|
55582
|
-
}
|
55583
55444
|
return type.node ? visitAndTransformType(type, typeReferenceToTypeNode) : typeReferenceToTypeNode(type);
|
55584
55445
|
}
|
55585
55446
|
if (type.flags & 262144 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) {
|
@@ -55609,14 +55470,6 @@ function createTypeChecker(host) {
|
|
55609
55470
|
void 0
|
55610
55471
|
);
|
55611
55472
|
}
|
55612
|
-
if (objectFlags & 3 /* ClassOrInterface */ && canUnfoldType(type, context)) {
|
55613
|
-
context.depth += 1;
|
55614
|
-
return createAnonymousTypeNode(
|
55615
|
-
type,
|
55616
|
-
/*forceClassExpansion*/
|
55617
|
-
true
|
55618
|
-
);
|
55619
|
-
}
|
55620
55473
|
if (type.symbol) {
|
55621
55474
|
return symbolToTypeNode(type.symbol, context, 788968 /* Type */);
|
55622
55475
|
}
|
@@ -55820,7 +55673,7 @@ function createTypeChecker(host) {
|
|
55820
55673
|
}
|
55821
55674
|
return result;
|
55822
55675
|
}
|
55823
|
-
function createAnonymousTypeNode(type2
|
55676
|
+
function createAnonymousTypeNode(type2) {
|
55824
55677
|
var _a2, _b2;
|
55825
55678
|
const typeId = type2.id;
|
55826
55679
|
const symbol = type2.symbol;
|
@@ -55843,7 +55696,7 @@ function createTypeChecker(host) {
|
|
55843
55696
|
const isInstanceType = isClassInstanceSide(type2) ? 788968 /* Type */ : 111551 /* Value */;
|
55844
55697
|
if (isJSConstructor(symbol.valueDeclaration)) {
|
55845
55698
|
return symbolToTypeNode(symbol, context, isInstanceType);
|
55846
|
-
} else if (symbol.flags & 32 /* Class */ && !
|
55699
|
+
} else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration && isClassLike(symbol.valueDeclaration) && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ && (!isClassDeclaration(symbol.valueDeclaration) || isSymbolAccessible(
|
55847
55700
|
symbol,
|
55848
55701
|
context.enclosingDeclaration,
|
55849
55702
|
isInstanceType,
|
@@ -55887,7 +55740,7 @@ function createTypeChecker(host) {
|
|
55887
55740
|
if (id && !context.symbolDepth) {
|
55888
55741
|
context.symbolDepth = /* @__PURE__ */ new Map();
|
55889
55742
|
}
|
55890
|
-
const links = context.
|
55743
|
+
const links = context.enclosingDeclaration && getNodeLinks(context.enclosingDeclaration);
|
55891
55744
|
const key = `${getTypeId(type2)}|${context.flags}|${context.internalFlags}`;
|
55892
55745
|
if (links) {
|
55893
55746
|
links.serializedTypes || (links.serializedTypes = /* @__PURE__ */ new Map());
|
@@ -56834,7 +56687,7 @@ function createTypeChecker(host) {
|
|
56834
56687
|
return factory.createTypeParameterDeclaration(modifiers, name, constraintNode, defaultParameterNode);
|
56835
56688
|
}
|
56836
56689
|
function typeToTypeNodeHelperWithPossibleReusableTypeNode(type, typeNode, context) {
|
56837
|
-
return
|
56690
|
+
return typeNode && getTypeFromTypeNode2(context, typeNode) === type && syntacticNodeBuilder.tryReuseExistingTypeNode(context, typeNode) || typeToTypeNodeHelper(type, context);
|
56838
56691
|
}
|
56839
56692
|
function typeParameterToDeclaration(type, context, constraint = getConstraintOfTypeParameter(type)) {
|
56840
56693
|
const constraintNode = constraint && typeToTypeNodeHelperWithPossibleReusableTypeNode(constraint, getConstraintDeclaration(type), context);
|
@@ -57481,7 +57334,7 @@ function createTypeChecker(host) {
|
|
57481
57334
|
let result;
|
57482
57335
|
const addUndefinedForParameter = declaration && (isParameter(declaration) || isJSDocParameterTag(declaration)) && requiresAddingImplicitUndefined(declaration, context.enclosingDeclaration);
|
57483
57336
|
const decl = declaration ?? symbol.valueDeclaration ?? getDeclarationWithTypeAnnotation(symbol) ?? ((_a = symbol.declarations) == null ? void 0 : _a[0]);
|
57484
|
-
if (
|
57337
|
+
if (decl) {
|
57485
57338
|
if (isAccessor(decl)) {
|
57486
57339
|
result = syntacticNodeBuilder.serializeTypeOfAccessor(decl, symbol, context);
|
57487
57340
|
} else if (hasInferredType(decl) && !nodeIsSynthesized(decl) && !(getObjectFlags(type) & 196608 /* RequiresWidening */)) {
|
@@ -64193,14 +64046,11 @@ function createTypeChecker(host) {
|
|
64193
64046
|
function isNoInferType(type) {
|
64194
64047
|
return !!(type.flags & 33554432 /* Substitution */ && type.constraint.flags & 2 /* Unknown */);
|
64195
64048
|
}
|
64196
|
-
function
|
64197
|
-
return
|
64198
|
-
}
|
64199
|
-
function getSubstitutionType(baseType, constraint, isNarrowed) {
|
64200
|
-
return constraint.flags & 3 /* AnyOrUnknown */ || constraint === baseType || baseType.flags & 1 /* Any */ ? baseType : getOrCreateSubstitutionType(baseType, constraint, isNarrowed);
|
64049
|
+
function getSubstitutionType(baseType, constraint) {
|
64050
|
+
return constraint.flags & 3 /* AnyOrUnknown */ || constraint === baseType || baseType.flags & 1 /* Any */ ? baseType : getOrCreateSubstitutionType(baseType, constraint);
|
64201
64051
|
}
|
64202
|
-
function getOrCreateSubstitutionType(baseType, constraint
|
64203
|
-
const id = `${getTypeId(baseType)}>${getTypeId(constraint)}
|
64052
|
+
function getOrCreateSubstitutionType(baseType, constraint) {
|
64053
|
+
const id = `${getTypeId(baseType)}>${getTypeId(constraint)}`;
|
64204
64054
|
const cached = substitutionTypes.get(id);
|
64205
64055
|
if (cached) {
|
64206
64056
|
return cached;
|
@@ -64208,9 +64058,6 @@ function createTypeChecker(host) {
|
|
64208
64058
|
const result = createType(33554432 /* Substitution */);
|
64209
64059
|
result.baseType = baseType;
|
64210
64060
|
result.constraint = constraint;
|
64211
|
-
if (isNarrowed) {
|
64212
|
-
result.objectFlags |= 16777216 /* IsNarrowingType */;
|
64213
|
-
}
|
64214
64061
|
substitutionTypes.set(id, result);
|
64215
64062
|
return result;
|
64216
64063
|
}
|
@@ -66416,7 +66263,7 @@ function createTypeChecker(host) {
|
|
66416
66263
|
function isDeferredType(type, checkTuples) {
|
66417
66264
|
return isGenericType(type) || checkTuples && isTupleType(type) && some(getElementTypes(type), isGenericType);
|
66418
66265
|
}
|
66419
|
-
function getConditionalType(root, mapper, forConstraint, aliasSymbol, aliasTypeArguments
|
66266
|
+
function getConditionalType(root, mapper, forConstraint, aliasSymbol, aliasTypeArguments) {
|
66420
66267
|
let result;
|
66421
66268
|
let extraTypes;
|
66422
66269
|
let tailCount = 0;
|
@@ -66433,11 +66280,10 @@ function createTypeChecker(host) {
|
|
66433
66280
|
if (checkType === wildcardType || extendsType === wildcardType) {
|
66434
66281
|
return wildcardType;
|
66435
66282
|
}
|
66436
|
-
const effectiveCheckType = forNarrowing && isNarrowingSubstitutionType(checkType) ? checkType.constraint : checkType;
|
66437
66283
|
const checkTypeNode = skipTypeParentheses(root.node.checkType);
|
66438
66284
|
const extendsTypeNode = skipTypeParentheses(root.node.extendsType);
|
66439
66285
|
const checkTuples = isSimpleTupleType(checkTypeNode) && isSimpleTupleType(extendsTypeNode) && length(checkTypeNode.elements) === length(extendsTypeNode.elements);
|
66440
|
-
const checkTypeDeferred = isDeferredType(
|
66286
|
+
const checkTypeDeferred = isDeferredType(checkType, checkTuples);
|
66441
66287
|
let combinedMapper;
|
66442
66288
|
if (root.inferTypeParameters) {
|
66443
66289
|
const context = createInferenceContext(
|
@@ -66456,8 +66302,8 @@ function createTypeChecker(host) {
|
|
66456
66302
|
}
|
66457
66303
|
const inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType;
|
66458
66304
|
if (!checkTypeDeferred && !isDeferredType(inferredExtendsType, checkTuples)) {
|
66459
|
-
if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && (
|
66460
|
-
if (
|
66305
|
+
if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && (checkType.flags & 1 /* Any */ || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) {
|
66306
|
+
if (checkType.flags & 1 /* Any */ || forConstraint && !(inferredExtendsType.flags & 131072 /* Never */) && someType(getPermissiveInstantiation(inferredExtendsType), (t) => isTypeAssignableTo(t, getPermissiveInstantiation(checkType)))) {
|
66461
66307
|
(extraTypes || (extraTypes = [])).push(instantiateType(getTypeFromTypeNode(root.node.trueType), combinedMapper || mapper));
|
66462
66308
|
}
|
66463
66309
|
const falseType2 = getTypeFromTypeNode(root.node.falseType);
|
@@ -66474,7 +66320,7 @@ function createTypeChecker(host) {
|
|
66474
66320
|
result = instantiateType(falseType2, mapper);
|
66475
66321
|
break;
|
66476
66322
|
}
|
66477
|
-
if (inferredExtendsType.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(
|
66323
|
+
if (inferredExtendsType.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) {
|
66478
66324
|
const trueType2 = getTypeFromTypeNode(root.node.trueType);
|
66479
66325
|
const trueMapper = combinedMapper || mapper;
|
66480
66326
|
if (canTailRecurse(trueType2, trueMapper)) {
|
@@ -67440,39 +67286,8 @@ function createTypeChecker(host) {
|
|
67440
67286
|
if (!result) {
|
67441
67287
|
const newMapper = createTypeMapper(root.outerTypeParameters, typeArguments);
|
67442
67288
|
const checkType = root.checkType;
|
67443
|
-
|
67444
|
-
|
67445
|
-
const forNarrowing = distributionType && isNarrowingSubstitutionType(distributionType) && isNarrowableConditionalType(type, mapper);
|
67446
|
-
if (forNarrowing) {
|
67447
|
-
narrowingBaseType = distributionType.baseType;
|
67448
|
-
distributionType = getReducedType(distributionType.constraint);
|
67449
|
-
}
|
67450
|
-
if (distributionType && checkType !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */)) {
|
67451
|
-
if (narrowingBaseType) {
|
67452
|
-
result = mapTypeToIntersection(
|
67453
|
-
distributionType,
|
67454
|
-
(t) => getConditionalType(
|
67455
|
-
root,
|
67456
|
-
prependTypeMapping(checkType, getSubstitutionType(
|
67457
|
-
narrowingBaseType,
|
67458
|
-
t,
|
67459
|
-
/*isNarrowed*/
|
67460
|
-
true
|
67461
|
-
), newMapper),
|
67462
|
-
forConstraint,
|
67463
|
-
/*aliasSymbol*/
|
67464
|
-
void 0,
|
67465
|
-
/*aliasTypeArguments*/
|
67466
|
-
void 0,
|
67467
|
-
forNarrowing
|
67468
|
-
)
|
67469
|
-
);
|
67470
|
-
} else {
|
67471
|
-
result = mapTypeWithAlias(distributionType, (t) => getConditionalType(root, prependTypeMapping(checkType, t, newMapper), forConstraint), aliasSymbol, aliasTypeArguments);
|
67472
|
-
}
|
67473
|
-
} else {
|
67474
|
-
result = getConditionalType(root, newMapper, forConstraint, aliasSymbol, aliasTypeArguments, forNarrowing);
|
67475
|
-
}
|
67289
|
+
const distributionType = root.isDistributive ? getReducedType(getMappedType(checkType, newMapper)) : void 0;
|
67290
|
+
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);
|
67476
67291
|
root.instantiations.set(id, result);
|
67477
67292
|
}
|
67478
67293
|
return result;
|
@@ -68615,12 +68430,10 @@ function createTypeChecker(host) {
|
|
68615
68430
|
function shouldNormalizeIntersection(type) {
|
68616
68431
|
let hasInstantiable = false;
|
68617
68432
|
let hasNullableOrEmpty = false;
|
68618
|
-
let hasSubstitution = false;
|
68619
68433
|
for (const t of type.types) {
|
68620
68434
|
hasInstantiable || (hasInstantiable = !!(t.flags & 465829888 /* Instantiable */));
|
68621
68435
|
hasNullableOrEmpty || (hasNullableOrEmpty = !!(t.flags & 98304 /* Nullable */) || isEmptyAnonymousObjectType(t));
|
68622
|
-
|
68623
|
-
if (hasInstantiable && hasNullableOrEmpty || hasSubstitution) return true;
|
68436
|
+
if (hasInstantiable && hasNullableOrEmpty) return true;
|
68624
68437
|
}
|
68625
68438
|
return false;
|
68626
68439
|
}
|
@@ -73780,18 +73593,6 @@ function createTypeChecker(host) {
|
|
73780
73593
|
}
|
73781
73594
|
return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* None */ : 1 /* Literal */) : type;
|
73782
73595
|
}
|
73783
|
-
function mapTypeToIntersection(type, mapper) {
|
73784
|
-
if (type.flags & 131072 /* Never */) {
|
73785
|
-
return type;
|
73786
|
-
}
|
73787
|
-
if (!(type.flags & 1048576 /* Union */)) {
|
73788
|
-
return mapper(type);
|
73789
|
-
}
|
73790
|
-
const origin = type.origin;
|
73791
|
-
const types = origin && origin.flags & 1048576 /* Union */ ? origin.types : type.types;
|
73792
|
-
const mappedTypes = types.map((t) => t.flags & 1048576 /* Union */ ? mapTypeToIntersection(t, mapper) : mapper(t));
|
73793
|
-
return getIntersectionType(mappedTypes);
|
73794
|
-
}
|
73795
73596
|
function mapTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) {
|
73796
73597
|
return type.flags & 1048576 /* Union */ && aliasSymbol ? getUnionType(map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments) : mapType(type, mapper);
|
73797
73598
|
}
|
@@ -75376,11 +75177,11 @@ function createTypeChecker(host) {
|
|
75376
75177
|
));
|
75377
75178
|
return contextualType && !isGenericType(contextualType);
|
75378
75179
|
}
|
75379
|
-
function getNarrowableTypeForReference(type, reference, checkMode
|
75180
|
+
function getNarrowableTypeForReference(type, reference, checkMode) {
|
75380
75181
|
if (isNoInferType(type)) {
|
75381
75182
|
type = type.baseType;
|
75382
75183
|
}
|
75383
|
-
const substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) && someType(type, isGenericTypeWithUnionConstraint) && (
|
75184
|
+
const substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) && someType(type, isGenericTypeWithUnionConstraint) && (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
|
75384
75185
|
return substituteConstraints ? mapType(type, getBaseConstraintOrType) : type;
|
75385
75186
|
}
|
75386
75187
|
function isExportOrExportExpression(location) {
|
@@ -76507,16 +76308,9 @@ function createTypeChecker(host) {
|
|
76507
76308
|
function getContextualTypeForReturnExpression(node, contextFlags) {
|
76508
76309
|
const func = getContainingFunction(node);
|
76509
76310
|
if (func) {
|
76510
|
-
const functionFlags = getFunctionFlags(func);
|
76511
|
-
const links = getNodeLinks(node);
|
76512
|
-
if (links.contextualReturnType) {
|
76513
|
-
if (functionFlags & 2 /* Async */) {
|
76514
|
-
return getUnionType([links.contextualReturnType, createPromiseLikeType(links.contextualReturnType)]);
|
76515
|
-
}
|
76516
|
-
return links.contextualReturnType;
|
76517
|
-
}
|
76518
76311
|
let contextualReturnType = getContextualReturnType(func, contextFlags);
|
76519
76312
|
if (contextualReturnType) {
|
76313
|
+
const functionFlags = getFunctionFlags(func);
|
76520
76314
|
if (functionFlags & 1 /* Generator */) {
|
76521
76315
|
const isAsyncGenerator = (functionFlags & 2 /* Async */) !== 0;
|
76522
76316
|
if (contextualReturnType.flags & 1048576 /* Union */) {
|
@@ -77214,13 +77008,6 @@ function createTypeChecker(host) {
|
|
77214
77008
|
if (index >= 0) {
|
77215
77009
|
return contextualTypes[index];
|
77216
77010
|
}
|
77217
|
-
const links = getNodeLinks(node);
|
77218
|
-
if (links.contextualReturnType) {
|
77219
|
-
if (node.flags & 65536 /* AwaitContext */) {
|
77220
|
-
return getUnionType([links.contextualReturnType, createPromiseLikeType(links.contextualReturnType)]);
|
77221
|
-
}
|
77222
|
-
return links.contextualReturnType;
|
77223
|
-
}
|
77224
77011
|
const { parent: parent2 } = node;
|
77225
77012
|
switch (parent2.kind) {
|
77226
77013
|
case 260 /* VariableDeclaration */:
|
@@ -88209,199 +87996,7 @@ function createTypeChecker(host) {
|
|
88209
87996
|
) : exprType;
|
88210
87997
|
const effectiveExpr = expr && getEffectiveCheckNode(expr);
|
88211
87998
|
const errorNode = inReturnStatement && !inConditionalExpression ? node : effectiveExpr;
|
88212
|
-
|
88213
|
-
checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, errorNode, effectiveExpr);
|
88214
|
-
return;
|
88215
|
-
}
|
88216
|
-
if (checkTypeAssignableTo(
|
88217
|
-
unwrappedExprType,
|
88218
|
-
unwrappedReturnType,
|
88219
|
-
/*errorNode*/
|
88220
|
-
void 0
|
88221
|
-
)) {
|
88222
|
-
return;
|
88223
|
-
}
|
88224
|
-
let narrowPosition = node;
|
88225
|
-
let narrowFlowNode = inReturnStatement && node.flowNode;
|
88226
|
-
if (expr && isConditionalExpression(expr.parent)) {
|
88227
|
-
narrowFlowNode = expr.parent.whenTrue === expr ? expr.parent.flowNodeWhenTrue : expr.parent.flowNodeWhenFalse;
|
88228
|
-
narrowPosition = expr;
|
88229
|
-
}
|
88230
|
-
if (!narrowFlowNode) {
|
88231
|
-
checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, errorNode, effectiveExpr);
|
88232
|
-
return;
|
88233
|
-
}
|
88234
|
-
const allTypeParameters = appendTypeParameters(getOuterTypeParameters(
|
88235
|
-
container,
|
88236
|
-
/*includeThisTypes*/
|
88237
|
-
false
|
88238
|
-
), getEffectiveTypeParameterDeclarations(container));
|
88239
|
-
const narrowableTypeParameters = allTypeParameters && getNarrowableTypeParameters(allTypeParameters);
|
88240
|
-
if (!narrowableTypeParameters || !narrowableTypeParameters.length || !isNarrowableReturnType(unwrappedReturnType)) {
|
88241
|
-
checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, errorNode, effectiveExpr);
|
88242
|
-
return;
|
88243
|
-
}
|
88244
|
-
const narrowedTypeParameters = [];
|
88245
|
-
const narrowedTypes = [];
|
88246
|
-
for (const [typeParam, symbol, reference] of narrowableTypeParameters) {
|
88247
|
-
const narrowReference = factory.cloneNode(reference);
|
88248
|
-
narrowReference.id = void 0;
|
88249
|
-
getNodeLinks(narrowReference).resolvedSymbol = symbol;
|
88250
|
-
setParent(narrowReference, narrowPosition.parent);
|
88251
|
-
narrowReference.flowNode = narrowFlowNode;
|
88252
|
-
const initialType = getNarrowableTypeForReference(
|
88253
|
-
typeParam,
|
88254
|
-
narrowReference,
|
88255
|
-
/*checkMode*/
|
88256
|
-
void 0,
|
88257
|
-
/*forReturnTypeNarrowing*/
|
88258
|
-
true
|
88259
|
-
);
|
88260
|
-
if (initialType === typeParam) {
|
88261
|
-
continue;
|
88262
|
-
}
|
88263
|
-
const flowType = getFlowTypeOfReference(narrowReference, initialType);
|
88264
|
-
const exprType2 = getTypeFromFlowType(flowType);
|
88265
|
-
if (exprType2.flags & 3 /* AnyOrUnknown */ || isErrorType(exprType2) || exprType2 === typeParam || exprType2 === mapType(typeParam, getBaseConstraintOrType)) {
|
88266
|
-
continue;
|
88267
|
-
}
|
88268
|
-
const narrowedType = getSubstitutionType(
|
88269
|
-
typeParam,
|
88270
|
-
exprType2,
|
88271
|
-
/*isNarrowed*/
|
88272
|
-
true
|
88273
|
-
);
|
88274
|
-
narrowedTypeParameters.push(typeParam);
|
88275
|
-
narrowedTypes.push(narrowedType);
|
88276
|
-
}
|
88277
|
-
const narrowMapper = createTypeMapper(narrowedTypeParameters, narrowedTypes);
|
88278
|
-
const narrowedReturnType = instantiateType(
|
88279
|
-
unwrappedReturnType,
|
88280
|
-
narrowMapper
|
88281
|
-
);
|
88282
|
-
if (expr) {
|
88283
|
-
const links = getNodeLinks(expr);
|
88284
|
-
if (!links.contextualReturnType) {
|
88285
|
-
links.contextualReturnType = narrowedReturnType;
|
88286
|
-
}
|
88287
|
-
}
|
88288
|
-
const narrowedExprType = expr ? checkExpression(expr) : undefinedType;
|
88289
|
-
const narrowedUnwrappedExprType = functionFlags & 2 /* Async */ ? checkAwaitedType(
|
88290
|
-
narrowedExprType,
|
88291
|
-
/*withAlias*/
|
88292
|
-
false,
|
88293
|
-
node,
|
88294
|
-
Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member
|
88295
|
-
) : narrowedExprType;
|
88296
|
-
checkTypeAssignableToAndOptionallyElaborate(narrowedUnwrappedExprType, narrowedReturnType, errorNode, effectiveExpr);
|
88297
|
-
}
|
88298
|
-
function getNarrowableTypeParameters(candidates) {
|
88299
|
-
const narrowableParams = [];
|
88300
|
-
for (const typeParam of candidates) {
|
88301
|
-
const constraint = getConstraintOfTypeParameter(typeParam);
|
88302
|
-
if (!constraint || !(constraint.flags & 1048576 /* Union */)) continue;
|
88303
|
-
if (typeParam.symbol && typeParam.symbol.declarations && typeParam.symbol.declarations.length === 1) {
|
88304
|
-
const declaration = typeParam.symbol.declarations[0];
|
88305
|
-
const container = isJSDocTemplateTag(declaration.parent) ? getJSDocHost(declaration.parent) : declaration.parent;
|
88306
|
-
if (!isFunctionLike(container)) continue;
|
88307
|
-
let reference;
|
88308
|
-
let hasInvalidReference = false;
|
88309
|
-
for (const paramDecl of container.parameters) {
|
88310
|
-
const typeNode = getEffectiveTypeAnnotationNode(paramDecl);
|
88311
|
-
if (!typeNode) continue;
|
88312
|
-
if (isTypeParameterReferenced(typeParam, typeNode)) {
|
88313
|
-
let candidateReference;
|
88314
|
-
if (isTypeReferenceNode(typeNode) && isReferenceToTypeParameter(typeParam, typeNode) && (candidateReference = getValidParameterReference(paramDecl, constraint))) {
|
88315
|
-
if (reference) {
|
88316
|
-
hasInvalidReference = true;
|
88317
|
-
break;
|
88318
|
-
}
|
88319
|
-
reference = candidateReference;
|
88320
|
-
} else {
|
88321
|
-
hasInvalidReference = true;
|
88322
|
-
break;
|
88323
|
-
}
|
88324
|
-
}
|
88325
|
-
}
|
88326
|
-
if (!hasInvalidReference && reference) {
|
88327
|
-
const symbol = getResolvedSymbol(reference);
|
88328
|
-
if (symbol !== unknownSymbol) narrowableParams.push([typeParam, symbol, reference]);
|
88329
|
-
}
|
88330
|
-
}
|
88331
|
-
}
|
88332
|
-
return narrowableParams;
|
88333
|
-
function getValidParameterReference(paramDecl, constraint) {
|
88334
|
-
if (!isIdentifier(paramDecl.name)) return;
|
88335
|
-
const isOptional = !!paramDecl.questionToken || isJSDocOptionalParameter(paramDecl);
|
88336
|
-
if (isOptional && !containsUndefinedType(constraint)) return;
|
88337
|
-
return paramDecl.name;
|
88338
|
-
}
|
88339
|
-
function isReferenceToTypeParameter(typeParam, node) {
|
88340
|
-
return getTypeFromTypeReference(node) === typeParam;
|
88341
|
-
}
|
88342
|
-
function isTypeParameterReferenced(typeParam, node) {
|
88343
|
-
return isReferenced(node);
|
88344
|
-
function isReferenced(node2) {
|
88345
|
-
if (isTypeReferenceNode(node2)) {
|
88346
|
-
return isReferenceToTypeParameter(typeParam, node2);
|
88347
|
-
}
|
88348
|
-
if (isTypeQueryNode(node2)) {
|
88349
|
-
return isTypeParameterPossiblyReferenced(typeParam, node2);
|
88350
|
-
}
|
88351
|
-
return !!forEachChild(node2, isReferenced);
|
88352
|
-
}
|
88353
|
-
}
|
88354
|
-
}
|
88355
|
-
function isNarrowableReturnType(returnType) {
|
88356
|
-
return isConditionalType(returnType) ? isNarrowableConditionalType(returnType) : !!(returnType.indexType.flags & 262144 /* TypeParameter */);
|
88357
|
-
}
|
88358
|
-
function isNarrowableConditionalType(type, mapper) {
|
88359
|
-
const typeArguments = mapper && map(type.root.outerTypeParameters, (t) => {
|
88360
|
-
const mapped = getMappedType(t, mapper);
|
88361
|
-
if (isNarrowingSubstitutionType(mapped)) {
|
88362
|
-
return mapped.baseType;
|
88363
|
-
}
|
88364
|
-
return mapped;
|
88365
|
-
});
|
88366
|
-
const id = `${type.id}:${getTypeListId(typeArguments)}`;
|
88367
|
-
let result = narrowableReturnTypeCache.get(id);
|
88368
|
-
if (result === void 0) {
|
88369
|
-
const nonNarrowingMapper = type.root.outerTypeParameters && typeArguments && createTypeMapper(type.root.outerTypeParameters, typeArguments);
|
88370
|
-
const instantiatedType = instantiateType(type, nonNarrowingMapper);
|
88371
|
-
result = isConditionalType(instantiatedType) && isNarrowableConditionalTypeWorker(instantiatedType);
|
88372
|
-
narrowableReturnTypeCache.set(id, result);
|
88373
|
-
}
|
88374
|
-
return result;
|
88375
|
-
}
|
88376
|
-
function isNarrowableConditionalTypeWorker(type) {
|
88377
|
-
if (!type.root.isDistributive) {
|
88378
|
-
return false;
|
88379
|
-
}
|
88380
|
-
if (type.root.inferTypeParameters) {
|
88381
|
-
return false;
|
88382
|
-
}
|
88383
|
-
if (!(type.checkType.flags & 262144 /* TypeParameter */)) {
|
88384
|
-
return false;
|
88385
|
-
}
|
88386
|
-
const constraintType = getConstraintOfTypeParameter(type.checkType);
|
88387
|
-
if (!constraintType || !(constraintType.flags & 1048576 /* Union */)) {
|
88388
|
-
return false;
|
88389
|
-
}
|
88390
|
-
if (!everyType(type.extendsType, (extendsType) => some(
|
88391
|
-
constraintType.types,
|
88392
|
-
(constraintType2) => isTypeIdenticalTo(constraintType2, extendsType)
|
88393
|
-
))) {
|
88394
|
-
return false;
|
88395
|
-
}
|
88396
|
-
const trueType2 = getTrueTypeFromConditionalType(type);
|
88397
|
-
const isValidTrueType = isConditionalType(trueType2) ? isNarrowableConditionalType(trueType2) : true;
|
88398
|
-
if (!isValidTrueType) return false;
|
88399
|
-
const falseType2 = getFalseTypeFromConditionalType(type);
|
88400
|
-
const isValidFalseType = isConditionalType(falseType2) ? isNarrowableConditionalType(falseType2) : falseType2 === neverType;
|
88401
|
-
return isValidFalseType;
|
88402
|
-
}
|
88403
|
-
function isConditionalType(type) {
|
88404
|
-
return !!(type.flags & 16777216 /* Conditional */);
|
87999
|
+
checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, errorNode, effectiveExpr);
|
88405
88000
|
}
|
88406
88001
|
function checkWithStatement(node) {
|
88407
88002
|
if (!checkGrammarStatementInAmbientContext(node)) {
|
@@ -140640,9 +140235,9 @@ function mapToDisplayParts(writeDisplayParts) {
|
|
140640
140235
|
displayPartWriter.clear();
|
140641
140236
|
}
|
140642
140237
|
}
|
140643
|
-
function typeToDisplayParts(typechecker, type, enclosingDeclaration, flags = 0 /* None
|
140238
|
+
function typeToDisplayParts(typechecker, type, enclosingDeclaration, flags = 0 /* None */) {
|
140644
140239
|
return mapToDisplayParts((writer) => {
|
140645
|
-
typechecker.writeType(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */ | 16384 /* UseAliasDefinedOutsideCurrentScope */, writer
|
140240
|
+
typechecker.writeType(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */ | 16384 /* UseAliasDefinedOutsideCurrentScope */, writer);
|
140646
140241
|
});
|
140647
140242
|
}
|
140648
140243
|
function symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration, meaning, flags = 0 /* None */) {
|
@@ -152607,7 +152202,7 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
|
|
152607
152202
|
synchronizeHostData();
|
152608
152203
|
return ts_Completions_exports.getCompletionEntrySymbol(program, log, getValidSourceFile(fileName), position, { name, source }, host, preferences);
|
152609
152204
|
}
|
152610
|
-
function getQuickInfoAtPosition(fileName, position
|
152205
|
+
function getQuickInfoAtPosition(fileName, position) {
|
152611
152206
|
synchronizeHostData();
|
152612
152207
|
const sourceFile = getValidSourceFile(fileName);
|
152613
152208
|
const node = getTouchingPropertyName(sourceFile, position);
|
@@ -152623,41 +152218,19 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
|
|
152623
152218
|
kind: "" /* unknown */,
|
152624
152219
|
kindModifiers: "" /* none */,
|
152625
152220
|
textSpan: createTextSpanFromNode(nodeForQuickInfo, sourceFile),
|
152626
|
-
displayParts: typeChecker.runWithCancellationToken(cancellationToken, (typeChecker2) => typeToDisplayParts(
|
152627
|
-
typeChecker2,
|
152628
|
-
type,
|
152629
|
-
getContainerNode(nodeForQuickInfo),
|
152630
|
-
/*flags*/
|
152631
|
-
void 0,
|
152632
|
-
verbosityLevel
|
152633
|
-
)),
|
152221
|
+
displayParts: typeChecker.runWithCancellationToken(cancellationToken, (typeChecker2) => typeToDisplayParts(typeChecker2, type, getContainerNode(nodeForQuickInfo))),
|
152634
152222
|
documentation: type.symbol ? type.symbol.getDocumentationComment(typeChecker) : void 0,
|
152635
152223
|
tags: type.symbol ? type.symbol.getJsDocTags(typeChecker) : void 0
|
152636
152224
|
};
|
152637
152225
|
}
|
152638
|
-
const { symbolKind, displayParts, documentation, tags
|
152639
|
-
cancellationToken,
|
152640
|
-
(typeChecker2) => ts_SymbolDisplay_exports.getSymbolDisplayPartsDocumentationAndSymbolKind(
|
152641
|
-
typeChecker2,
|
152642
|
-
symbol,
|
152643
|
-
sourceFile,
|
152644
|
-
getContainerNode(nodeForQuickInfo),
|
152645
|
-
nodeForQuickInfo,
|
152646
|
-
/*semanticMeaning*/
|
152647
|
-
void 0,
|
152648
|
-
/*alias*/
|
152649
|
-
void 0,
|
152650
|
-
verbosityLevel
|
152651
|
-
)
|
152652
|
-
);
|
152226
|
+
const { symbolKind, displayParts, documentation, tags } = typeChecker.runWithCancellationToken(cancellationToken, (typeChecker2) => ts_SymbolDisplay_exports.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker2, symbol, sourceFile, getContainerNode(nodeForQuickInfo), nodeForQuickInfo));
|
152653
152227
|
return {
|
152654
152228
|
kind: symbolKind,
|
152655
152229
|
kindModifiers: ts_SymbolDisplay_exports.getSymbolModifiers(typeChecker, symbol),
|
152656
152230
|
textSpan: createTextSpanFromNode(nodeForQuickInfo, sourceFile),
|
152657
152231
|
displayParts,
|
152658
152232
|
documentation,
|
152659
|
-
tags
|
152660
|
-
canIncreaseVerbosityLevel
|
152233
|
+
tags
|
152661
152234
|
};
|
152662
152235
|
}
|
152663
152236
|
function preparePasteEditsForFile(fileName, copiedTextRange) {
|
@@ -177733,7 +177306,7 @@ function getSymbolModifiers(typeChecker, symbol) {
|
|
177733
177306
|
}
|
177734
177307
|
return modifiers.size > 0 ? arrayFrom(modifiers.values()).join(",") : "" /* none */;
|
177735
177308
|
}
|
177736
|
-
function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker, symbol, sourceFile, enclosingDeclaration, location, type, semanticMeaning, alias
|
177309
|
+
function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker, symbol, sourceFile, enclosingDeclaration, location, type, semanticMeaning, alias) {
|
177737
177310
|
var _a;
|
177738
177311
|
const displayParts = [];
|
177739
177312
|
let documentation = [];
|
@@ -177745,7 +177318,6 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker, symb
|
|
177745
177318
|
let documentationFromAlias;
|
177746
177319
|
let tagsFromAlias;
|
177747
177320
|
let hasMultipleSignatures = false;
|
177748
|
-
const typeWriterOut = verbosityLevel !== void 0 ? { couldUnfoldMore: false } : void 0;
|
177749
177321
|
if (location.kind === 110 /* ThisKeyword */ && !isThisExpression) {
|
177750
177322
|
return { displayParts: [keywordPart(110 /* ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* primitiveType */, tags: void 0 };
|
177751
177323
|
}
|
@@ -177905,17 +177477,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker, symb
|
|
177905
177477
|
displayParts.push(spacePart());
|
177906
177478
|
displayParts.push(operatorPart(64 /* EqualsToken */));
|
177907
177479
|
displayParts.push(spacePart());
|
177908
|
-
addRange(
|
177909
|
-
displayParts,
|
177910
|
-
typeToDisplayParts(
|
177911
|
-
typeChecker,
|
177912
|
-
location.parent && isConstTypeReference(location.parent) ? typeChecker.getTypeAtLocation(location.parent) : typeChecker.getDeclaredTypeOfSymbol(symbol),
|
177913
|
-
enclosingDeclaration,
|
177914
|
-
8388608 /* InTypeAlias */,
|
177915
|
-
verbosityLevel,
|
177916
|
-
typeWriterOut
|
177917
|
-
)
|
177918
|
-
);
|
177480
|
+
addRange(displayParts, typeToDisplayParts(typeChecker, location.parent && isConstTypeReference(location.parent) ? typeChecker.getTypeAtLocation(location.parent) : typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 8388608 /* InTypeAlias */));
|
177919
177481
|
}
|
177920
177482
|
if (symbolFlags & 384 /* Enum */) {
|
177921
177483
|
prefixNextMeaning();
|
@@ -178074,32 +177636,12 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker, symb
|
|
178074
177636
|
displayParts.push(spacePart());
|
178075
177637
|
if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */ && symbolKind !== "index" /* indexSignatureElement */) {
|
178076
177638
|
const typeParameterParts = mapToDisplayParts((writer) => {
|
178077
|
-
const param = typeChecker.typeParameterToDeclaration(
|
178078
|
-
type,
|
178079
|
-
enclosingDeclaration,
|
178080
|
-
symbolDisplayNodeBuilderFlags,
|
178081
|
-
/*internalFlags*/
|
178082
|
-
void 0,
|
178083
|
-
/*tracker*/
|
178084
|
-
void 0,
|
178085
|
-
verbosityLevel
|
178086
|
-
);
|
177639
|
+
const param = typeChecker.typeParameterToDeclaration(type, enclosingDeclaration, symbolDisplayNodeBuilderFlags);
|
178087
177640
|
getPrinter().writeNode(4 /* Unspecified */, param, getSourceFileOfNode(getParseTreeNode(enclosingDeclaration)), writer);
|
178088
177641
|
});
|
178089
177642
|
addRange(displayParts, typeParameterParts);
|
178090
177643
|
} else {
|
178091
|
-
addRange(
|
178092
|
-
displayParts,
|
178093
|
-
typeToDisplayParts(
|
178094
|
-
typeChecker,
|
178095
|
-
type,
|
178096
|
-
enclosingDeclaration,
|
178097
|
-
/*flags*/
|
178098
|
-
void 0,
|
178099
|
-
verbosityLevel,
|
178100
|
-
typeWriterOut
|
178101
|
-
)
|
178102
|
-
);
|
177644
|
+
addRange(displayParts, typeToDisplayParts(typeChecker, type, enclosingDeclaration));
|
178103
177645
|
}
|
178104
177646
|
if (isTransientSymbol(symbol) && symbol.links.target && isTransientSymbol(symbol.links.target) && symbol.links.target.links.tupleLabelDeclaration) {
|
178105
177647
|
const labelDecl = symbol.links.target.links.tupleLabelDeclaration;
|
@@ -178164,13 +177706,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker, symb
|
|
178164
177706
|
if (tags.length === 0 && tagsFromAlias) {
|
178165
177707
|
tags = tagsFromAlias;
|
178166
177708
|
}
|
178167
|
-
return {
|
178168
|
-
displayParts,
|
178169
|
-
documentation,
|
178170
|
-
symbolKind,
|
178171
|
-
tags: tags.length === 0 ? void 0 : tags,
|
178172
|
-
canIncreaseVerbosityLevel: typeWriterOut == null ? void 0 : typeWriterOut.couldUnfoldMore
|
178173
|
-
};
|
177709
|
+
return { displayParts, documentation, symbolKind, tags: tags.length === 0 ? void 0 : tags };
|
178174
177710
|
function getPrinter() {
|
178175
177711
|
return createPrinterWithRemoveComments();
|
178176
177712
|
}
|
@@ -178283,7 +177819,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker, symb
|
|
178283
177819
|
addRange(displayParts, typeParameterParts);
|
178284
177820
|
}
|
178285
177821
|
}
|
178286
|
-
function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, enclosingDeclaration, location, semanticMeaning = getMeaningFromLocation(location), alias
|
177822
|
+
function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, enclosingDeclaration, location, semanticMeaning = getMeaningFromLocation(location), alias) {
|
178287
177823
|
return getSymbolDisplayPartsDocumentationAndSymbolKindWorker(
|
178288
177824
|
typeChecker,
|
178289
177825
|
symbol,
|
@@ -178293,8 +177829,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, so
|
|
178293
177829
|
/*type*/
|
178294
177830
|
void 0,
|
178295
177831
|
semanticMeaning,
|
178296
|
-
alias
|
178297
|
-
verbosityLevel
|
177832
|
+
alias
|
178298
177833
|
);
|
178299
177834
|
}
|
178300
177835
|
function isLocalVariableOrFunction(symbol) {
|
@@ -195244,7 +194779,7 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
|
|
195244
194779
|
getQuickInfoWorker(args, simplifiedResult) {
|
195245
194780
|
const { file, project } = this.getFileAndProject(args);
|
195246
194781
|
const scriptInfo = this.projectService.getScriptInfoForNormalizedPath(file);
|
195247
|
-
const quickInfo = project.getLanguageService().getQuickInfoAtPosition(file, this.getPosition(args, scriptInfo)
|
194782
|
+
const quickInfo = project.getLanguageService().getQuickInfoAtPosition(file, this.getPosition(args, scriptInfo));
|
195248
194783
|
if (!quickInfo) {
|
195249
194784
|
return void 0;
|
195250
194785
|
}
|
@@ -195258,8 +194793,7 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
|
|
195258
194793
|
end: scriptInfo.positionToLineOffset(textSpanEnd(quickInfo.textSpan)),
|
195259
194794
|
displayString,
|
195260
194795
|
documentation: useDisplayParts ? this.mapDisplayParts(quickInfo.documentation, project) : displayPartsToString(quickInfo.documentation),
|
195261
|
-
tags: this.mapJSDocTagInfo(quickInfo.tags, project, useDisplayParts)
|
195262
|
-
canIncreaseVerbosityLevel: quickInfo.canIncreaseVerbosityLevel
|
194796
|
+
tags: this.mapJSDocTagInfo(quickInfo.tags, project, useDisplayParts)
|
195263
194797
|
};
|
195264
194798
|
} else {
|
195265
194799
|
return useDisplayParts ? quickInfo : {
|