typescript 5.8.0-dev.20250207 → 5.8.0-dev.20250208
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/_tsc.js
CHANGED
@@ -18,7 +18,7 @@ and limitations under the License.
|
|
18
18
|
|
19
19
|
// src/compiler/corePublic.ts
|
20
20
|
var versionMajorMinor = "5.8";
|
21
|
-
var version = `${versionMajorMinor}.0-dev.
|
21
|
+
var version = `${versionMajorMinor}.0-dev.20250208`;
|
22
22
|
|
23
23
|
// src/compiler/core.ts
|
24
24
|
var emptyArray = [];
|
@@ -3680,7 +3680,6 @@ var ObjectFlags = /* @__PURE__ */ ((ObjectFlags3) => {
|
|
3680
3680
|
ObjectFlags3[ObjectFlags3["IsGenericObjectType"] = 4194304] = "IsGenericObjectType";
|
3681
3681
|
ObjectFlags3[ObjectFlags3["IsGenericIndexType"] = 8388608] = "IsGenericIndexType";
|
3682
3682
|
ObjectFlags3[ObjectFlags3["IsGenericType"] = 12582912] = "IsGenericType";
|
3683
|
-
ObjectFlags3[ObjectFlags3["IsNarrowingType"] = 16777216] = "IsNarrowingType";
|
3684
3683
|
ObjectFlags3[ObjectFlags3["ContainsIntersections"] = 16777216] = "ContainsIntersections";
|
3685
3684
|
ObjectFlags3[ObjectFlags3["IsUnknownLikeUnionComputed"] = 33554432] = "IsUnknownLikeUnionComputed";
|
3686
3685
|
ObjectFlags3[ObjectFlags3["IsUnknownLikeUnion"] = 67108864] = "IsUnknownLikeUnion";
|
@@ -46377,8 +46376,8 @@ function createTypeChecker(host) {
|
|
46377
46376
|
writeSignature: (signature, enclosingDeclaration, flags, kind, writer) => {
|
46378
46377
|
return signatureToString(signature, getParseTreeNode(enclosingDeclaration), flags, kind, writer);
|
46379
46378
|
},
|
46380
|
-
writeType: (type, enclosingDeclaration, flags, writer
|
46381
|
-
return typeToString(type, getParseTreeNode(enclosingDeclaration), flags, writer
|
46379
|
+
writeType: (type, enclosingDeclaration, flags, writer) => {
|
46380
|
+
return typeToString(type, getParseTreeNode(enclosingDeclaration), flags, writer);
|
46382
46381
|
},
|
46383
46382
|
writeSymbol: (symbol, enclosingDeclaration, meaning, flags, writer) => {
|
46384
46383
|
return symbolToString(symbol, getParseTreeNode(enclosingDeclaration), meaning, flags, writer);
|
@@ -47176,7 +47175,6 @@ function createTypeChecker(host) {
|
|
47176
47175
|
[".jsx", ".jsx"],
|
47177
47176
|
[".json", ".json"]
|
47178
47177
|
];
|
47179
|
-
var narrowableReturnTypeCache = /* @__PURE__ */ new Map();
|
47180
47178
|
initializeTypeChecker();
|
47181
47179
|
return checker;
|
47182
47180
|
function isDefinitelyReferenceToGlobalSymbolObject(node) {
|
@@ -50312,18 +50310,14 @@ function createTypeChecker(host) {
|
|
50312
50310
|
return writer2;
|
50313
50311
|
}
|
50314
50312
|
}
|
50315
|
-
function typeToString(type, enclosingDeclaration, flags = 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */, writer = createTextWriter("")
|
50316
|
-
const noTruncation = compilerOptions.noErrorTruncation || flags & 1 /* NoTruncation
|
50313
|
+
function typeToString(type, enclosingDeclaration, flags = 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */, writer = createTextWriter("")) {
|
50314
|
+
const noTruncation = compilerOptions.noErrorTruncation || flags & 1 /* NoTruncation */;
|
50317
50315
|
const typeNode = nodeBuilder.typeToTypeNode(
|
50318
50316
|
type,
|
50319
50317
|
enclosingDeclaration,
|
50320
|
-
toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | (noTruncation ? 1 /* NoTruncation */ : 0),
|
50318
|
+
toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | (noTruncation ? 1 /* NoTruncation */ : 0 /* None */),
|
50321
50319
|
/*internalFlags*/
|
50322
|
-
void 0
|
50323
|
-
/*tracker*/
|
50324
|
-
void 0,
|
50325
|
-
verbosityLevel,
|
50326
|
-
out
|
50320
|
+
void 0
|
50327
50321
|
);
|
50328
50322
|
if (typeNode === void 0) return Debug.fail("should always get typenode");
|
50329
50323
|
const printer = type !== unresolvedType ? createPrinterWithRemoveComments() : createPrinterWithDefaults();
|
@@ -50550,127 +50544,31 @@ function createTypeChecker(host) {
|
|
50550
50544
|
};
|
50551
50545
|
return {
|
50552
50546
|
syntacticBuilderResolver,
|
50553
|
-
typeToTypeNode: (type, enclosingDeclaration, flags, internalFlags, tracker
|
50554
|
-
typePredicateToTypePredicateNode: (typePredicate, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
|
50555
|
-
|
50556
|
-
|
50557
|
-
|
50558
|
-
|
50559
|
-
|
50560
|
-
|
50561
|
-
|
50562
|
-
|
50563
|
-
|
50564
|
-
|
50565
|
-
|
50566
|
-
|
50567
|
-
|
50568
|
-
|
50569
|
-
|
50570
|
-
|
50571
|
-
),
|
50572
|
-
|
50573
|
-
|
50574
|
-
|
50575
|
-
|
50576
|
-
|
50577
|
-
|
50578
|
-
void 0,
|
50579
|
-
(context) => syntacticNodeBuilder.serializeReturnTypeForSignature(signature, getSymbolOfDeclaration(signature), context)
|
50580
|
-
),
|
50581
|
-
serializeTypeForExpression: (expr, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
|
50582
|
-
enclosingDeclaration,
|
50583
|
-
flags,
|
50584
|
-
internalFlags,
|
50585
|
-
tracker,
|
50586
|
-
/*verbosityLevel*/
|
50587
|
-
void 0,
|
50588
|
-
(context) => syntacticNodeBuilder.serializeTypeOfExpression(expr, context)
|
50589
|
-
),
|
50590
|
-
indexInfoToIndexSignatureDeclaration: (indexInfo, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
|
50591
|
-
enclosingDeclaration,
|
50592
|
-
flags,
|
50593
|
-
internalFlags,
|
50594
|
-
tracker,
|
50595
|
-
/*verbosityLevel*/
|
50596
|
-
void 0,
|
50597
|
-
(context) => indexInfoToIndexSignatureDeclarationHelper(
|
50598
|
-
indexInfo,
|
50599
|
-
context,
|
50600
|
-
/*typeNode*/
|
50601
|
-
void 0
|
50602
|
-
)
|
50603
|
-
),
|
50604
|
-
signatureToSignatureDeclaration: (signature, kind, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
|
50605
|
-
enclosingDeclaration,
|
50606
|
-
flags,
|
50607
|
-
internalFlags,
|
50608
|
-
tracker,
|
50609
|
-
/*verbosityLevel*/
|
50610
|
-
void 0,
|
50611
|
-
(context) => signatureToSignatureDeclarationHelper(signature, kind, context)
|
50612
|
-
),
|
50613
|
-
symbolToEntityName: (symbol, meaning, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
|
50614
|
-
enclosingDeclaration,
|
50615
|
-
flags,
|
50616
|
-
internalFlags,
|
50617
|
-
tracker,
|
50618
|
-
/*verbosityLevel*/
|
50619
|
-
void 0,
|
50620
|
-
(context) => symbolToName(
|
50621
|
-
symbol,
|
50622
|
-
context,
|
50623
|
-
meaning,
|
50624
|
-
/*expectsIdentifier*/
|
50625
|
-
false
|
50626
|
-
)
|
50627
|
-
),
|
50628
|
-
symbolToExpression: (symbol, meaning, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
|
50629
|
-
enclosingDeclaration,
|
50630
|
-
flags,
|
50631
|
-
internalFlags,
|
50632
|
-
tracker,
|
50633
|
-
/*verbosityLevel*/
|
50634
|
-
void 0,
|
50635
|
-
(context) => symbolToExpression(symbol, context, meaning)
|
50636
|
-
),
|
50637
|
-
symbolToTypeParameterDeclarations: (symbol, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
|
50638
|
-
enclosingDeclaration,
|
50639
|
-
flags,
|
50640
|
-
internalFlags,
|
50641
|
-
tracker,
|
50642
|
-
/*verbosityLevel*/
|
50643
|
-
void 0,
|
50644
|
-
(context) => typeParametersToTypeParameterDeclarations(symbol, context)
|
50645
|
-
),
|
50646
|
-
symbolToParameterDeclaration: (symbol, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
|
50647
|
-
enclosingDeclaration,
|
50648
|
-
flags,
|
50649
|
-
internalFlags,
|
50650
|
-
tracker,
|
50651
|
-
/*verbosityLevel*/
|
50652
|
-
void 0,
|
50653
|
-
(context) => symbolToParameterDeclaration(symbol, context)
|
50654
|
-
),
|
50655
|
-
typeParameterToDeclaration: (parameter, enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel) => withContext(enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, (context) => typeParameterToDeclaration(parameter, context)),
|
50656
|
-
symbolTableToDeclarationStatements: (symbolTable, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
|
50657
|
-
enclosingDeclaration,
|
50658
|
-
flags,
|
50659
|
-
internalFlags,
|
50660
|
-
tracker,
|
50661
|
-
/*verbosityLevel*/
|
50662
|
-
void 0,
|
50663
|
-
(context) => symbolTableToDeclarationStatements(symbolTable, context)
|
50664
|
-
),
|
50665
|
-
symbolToNode: (symbol, meaning, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
|
50666
|
-
enclosingDeclaration,
|
50667
|
-
flags,
|
50668
|
-
internalFlags,
|
50669
|
-
tracker,
|
50670
|
-
/*verbosityLevel*/
|
50671
|
-
void 0,
|
50672
|
-
(context) => symbolToNode(symbol, context, meaning)
|
50673
|
-
)
|
50547
|
+
typeToTypeNode: (type, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => typeToTypeNodeHelper(type, context)),
|
50548
|
+
typePredicateToTypePredicateNode: (typePredicate, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => typePredicateToTypePredicateNodeHelper(typePredicate, context)),
|
50549
|
+
serializeTypeForExpression: (expr, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => syntacticNodeBuilder.serializeTypeOfExpression(expr, context)),
|
50550
|
+
serializeTypeForDeclaration: (declaration, symbol, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => syntacticNodeBuilder.serializeTypeOfDeclaration(declaration, symbol, context)),
|
50551
|
+
serializeReturnTypeForSignature: (signature, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => syntacticNodeBuilder.serializeReturnTypeForSignature(signature, getSymbolOfDeclaration(signature), context)),
|
50552
|
+
indexInfoToIndexSignatureDeclaration: (indexInfo, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => indexInfoToIndexSignatureDeclarationHelper(
|
50553
|
+
indexInfo,
|
50554
|
+
context,
|
50555
|
+
/*typeNode*/
|
50556
|
+
void 0
|
50557
|
+
)),
|
50558
|
+
signatureToSignatureDeclaration: (signature, kind, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => signatureToSignatureDeclarationHelper(signature, kind, context)),
|
50559
|
+
symbolToEntityName: (symbol, meaning, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => symbolToName(
|
50560
|
+
symbol,
|
50561
|
+
context,
|
50562
|
+
meaning,
|
50563
|
+
/*expectsIdentifier*/
|
50564
|
+
false
|
50565
|
+
)),
|
50566
|
+
symbolToExpression: (symbol, meaning, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => symbolToExpression(symbol, context, meaning)),
|
50567
|
+
symbolToTypeParameterDeclarations: (symbol, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => typeParametersToTypeParameterDeclarations(symbol, context)),
|
50568
|
+
symbolToParameterDeclaration: (symbol, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => symbolToParameterDeclaration(symbol, context)),
|
50569
|
+
typeParameterToDeclaration: (parameter, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => typeParameterToDeclaration(parameter, context)),
|
50570
|
+
symbolTableToDeclarationStatements: (symbolTable, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => symbolTableToDeclarationStatements(symbolTable, context)),
|
50571
|
+
symbolToNode: (symbol, meaning, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => symbolToNode(symbol, context, meaning))
|
50674
50572
|
};
|
50675
50573
|
function getTypeFromTypeNode2(context, node, noMappedTypes) {
|
50676
50574
|
const type = getTypeFromTypeNodeWithoutContext(node);
|
@@ -50712,7 +50610,7 @@ function createTypeChecker(host) {
|
|
50712
50610
|
}
|
50713
50611
|
return symbolToExpression(symbol, context, meaning);
|
50714
50612
|
}
|
50715
|
-
function withContext(enclosingDeclaration, flags, internalFlags, tracker,
|
50613
|
+
function withContext(enclosingDeclaration, flags, internalFlags, tracker, cb) {
|
50716
50614
|
const moduleResolverHost = (tracker == null ? void 0 : tracker.trackSymbol) ? tracker.moduleResolverHost : (internalFlags || 0 /* None */) & 4 /* DoNotIncludeSymbolChain */ ? createBasicNodeBuilderModuleSpecifierResolutionHost(host) : void 0;
|
50717
50615
|
const context = {
|
50718
50616
|
enclosingDeclaration,
|
@@ -50720,7 +50618,6 @@ function createTypeChecker(host) {
|
|
50720
50618
|
flags: flags || 0 /* None */,
|
50721
50619
|
internalFlags: internalFlags || 0 /* None */,
|
50722
50620
|
tracker: void 0,
|
50723
|
-
unfoldDepth: verbosityLevel ?? -1,
|
50724
50621
|
encounteredError: false,
|
50725
50622
|
suppressReportInferenceFallback: false,
|
50726
50623
|
reportedDiagnostic: false,
|
@@ -50742,18 +50639,13 @@ function createTypeChecker(host) {
|
|
50742
50639
|
typeParameterNamesByText: void 0,
|
50743
50640
|
typeParameterNamesByTextNextNameCount: void 0,
|
50744
50641
|
enclosingSymbolTypes: /* @__PURE__ */ new Map(),
|
50745
|
-
mapper: void 0
|
50746
|
-
depth: 0,
|
50747
|
-
couldUnfoldMore: false
|
50642
|
+
mapper: void 0
|
50748
50643
|
};
|
50749
50644
|
context.tracker = new SymbolTrackerImpl(context, tracker, moduleResolverHost);
|
50750
50645
|
const resultingNode = cb(context);
|
50751
50646
|
if (context.truncating && context.flags & 1 /* NoTruncation */) {
|
50752
50647
|
context.tracker.reportTruncationError();
|
50753
50648
|
}
|
50754
|
-
if (out) {
|
50755
|
-
out.couldUnfoldMore = context.couldUnfoldMore;
|
50756
|
-
}
|
50757
50649
|
return context.encounteredError ? void 0 : resultingNode;
|
50758
50650
|
}
|
50759
50651
|
function addSymbolTypeToContext(context, symbol, type) {
|
@@ -50772,36 +50664,16 @@ function createTypeChecker(host) {
|
|
50772
50664
|
function saveRestoreFlags(context) {
|
50773
50665
|
const flags = context.flags;
|
50774
50666
|
const internalFlags = context.internalFlags;
|
50775
|
-
const depth = context.depth;
|
50776
50667
|
return restore;
|
50777
50668
|
function restore() {
|
50778
50669
|
context.flags = flags;
|
50779
50670
|
context.internalFlags = internalFlags;
|
50780
|
-
context.depth = depth;
|
50781
50671
|
}
|
50782
50672
|
}
|
50783
50673
|
function checkTruncationLength(context) {
|
50784
50674
|
if (context.truncating) return context.truncating;
|
50785
50675
|
return context.truncating = context.approximateLength > (context.flags & 1 /* NoTruncation */ ? noTruncationMaximumTruncationLength : defaultMaximumTruncationLength);
|
50786
50676
|
}
|
50787
|
-
function couldUnfoldType(type, context) {
|
50788
|
-
var _a;
|
50789
|
-
if ((_a = context.visitedTypes) == null ? void 0 : _a.has(type.id)) {
|
50790
|
-
return false;
|
50791
|
-
}
|
50792
|
-
return context.depth < context.unfoldDepth || context.depth === context.unfoldDepth && !context.couldUnfoldMore;
|
50793
|
-
}
|
50794
|
-
function canUnfoldType(type, context) {
|
50795
|
-
var _a;
|
50796
|
-
if ((_a = context.visitedTypes) == null ? void 0 : _a.has(type.id)) {
|
50797
|
-
return false;
|
50798
|
-
}
|
50799
|
-
const result = context.depth < context.unfoldDepth;
|
50800
|
-
if (!result) {
|
50801
|
-
context.couldUnfoldMore = true;
|
50802
|
-
}
|
50803
|
-
return result;
|
50804
|
-
}
|
50805
50677
|
function typeToTypeNodeHelper(type, context) {
|
50806
50678
|
const restoreFlags = saveRestoreFlags(context);
|
50807
50679
|
const typeNode = typeToTypeNodeWorker(type, context);
|
@@ -50949,27 +50821,16 @@ function createTypeChecker(host) {
|
|
50949
50821
|
return factory.createThisTypeNode();
|
50950
50822
|
}
|
50951
50823
|
if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) {
|
50952
|
-
|
50953
|
-
|
50954
|
-
|
50955
|
-
|
50956
|
-
return factory.createArrayTypeNode(typeArgumentNodes[0]);
|
50957
|
-
}
|
50958
|
-
return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes);
|
50824
|
+
const typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context);
|
50825
|
+
if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) return factory.createTypeReferenceNode(factory.createIdentifier(""), typeArgumentNodes);
|
50826
|
+
if (length(typeArgumentNodes) === 1 && type.aliasSymbol === globalArrayType.symbol) {
|
50827
|
+
return factory.createArrayTypeNode(typeArgumentNodes[0]);
|
50959
50828
|
}
|
50960
|
-
|
50829
|
+
return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes);
|
50961
50830
|
}
|
50962
50831
|
const objectFlags = getObjectFlags(type);
|
50963
50832
|
if (objectFlags & 4 /* Reference */) {
|
50964
50833
|
Debug.assert(!!(type.flags & 524288 /* Object */));
|
50965
|
-
if (canUnfoldType(type, context)) {
|
50966
|
-
context.depth += 1;
|
50967
|
-
return createAnonymousTypeNode(
|
50968
|
-
type,
|
50969
|
-
/*forceClassExpansion*/
|
50970
|
-
true
|
50971
|
-
);
|
50972
|
-
}
|
50973
50834
|
return type.node ? visitAndTransformType(type, typeReferenceToTypeNode) : typeReferenceToTypeNode(type);
|
50974
50835
|
}
|
50975
50836
|
if (type.flags & 262144 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) {
|
@@ -50999,14 +50860,6 @@ function createTypeChecker(host) {
|
|
50999
50860
|
void 0
|
51000
50861
|
);
|
51001
50862
|
}
|
51002
|
-
if (objectFlags & 3 /* ClassOrInterface */ && canUnfoldType(type, context)) {
|
51003
|
-
context.depth += 1;
|
51004
|
-
return createAnonymousTypeNode(
|
51005
|
-
type,
|
51006
|
-
/*forceClassExpansion*/
|
51007
|
-
true
|
51008
|
-
);
|
51009
|
-
}
|
51010
50863
|
if (type.symbol) {
|
51011
50864
|
return symbolToTypeNode(type.symbol, context, 788968 /* Type */);
|
51012
50865
|
}
|
@@ -51210,7 +51063,7 @@ function createTypeChecker(host) {
|
|
51210
51063
|
}
|
51211
51064
|
return result;
|
51212
51065
|
}
|
51213
|
-
function createAnonymousTypeNode(type2
|
51066
|
+
function createAnonymousTypeNode(type2) {
|
51214
51067
|
var _a2, _b2;
|
51215
51068
|
const typeId = type2.id;
|
51216
51069
|
const symbol = type2.symbol;
|
@@ -51233,7 +51086,7 @@ function createTypeChecker(host) {
|
|
51233
51086
|
const isInstanceType = isClassInstanceSide(type2) ? 788968 /* Type */ : 111551 /* Value */;
|
51234
51087
|
if (isJSConstructor(symbol.valueDeclaration)) {
|
51235
51088
|
return symbolToTypeNode(symbol, context, isInstanceType);
|
51236
|
-
} else if (symbol.flags & 32 /* Class */ && !
|
51089
|
+
} else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration && isClassLike(symbol.valueDeclaration) && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ && (!isClassDeclaration(symbol.valueDeclaration) || isSymbolAccessible(
|
51237
51090
|
symbol,
|
51238
51091
|
context.enclosingDeclaration,
|
51239
51092
|
isInstanceType,
|
@@ -51277,7 +51130,7 @@ function createTypeChecker(host) {
|
|
51277
51130
|
if (id && !context.symbolDepth) {
|
51278
51131
|
context.symbolDepth = /* @__PURE__ */ new Map();
|
51279
51132
|
}
|
51280
|
-
const links = context.
|
51133
|
+
const links = context.enclosingDeclaration && getNodeLinks(context.enclosingDeclaration);
|
51281
51134
|
const key = `${getTypeId(type2)}|${context.flags}|${context.internalFlags}`;
|
51282
51135
|
if (links) {
|
51283
51136
|
links.serializedTypes || (links.serializedTypes = /* @__PURE__ */ new Map());
|
@@ -52224,7 +52077,7 @@ function createTypeChecker(host) {
|
|
52224
52077
|
return factory.createTypeParameterDeclaration(modifiers, name, constraintNode, defaultParameterNode);
|
52225
52078
|
}
|
52226
52079
|
function typeToTypeNodeHelperWithPossibleReusableTypeNode(type, typeNode, context) {
|
52227
|
-
return
|
52080
|
+
return typeNode && getTypeFromTypeNode2(context, typeNode) === type && syntacticNodeBuilder.tryReuseExistingTypeNode(context, typeNode) || typeToTypeNodeHelper(type, context);
|
52228
52081
|
}
|
52229
52082
|
function typeParameterToDeclaration(type, context, constraint = getConstraintOfTypeParameter(type)) {
|
52230
52083
|
const constraintNode = constraint && typeToTypeNodeHelperWithPossibleReusableTypeNode(constraint, getConstraintDeclaration(type), context);
|
@@ -52871,7 +52724,7 @@ function createTypeChecker(host) {
|
|
52871
52724
|
let result;
|
52872
52725
|
const addUndefinedForParameter = declaration && (isParameter(declaration) || isJSDocParameterTag(declaration)) && requiresAddingImplicitUndefined(declaration, context.enclosingDeclaration);
|
52873
52726
|
const decl = declaration ?? symbol.valueDeclaration ?? getDeclarationWithTypeAnnotation(symbol) ?? ((_a = symbol.declarations) == null ? void 0 : _a[0]);
|
52874
|
-
if (
|
52727
|
+
if (decl) {
|
52875
52728
|
if (isAccessor(decl)) {
|
52876
52729
|
result = syntacticNodeBuilder.serializeTypeOfAccessor(decl, symbol, context);
|
52877
52730
|
} else if (hasInferredType(decl) && !nodeIsSynthesized(decl) && !(getObjectFlags(type) & 196608 /* RequiresWidening */)) {
|
@@ -59583,14 +59436,11 @@ function createTypeChecker(host) {
|
|
59583
59436
|
function isNoInferType(type) {
|
59584
59437
|
return !!(type.flags & 33554432 /* Substitution */ && type.constraint.flags & 2 /* Unknown */);
|
59585
59438
|
}
|
59586
|
-
function
|
59587
|
-
return
|
59439
|
+
function getSubstitutionType(baseType, constraint) {
|
59440
|
+
return constraint.flags & 3 /* AnyOrUnknown */ || constraint === baseType || baseType.flags & 1 /* Any */ ? baseType : getOrCreateSubstitutionType(baseType, constraint);
|
59588
59441
|
}
|
59589
|
-
function
|
59590
|
-
|
59591
|
-
}
|
59592
|
-
function getOrCreateSubstitutionType(baseType, constraint, isNarrowed) {
|
59593
|
-
const id = `${getTypeId(baseType)}>${getTypeId(constraint)}${isNarrowed ? ">N" : ""}`;
|
59442
|
+
function getOrCreateSubstitutionType(baseType, constraint) {
|
59443
|
+
const id = `${getTypeId(baseType)}>${getTypeId(constraint)}`;
|
59594
59444
|
const cached = substitutionTypes.get(id);
|
59595
59445
|
if (cached) {
|
59596
59446
|
return cached;
|
@@ -59598,9 +59448,6 @@ function createTypeChecker(host) {
|
|
59598
59448
|
const result = createType(33554432 /* Substitution */);
|
59599
59449
|
result.baseType = baseType;
|
59600
59450
|
result.constraint = constraint;
|
59601
|
-
if (isNarrowed) {
|
59602
|
-
result.objectFlags |= 16777216 /* IsNarrowingType */;
|
59603
|
-
}
|
59604
59451
|
substitutionTypes.set(id, result);
|
59605
59452
|
return result;
|
59606
59453
|
}
|
@@ -61806,7 +61653,7 @@ function createTypeChecker(host) {
|
|
61806
61653
|
function isDeferredType(type, checkTuples) {
|
61807
61654
|
return isGenericType(type) || checkTuples && isTupleType(type) && some(getElementTypes(type), isGenericType);
|
61808
61655
|
}
|
61809
|
-
function getConditionalType(root, mapper, forConstraint, aliasSymbol, aliasTypeArguments
|
61656
|
+
function getConditionalType(root, mapper, forConstraint, aliasSymbol, aliasTypeArguments) {
|
61810
61657
|
let result;
|
61811
61658
|
let extraTypes;
|
61812
61659
|
let tailCount = 0;
|
@@ -61823,11 +61670,10 @@ function createTypeChecker(host) {
|
|
61823
61670
|
if (checkType === wildcardType || extendsType === wildcardType) {
|
61824
61671
|
return wildcardType;
|
61825
61672
|
}
|
61826
|
-
const effectiveCheckType = forNarrowing && isNarrowingSubstitutionType(checkType) ? checkType.constraint : checkType;
|
61827
61673
|
const checkTypeNode = skipTypeParentheses(root.node.checkType);
|
61828
61674
|
const extendsTypeNode = skipTypeParentheses(root.node.extendsType);
|
61829
61675
|
const checkTuples = isSimpleTupleType(checkTypeNode) && isSimpleTupleType(extendsTypeNode) && length(checkTypeNode.elements) === length(extendsTypeNode.elements);
|
61830
|
-
const checkTypeDeferred = isDeferredType(
|
61676
|
+
const checkTypeDeferred = isDeferredType(checkType, checkTuples);
|
61831
61677
|
let combinedMapper;
|
61832
61678
|
if (root.inferTypeParameters) {
|
61833
61679
|
const context = createInferenceContext(
|
@@ -61846,8 +61692,8 @@ function createTypeChecker(host) {
|
|
61846
61692
|
}
|
61847
61693
|
const inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType;
|
61848
61694
|
if (!checkTypeDeferred && !isDeferredType(inferredExtendsType, checkTuples)) {
|
61849
|
-
if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && (
|
61850
|
-
if (
|
61695
|
+
if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && (checkType.flags & 1 /* Any */ || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) {
|
61696
|
+
if (checkType.flags & 1 /* Any */ || forConstraint && !(inferredExtendsType.flags & 131072 /* Never */) && someType(getPermissiveInstantiation(inferredExtendsType), (t) => isTypeAssignableTo(t, getPermissiveInstantiation(checkType)))) {
|
61851
61697
|
(extraTypes || (extraTypes = [])).push(instantiateType(getTypeFromTypeNode(root.node.trueType), combinedMapper || mapper));
|
61852
61698
|
}
|
61853
61699
|
const falseType2 = getTypeFromTypeNode(root.node.falseType);
|
@@ -61864,7 +61710,7 @@ function createTypeChecker(host) {
|
|
61864
61710
|
result = instantiateType(falseType2, mapper);
|
61865
61711
|
break;
|
61866
61712
|
}
|
61867
|
-
if (inferredExtendsType.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(
|
61713
|
+
if (inferredExtendsType.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) {
|
61868
61714
|
const trueType2 = getTypeFromTypeNode(root.node.trueType);
|
61869
61715
|
const trueMapper = combinedMapper || mapper;
|
61870
61716
|
if (canTailRecurse(trueType2, trueMapper)) {
|
@@ -62830,39 +62676,8 @@ function createTypeChecker(host) {
|
|
62830
62676
|
if (!result) {
|
62831
62677
|
const newMapper = createTypeMapper(root.outerTypeParameters, typeArguments);
|
62832
62678
|
const checkType = root.checkType;
|
62833
|
-
|
62834
|
-
|
62835
|
-
const forNarrowing = distributionType && isNarrowingSubstitutionType(distributionType) && isNarrowableConditionalType(type, mapper);
|
62836
|
-
if (forNarrowing) {
|
62837
|
-
narrowingBaseType = distributionType.baseType;
|
62838
|
-
distributionType = getReducedType(distributionType.constraint);
|
62839
|
-
}
|
62840
|
-
if (distributionType && checkType !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */)) {
|
62841
|
-
if (narrowingBaseType) {
|
62842
|
-
result = mapTypeToIntersection(
|
62843
|
-
distributionType,
|
62844
|
-
(t) => getConditionalType(
|
62845
|
-
root,
|
62846
|
-
prependTypeMapping(checkType, getSubstitutionType(
|
62847
|
-
narrowingBaseType,
|
62848
|
-
t,
|
62849
|
-
/*isNarrowed*/
|
62850
|
-
true
|
62851
|
-
), newMapper),
|
62852
|
-
forConstraint,
|
62853
|
-
/*aliasSymbol*/
|
62854
|
-
void 0,
|
62855
|
-
/*aliasTypeArguments*/
|
62856
|
-
void 0,
|
62857
|
-
forNarrowing
|
62858
|
-
)
|
62859
|
-
);
|
62860
|
-
} else {
|
62861
|
-
result = mapTypeWithAlias(distributionType, (t) => getConditionalType(root, prependTypeMapping(checkType, t, newMapper), forConstraint), aliasSymbol, aliasTypeArguments);
|
62862
|
-
}
|
62863
|
-
} else {
|
62864
|
-
result = getConditionalType(root, newMapper, forConstraint, aliasSymbol, aliasTypeArguments, forNarrowing);
|
62865
|
-
}
|
62679
|
+
const distributionType = root.isDistributive ? getReducedType(getMappedType(checkType, newMapper)) : void 0;
|
62680
|
+
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);
|
62866
62681
|
root.instantiations.set(id, result);
|
62867
62682
|
}
|
62868
62683
|
return result;
|
@@ -64005,12 +63820,10 @@ function createTypeChecker(host) {
|
|
64005
63820
|
function shouldNormalizeIntersection(type) {
|
64006
63821
|
let hasInstantiable = false;
|
64007
63822
|
let hasNullableOrEmpty = false;
|
64008
|
-
let hasSubstitution = false;
|
64009
63823
|
for (const t of type.types) {
|
64010
63824
|
hasInstantiable || (hasInstantiable = !!(t.flags & 465829888 /* Instantiable */));
|
64011
63825
|
hasNullableOrEmpty || (hasNullableOrEmpty = !!(t.flags & 98304 /* Nullable */) || isEmptyAnonymousObjectType(t));
|
64012
|
-
|
64013
|
-
if (hasInstantiable && hasNullableOrEmpty || hasSubstitution) return true;
|
63826
|
+
if (hasInstantiable && hasNullableOrEmpty) return true;
|
64014
63827
|
}
|
64015
63828
|
return false;
|
64016
63829
|
}
|
@@ -69170,18 +68983,6 @@ function createTypeChecker(host) {
|
|
69170
68983
|
}
|
69171
68984
|
return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* None */ : 1 /* Literal */) : type;
|
69172
68985
|
}
|
69173
|
-
function mapTypeToIntersection(type, mapper) {
|
69174
|
-
if (type.flags & 131072 /* Never */) {
|
69175
|
-
return type;
|
69176
|
-
}
|
69177
|
-
if (!(type.flags & 1048576 /* Union */)) {
|
69178
|
-
return mapper(type);
|
69179
|
-
}
|
69180
|
-
const origin = type.origin;
|
69181
|
-
const types = origin && origin.flags & 1048576 /* Union */ ? origin.types : type.types;
|
69182
|
-
const mappedTypes = types.map((t) => t.flags & 1048576 /* Union */ ? mapTypeToIntersection(t, mapper) : mapper(t));
|
69183
|
-
return getIntersectionType(mappedTypes);
|
69184
|
-
}
|
69185
68986
|
function mapTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) {
|
69186
68987
|
return type.flags & 1048576 /* Union */ && aliasSymbol ? getUnionType(map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments) : mapType(type, mapper);
|
69187
68988
|
}
|
@@ -70766,11 +70567,11 @@ function createTypeChecker(host) {
|
|
70766
70567
|
));
|
70767
70568
|
return contextualType && !isGenericType(contextualType);
|
70768
70569
|
}
|
70769
|
-
function getNarrowableTypeForReference(type, reference, checkMode
|
70570
|
+
function getNarrowableTypeForReference(type, reference, checkMode) {
|
70770
70571
|
if (isNoInferType(type)) {
|
70771
70572
|
type = type.baseType;
|
70772
70573
|
}
|
70773
|
-
const substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) && someType(type, isGenericTypeWithUnionConstraint) && (
|
70574
|
+
const substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) && someType(type, isGenericTypeWithUnionConstraint) && (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
|
70774
70575
|
return substituteConstraints ? mapType(type, getBaseConstraintOrType) : type;
|
70775
70576
|
}
|
70776
70577
|
function isExportOrExportExpression(location) {
|
@@ -71897,16 +71698,9 @@ function createTypeChecker(host) {
|
|
71897
71698
|
function getContextualTypeForReturnExpression(node, contextFlags) {
|
71898
71699
|
const func = getContainingFunction(node);
|
71899
71700
|
if (func) {
|
71900
|
-
const functionFlags = getFunctionFlags(func);
|
71901
|
-
const links = getNodeLinks(node);
|
71902
|
-
if (links.contextualReturnType) {
|
71903
|
-
if (functionFlags & 2 /* Async */) {
|
71904
|
-
return getUnionType([links.contextualReturnType, createPromiseLikeType(links.contextualReturnType)]);
|
71905
|
-
}
|
71906
|
-
return links.contextualReturnType;
|
71907
|
-
}
|
71908
71701
|
let contextualReturnType = getContextualReturnType(func, contextFlags);
|
71909
71702
|
if (contextualReturnType) {
|
71703
|
+
const functionFlags = getFunctionFlags(func);
|
71910
71704
|
if (functionFlags & 1 /* Generator */) {
|
71911
71705
|
const isAsyncGenerator = (functionFlags & 2 /* Async */) !== 0;
|
71912
71706
|
if (contextualReturnType.flags & 1048576 /* Union */) {
|
@@ -72604,13 +72398,6 @@ function createTypeChecker(host) {
|
|
72604
72398
|
if (index >= 0) {
|
72605
72399
|
return contextualTypes[index];
|
72606
72400
|
}
|
72607
|
-
const links = getNodeLinks(node);
|
72608
|
-
if (links.contextualReturnType) {
|
72609
|
-
if (node.flags & 65536 /* AwaitContext */) {
|
72610
|
-
return getUnionType([links.contextualReturnType, createPromiseLikeType(links.contextualReturnType)]);
|
72611
|
-
}
|
72612
|
-
return links.contextualReturnType;
|
72613
|
-
}
|
72614
72401
|
const { parent } = node;
|
72615
72402
|
switch (parent.kind) {
|
72616
72403
|
case 260 /* VariableDeclaration */:
|
@@ -83599,199 +83386,7 @@ function createTypeChecker(host) {
|
|
83599
83386
|
) : exprType;
|
83600
83387
|
const effectiveExpr = expr && getEffectiveCheckNode(expr);
|
83601
83388
|
const errorNode = inReturnStatement && !inConditionalExpression ? node : effectiveExpr;
|
83602
|
-
|
83603
|
-
checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, errorNode, effectiveExpr);
|
83604
|
-
return;
|
83605
|
-
}
|
83606
|
-
if (checkTypeAssignableTo(
|
83607
|
-
unwrappedExprType,
|
83608
|
-
unwrappedReturnType,
|
83609
|
-
/*errorNode*/
|
83610
|
-
void 0
|
83611
|
-
)) {
|
83612
|
-
return;
|
83613
|
-
}
|
83614
|
-
let narrowPosition = node;
|
83615
|
-
let narrowFlowNode = inReturnStatement && node.flowNode;
|
83616
|
-
if (expr && isConditionalExpression(expr.parent)) {
|
83617
|
-
narrowFlowNode = expr.parent.whenTrue === expr ? expr.parent.flowNodeWhenTrue : expr.parent.flowNodeWhenFalse;
|
83618
|
-
narrowPosition = expr;
|
83619
|
-
}
|
83620
|
-
if (!narrowFlowNode) {
|
83621
|
-
checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, errorNode, effectiveExpr);
|
83622
|
-
return;
|
83623
|
-
}
|
83624
|
-
const allTypeParameters = appendTypeParameters(getOuterTypeParameters(
|
83625
|
-
container,
|
83626
|
-
/*includeThisTypes*/
|
83627
|
-
false
|
83628
|
-
), getEffectiveTypeParameterDeclarations(container));
|
83629
|
-
const narrowableTypeParameters = allTypeParameters && getNarrowableTypeParameters(allTypeParameters);
|
83630
|
-
if (!narrowableTypeParameters || !narrowableTypeParameters.length || !isNarrowableReturnType(unwrappedReturnType)) {
|
83631
|
-
checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, errorNode, effectiveExpr);
|
83632
|
-
return;
|
83633
|
-
}
|
83634
|
-
const narrowedTypeParameters = [];
|
83635
|
-
const narrowedTypes = [];
|
83636
|
-
for (const [typeParam, symbol, reference] of narrowableTypeParameters) {
|
83637
|
-
const narrowReference = factory.cloneNode(reference);
|
83638
|
-
narrowReference.id = void 0;
|
83639
|
-
getNodeLinks(narrowReference).resolvedSymbol = symbol;
|
83640
|
-
setParent(narrowReference, narrowPosition.parent);
|
83641
|
-
narrowReference.flowNode = narrowFlowNode;
|
83642
|
-
const initialType = getNarrowableTypeForReference(
|
83643
|
-
typeParam,
|
83644
|
-
narrowReference,
|
83645
|
-
/*checkMode*/
|
83646
|
-
void 0,
|
83647
|
-
/*forReturnTypeNarrowing*/
|
83648
|
-
true
|
83649
|
-
);
|
83650
|
-
if (initialType === typeParam) {
|
83651
|
-
continue;
|
83652
|
-
}
|
83653
|
-
const flowType = getFlowTypeOfReference(narrowReference, initialType);
|
83654
|
-
const exprType2 = getTypeFromFlowType(flowType);
|
83655
|
-
if (exprType2.flags & 3 /* AnyOrUnknown */ || isErrorType(exprType2) || exprType2 === typeParam || exprType2 === mapType(typeParam, getBaseConstraintOrType)) {
|
83656
|
-
continue;
|
83657
|
-
}
|
83658
|
-
const narrowedType = getSubstitutionType(
|
83659
|
-
typeParam,
|
83660
|
-
exprType2,
|
83661
|
-
/*isNarrowed*/
|
83662
|
-
true
|
83663
|
-
);
|
83664
|
-
narrowedTypeParameters.push(typeParam);
|
83665
|
-
narrowedTypes.push(narrowedType);
|
83666
|
-
}
|
83667
|
-
const narrowMapper = createTypeMapper(narrowedTypeParameters, narrowedTypes);
|
83668
|
-
const narrowedReturnType = instantiateType(
|
83669
|
-
unwrappedReturnType,
|
83670
|
-
narrowMapper
|
83671
|
-
);
|
83672
|
-
if (expr) {
|
83673
|
-
const links = getNodeLinks(expr);
|
83674
|
-
if (!links.contextualReturnType) {
|
83675
|
-
links.contextualReturnType = narrowedReturnType;
|
83676
|
-
}
|
83677
|
-
}
|
83678
|
-
const narrowedExprType = expr ? checkExpression(expr) : undefinedType;
|
83679
|
-
const narrowedUnwrappedExprType = functionFlags & 2 /* Async */ ? checkAwaitedType(
|
83680
|
-
narrowedExprType,
|
83681
|
-
/*withAlias*/
|
83682
|
-
false,
|
83683
|
-
node,
|
83684
|
-
Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member
|
83685
|
-
) : narrowedExprType;
|
83686
|
-
checkTypeAssignableToAndOptionallyElaborate(narrowedUnwrappedExprType, narrowedReturnType, errorNode, effectiveExpr);
|
83687
|
-
}
|
83688
|
-
function getNarrowableTypeParameters(candidates) {
|
83689
|
-
const narrowableParams = [];
|
83690
|
-
for (const typeParam of candidates) {
|
83691
|
-
const constraint = getConstraintOfTypeParameter(typeParam);
|
83692
|
-
if (!constraint || !(constraint.flags & 1048576 /* Union */)) continue;
|
83693
|
-
if (typeParam.symbol && typeParam.symbol.declarations && typeParam.symbol.declarations.length === 1) {
|
83694
|
-
const declaration = typeParam.symbol.declarations[0];
|
83695
|
-
const container = isJSDocTemplateTag(declaration.parent) ? getJSDocHost(declaration.parent) : declaration.parent;
|
83696
|
-
if (!isFunctionLike(container)) continue;
|
83697
|
-
let reference;
|
83698
|
-
let hasInvalidReference = false;
|
83699
|
-
for (const paramDecl of container.parameters) {
|
83700
|
-
const typeNode = getEffectiveTypeAnnotationNode(paramDecl);
|
83701
|
-
if (!typeNode) continue;
|
83702
|
-
if (isTypeParameterReferenced(typeParam, typeNode)) {
|
83703
|
-
let candidateReference;
|
83704
|
-
if (isTypeReferenceNode(typeNode) && isReferenceToTypeParameter(typeParam, typeNode) && (candidateReference = getValidParameterReference(paramDecl, constraint))) {
|
83705
|
-
if (reference) {
|
83706
|
-
hasInvalidReference = true;
|
83707
|
-
break;
|
83708
|
-
}
|
83709
|
-
reference = candidateReference;
|
83710
|
-
} else {
|
83711
|
-
hasInvalidReference = true;
|
83712
|
-
break;
|
83713
|
-
}
|
83714
|
-
}
|
83715
|
-
}
|
83716
|
-
if (!hasInvalidReference && reference) {
|
83717
|
-
const symbol = getResolvedSymbol(reference);
|
83718
|
-
if (symbol !== unknownSymbol) narrowableParams.push([typeParam, symbol, reference]);
|
83719
|
-
}
|
83720
|
-
}
|
83721
|
-
}
|
83722
|
-
return narrowableParams;
|
83723
|
-
function getValidParameterReference(paramDecl, constraint) {
|
83724
|
-
if (!isIdentifier(paramDecl.name)) return;
|
83725
|
-
const isOptional = !!paramDecl.questionToken || isJSDocOptionalParameter(paramDecl);
|
83726
|
-
if (isOptional && !containsUndefinedType(constraint)) return;
|
83727
|
-
return paramDecl.name;
|
83728
|
-
}
|
83729
|
-
function isReferenceToTypeParameter(typeParam, node) {
|
83730
|
-
return getTypeFromTypeReference(node) === typeParam;
|
83731
|
-
}
|
83732
|
-
function isTypeParameterReferenced(typeParam, node) {
|
83733
|
-
return isReferenced(node);
|
83734
|
-
function isReferenced(node2) {
|
83735
|
-
if (isTypeReferenceNode(node2)) {
|
83736
|
-
return isReferenceToTypeParameter(typeParam, node2);
|
83737
|
-
}
|
83738
|
-
if (isTypeQueryNode(node2)) {
|
83739
|
-
return isTypeParameterPossiblyReferenced(typeParam, node2);
|
83740
|
-
}
|
83741
|
-
return !!forEachChild(node2, isReferenced);
|
83742
|
-
}
|
83743
|
-
}
|
83744
|
-
}
|
83745
|
-
function isNarrowableReturnType(returnType) {
|
83746
|
-
return isConditionalType(returnType) ? isNarrowableConditionalType(returnType) : !!(returnType.indexType.flags & 262144 /* TypeParameter */);
|
83747
|
-
}
|
83748
|
-
function isNarrowableConditionalType(type, mapper) {
|
83749
|
-
const typeArguments = mapper && map(type.root.outerTypeParameters, (t) => {
|
83750
|
-
const mapped = getMappedType(t, mapper);
|
83751
|
-
if (isNarrowingSubstitutionType(mapped)) {
|
83752
|
-
return mapped.baseType;
|
83753
|
-
}
|
83754
|
-
return mapped;
|
83755
|
-
});
|
83756
|
-
const id = `${type.id}:${getTypeListId(typeArguments)}`;
|
83757
|
-
let result = narrowableReturnTypeCache.get(id);
|
83758
|
-
if (result === void 0) {
|
83759
|
-
const nonNarrowingMapper = type.root.outerTypeParameters && typeArguments && createTypeMapper(type.root.outerTypeParameters, typeArguments);
|
83760
|
-
const instantiatedType = instantiateType(type, nonNarrowingMapper);
|
83761
|
-
result = isConditionalType(instantiatedType) && isNarrowableConditionalTypeWorker(instantiatedType);
|
83762
|
-
narrowableReturnTypeCache.set(id, result);
|
83763
|
-
}
|
83764
|
-
return result;
|
83765
|
-
}
|
83766
|
-
function isNarrowableConditionalTypeWorker(type) {
|
83767
|
-
if (!type.root.isDistributive) {
|
83768
|
-
return false;
|
83769
|
-
}
|
83770
|
-
if (type.root.inferTypeParameters) {
|
83771
|
-
return false;
|
83772
|
-
}
|
83773
|
-
if (!(type.checkType.flags & 262144 /* TypeParameter */)) {
|
83774
|
-
return false;
|
83775
|
-
}
|
83776
|
-
const constraintType = getConstraintOfTypeParameter(type.checkType);
|
83777
|
-
if (!constraintType || !(constraintType.flags & 1048576 /* Union */)) {
|
83778
|
-
return false;
|
83779
|
-
}
|
83780
|
-
if (!everyType(type.extendsType, (extendsType) => some(
|
83781
|
-
constraintType.types,
|
83782
|
-
(constraintType2) => isTypeIdenticalTo(constraintType2, extendsType)
|
83783
|
-
))) {
|
83784
|
-
return false;
|
83785
|
-
}
|
83786
|
-
const trueType2 = getTrueTypeFromConditionalType(type);
|
83787
|
-
const isValidTrueType = isConditionalType(trueType2) ? isNarrowableConditionalType(trueType2) : true;
|
83788
|
-
if (!isValidTrueType) return false;
|
83789
|
-
const falseType2 = getFalseTypeFromConditionalType(type);
|
83790
|
-
const isValidFalseType = isConditionalType(falseType2) ? isNarrowableConditionalType(falseType2) : falseType2 === neverType;
|
83791
|
-
return isValidFalseType;
|
83792
|
-
}
|
83793
|
-
function isConditionalType(type) {
|
83794
|
-
return !!(type.flags & 16777216 /* Conditional */);
|
83389
|
+
checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, errorNode, effectiveExpr);
|
83795
83390
|
}
|
83796
83391
|
function checkWithStatement(node) {
|
83797
83392
|
if (!checkGrammarStatementInAmbientContext(node)) {
|