@typescript-deploys/pr-build 5.2.0-pr-54282-26 → 5.2.0-pr-54281-25
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 +32 -315
- package/lib/tsserver.js +246 -378
- package/lib/tsserverlibrary.js +264 -387
- package/lib/typescript.js +264 -387
- package/lib/typingsInstaller.js +3 -0
- package/package.json +2 -2
package/lib/tsc.js
CHANGED
|
@@ -7729,6 +7729,9 @@ var Diagnostics = {
|
|
|
7729
7729
|
Use_type_0: diag(95181, 3 /* Message */, "Use_type_0_95181", "Use 'type {0}'"),
|
|
7730
7730
|
Fix_all_with_type_only_imports: diag(95182, 3 /* Message */, "Fix_all_with_type_only_imports_95182", "Fix all with type-only imports"),
|
|
7731
7731
|
Cannot_move_statements_to_the_selected_file: diag(95183, 3 /* Message */, "Cannot_move_statements_to_the_selected_file_95183", "Cannot move statements to the selected file"),
|
|
7732
|
+
Inline_variable: diag(95184, 3 /* Message */, "Inline_variable_95184", "Inline variable"),
|
|
7733
|
+
Could_not_find_variable_to_inline: diag(95185, 3 /* Message */, "Could_not_find_variable_to_inline_95185", "Could not find variable to inline."),
|
|
7734
|
+
Variables_with_multiple_declarations_cannot_be_inlined: diag(95186, 3 /* Message */, "Variables_with_multiple_declarations_cannot_be_inlined_95186", "Variables with multiple declarations cannot be inlined."),
|
|
7732
7735
|
No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, 1 /* Error */, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."),
|
|
7733
7736
|
Classes_may_not_have_a_field_named_constructor: diag(18006, 1 /* Error */, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."),
|
|
7734
7737
|
JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, 1 /* Error */, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"),
|
|
@@ -10049,15 +10052,6 @@ function createTextChangeRange(span, newLength) {
|
|
|
10049
10052
|
return { span, newLength };
|
|
10050
10053
|
}
|
|
10051
10054
|
var unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0);
|
|
10052
|
-
function getTypeParameterOwner(d) {
|
|
10053
|
-
if (d && d.kind === 167 /* TypeParameter */) {
|
|
10054
|
-
for (let current = d; current; current = current.parent) {
|
|
10055
|
-
if (isFunctionLike(current) || isClassLike(current) || current.kind === 263 /* InterfaceDeclaration */) {
|
|
10056
|
-
return current;
|
|
10057
|
-
}
|
|
10058
|
-
}
|
|
10059
|
-
}
|
|
10060
|
-
}
|
|
10061
10055
|
function isParameterPropertyDeclaration(node, parent) {
|
|
10062
10056
|
return isParameter(node) && hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) && parent.kind === 175 /* Constructor */;
|
|
10063
10057
|
}
|
|
@@ -57454,114 +57448,6 @@ function createTypeChecker(host) {
|
|
|
57454
57448
|
}
|
|
57455
57449
|
return links.resolvedType;
|
|
57456
57450
|
}
|
|
57457
|
-
function getNarrowConditionalType(root, narrowMapper, mapper, aliasSymbol, aliasTypeArguments) {
|
|
57458
|
-
let result;
|
|
57459
|
-
let extraTypes;
|
|
57460
|
-
let tailCount = 0;
|
|
57461
|
-
while (true) {
|
|
57462
|
-
if (tailCount === 1e3) {
|
|
57463
|
-
error(currentNode, Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
|
|
57464
|
-
return errorType;
|
|
57465
|
-
}
|
|
57466
|
-
const checkType = instantiateNarrowType(getActualTypeVariable(root.checkType), narrowMapper, mapper);
|
|
57467
|
-
const extendsType = instantiateType(root.extendsType, mapper);
|
|
57468
|
-
if (checkType === errorType || extendsType === errorType) {
|
|
57469
|
-
return errorType;
|
|
57470
|
-
}
|
|
57471
|
-
if (checkType === wildcardType || extendsType === wildcardType) {
|
|
57472
|
-
return wildcardType;
|
|
57473
|
-
}
|
|
57474
|
-
const checkTypeDeferred = false;
|
|
57475
|
-
let combinedMapper;
|
|
57476
|
-
if (root.inferTypeParameters) {
|
|
57477
|
-
const freshParams = sameMap(root.inferTypeParameters, maybeCloneTypeParameter);
|
|
57478
|
-
const freshMapper = freshParams !== root.inferTypeParameters ? createTypeMapper(root.inferTypeParameters, freshParams) : void 0;
|
|
57479
|
-
const context = createInferenceContext(
|
|
57480
|
-
freshParams,
|
|
57481
|
-
/*signature*/
|
|
57482
|
-
void 0,
|
|
57483
|
-
0 /* None */
|
|
57484
|
-
);
|
|
57485
|
-
if (freshMapper) {
|
|
57486
|
-
const freshCombinedMapper = combineTypeMappers(mapper, freshMapper);
|
|
57487
|
-
for (const p of freshParams) {
|
|
57488
|
-
if (root.inferTypeParameters.indexOf(p) === -1) {
|
|
57489
|
-
p.mapper = freshCombinedMapper;
|
|
57490
|
-
}
|
|
57491
|
-
}
|
|
57492
|
-
}
|
|
57493
|
-
if (!checkTypeDeferred) {
|
|
57494
|
-
inferTypes(context.inferences, checkType, instantiateType(extendsType, freshMapper), 512 /* NoConstraints */ | 1024 /* AlwaysStrict */);
|
|
57495
|
-
}
|
|
57496
|
-
const innerMapper = combineTypeMappers(freshMapper, context.mapper);
|
|
57497
|
-
combinedMapper = mapper ? combineTypeMappers(innerMapper, mapper) : innerMapper;
|
|
57498
|
-
}
|
|
57499
|
-
const inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType;
|
|
57500
|
-
if (true) {
|
|
57501
|
-
if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && (checkType.flags & 1 /* Any */ || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) {
|
|
57502
|
-
if (checkType.flags & 1 /* Any */) {
|
|
57503
|
-
(extraTypes || (extraTypes = [])).push(
|
|
57504
|
-
instantiateNarrowType(getTypeFromTypeNode(root.node.trueType), narrowMapper, combinedMapper || mapper)
|
|
57505
|
-
);
|
|
57506
|
-
}
|
|
57507
|
-
const falseType2 = getTypeFromTypeNode(root.node.falseType);
|
|
57508
|
-
if (falseType2.flags & 16777216 /* Conditional */) {
|
|
57509
|
-
const newRoot = falseType2.root;
|
|
57510
|
-
if (newRoot.node.parent === root.node && (!newRoot.isDistributive || newRoot.checkType === root.checkType)) {
|
|
57511
|
-
root = newRoot;
|
|
57512
|
-
continue;
|
|
57513
|
-
}
|
|
57514
|
-
if (canTailRecurse(falseType2, mapper)) {
|
|
57515
|
-
continue;
|
|
57516
|
-
}
|
|
57517
|
-
}
|
|
57518
|
-
result = instantiateNarrowType(falseType2, narrowMapper, mapper);
|
|
57519
|
-
break;
|
|
57520
|
-
}
|
|
57521
|
-
if (inferredExtendsType.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) {
|
|
57522
|
-
const trueType2 = getTypeFromTypeNode(root.node.trueType);
|
|
57523
|
-
const trueMapper = combinedMapper || mapper;
|
|
57524
|
-
if (canTailRecurse(trueType2, trueMapper)) {
|
|
57525
|
-
continue;
|
|
57526
|
-
}
|
|
57527
|
-
result = instantiateNarrowType(trueType2, narrowMapper, trueMapper);
|
|
57528
|
-
break;
|
|
57529
|
-
}
|
|
57530
|
-
}
|
|
57531
|
-
result = createType(16777216 /* Conditional */);
|
|
57532
|
-
result.root = root;
|
|
57533
|
-
result.checkType = instantiateType(root.checkType, mapper);
|
|
57534
|
-
result.extendsType = instantiateType(root.extendsType, mapper);
|
|
57535
|
-
result.mapper = mapper;
|
|
57536
|
-
result.combinedMapper = combinedMapper;
|
|
57537
|
-
result.aliasSymbol = aliasSymbol || root.aliasSymbol;
|
|
57538
|
-
result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(root.aliasTypeArguments, mapper);
|
|
57539
|
-
break;
|
|
57540
|
-
}
|
|
57541
|
-
return extraTypes ? getIntersectionType(append(extraTypes, result)) : result;
|
|
57542
|
-
function canTailRecurse(newType, newMapper) {
|
|
57543
|
-
if (newType.flags & 16777216 /* Conditional */ && newMapper) {
|
|
57544
|
-
const newRoot = newType.root;
|
|
57545
|
-
if (newRoot.outerTypeParameters) {
|
|
57546
|
-
const typeParamMapper = combineTypeMappers(newType.mapper, newMapper);
|
|
57547
|
-
const typeArguments = map(newRoot.outerTypeParameters, (t) => getMappedType(t, typeParamMapper));
|
|
57548
|
-
const newRootMapper = createTypeMapper(newRoot.outerTypeParameters, typeArguments);
|
|
57549
|
-
const newCheckType = newRoot.isDistributive ? getMappedType(newRoot.checkType, newRootMapper) : void 0;
|
|
57550
|
-
if (!newCheckType || newCheckType === newRoot.checkType || !(newCheckType.flags & (1048576 /* Union */ | 131072 /* Never */))) {
|
|
57551
|
-
root = newRoot;
|
|
57552
|
-
mapper = newRootMapper;
|
|
57553
|
-
aliasSymbol = void 0;
|
|
57554
|
-
aliasTypeArguments = void 0;
|
|
57555
|
-
if (newRoot.aliasSymbol) {
|
|
57556
|
-
tailCount++;
|
|
57557
|
-
}
|
|
57558
|
-
return true;
|
|
57559
|
-
}
|
|
57560
|
-
}
|
|
57561
|
-
}
|
|
57562
|
-
return false;
|
|
57563
|
-
}
|
|
57564
|
-
}
|
|
57565
57451
|
function getTypeFromInferTypeNode(node) {
|
|
57566
57452
|
const links = getNodeLinks(node);
|
|
57567
57453
|
if (!links.resolvedType) {
|
|
@@ -58510,93 +58396,6 @@ function createTypeChecker(host) {
|
|
|
58510
58396
|
}
|
|
58511
58397
|
return type;
|
|
58512
58398
|
}
|
|
58513
|
-
function instantiateNarrowType(type, narrowMapper, mapper, noTopLevel = false) {
|
|
58514
|
-
return type ? instantiateNarrowTypeWithAlias(
|
|
58515
|
-
type,
|
|
58516
|
-
narrowMapper,
|
|
58517
|
-
mapper,
|
|
58518
|
-
/*aliasSymbol*/
|
|
58519
|
-
void 0,
|
|
58520
|
-
/*aliasTypeArguments*/
|
|
58521
|
-
void 0,
|
|
58522
|
-
noTopLevel
|
|
58523
|
-
) : type;
|
|
58524
|
-
}
|
|
58525
|
-
function instantiateNarrowTypeWithAlias(type, narrowMapper, mapper, aliasSymbol, aliasTypeArguments, noTopLevel) {
|
|
58526
|
-
var _a;
|
|
58527
|
-
if (!couldContainTypeVariables(type)) {
|
|
58528
|
-
return type;
|
|
58529
|
-
}
|
|
58530
|
-
if (instantiationDepth === 100 || instantiationCount >= 5e6) {
|
|
58531
|
-
(_a = tracing) == null ? void 0 : _a.instant(tracing.Phase.CheckTypes, "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth, instantiationCount });
|
|
58532
|
-
error(currentNode, Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
|
|
58533
|
-
return errorType;
|
|
58534
|
-
}
|
|
58535
|
-
totalInstantiationCount++;
|
|
58536
|
-
instantiationCount++;
|
|
58537
|
-
instantiationDepth++;
|
|
58538
|
-
const result = instantiateNarrowTypeWorker(type, narrowMapper, mapper, aliasSymbol, aliasTypeArguments, noTopLevel);
|
|
58539
|
-
instantiationDepth--;
|
|
58540
|
-
return result;
|
|
58541
|
-
}
|
|
58542
|
-
function instantiateNarrowTypeWorker(type, narrowMapper, mapper, aliasSymbol, aliasTypeArguments, noTopLevel) {
|
|
58543
|
-
const flags = type.flags;
|
|
58544
|
-
if (flags & 262144 /* TypeParameter */) {
|
|
58545
|
-
if (noTopLevel) {
|
|
58546
|
-
return type;
|
|
58547
|
-
}
|
|
58548
|
-
return getMappedType(type, combineTypeMappers(mapper, narrowMapper));
|
|
58549
|
-
}
|
|
58550
|
-
if (flags & 8388608 /* IndexedAccess */) {
|
|
58551
|
-
const newAliasSymbol = aliasSymbol || type.aliasSymbol;
|
|
58552
|
-
const newAliasTypeArguments = aliasSymbol || !mapper ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper);
|
|
58553
|
-
const objectType = instantiateType(type.objectType, mapper);
|
|
58554
|
-
let indexType = instantiateType(type.indexType, mapper);
|
|
58555
|
-
if (indexType.flags & 262144 /* TypeParameter */) {
|
|
58556
|
-
indexType = getMappedType(indexType, narrowMapper);
|
|
58557
|
-
}
|
|
58558
|
-
return getIndexedAccessType(
|
|
58559
|
-
objectType,
|
|
58560
|
-
indexType,
|
|
58561
|
-
type.accessFlags | 4 /* Writing */,
|
|
58562
|
-
// Get the writing type
|
|
58563
|
-
/*accessNode*/
|
|
58564
|
-
void 0,
|
|
58565
|
-
newAliasSymbol,
|
|
58566
|
-
newAliasTypeArguments
|
|
58567
|
-
);
|
|
58568
|
-
}
|
|
58569
|
-
if (flags & 16777216 /* Conditional */) {
|
|
58570
|
-
return getNarrowConditionalTypeInstantiation(
|
|
58571
|
-
type,
|
|
58572
|
-
narrowMapper,
|
|
58573
|
-
mapper ? combineTypeMappers(type.mapper, mapper) : type.mapper,
|
|
58574
|
-
aliasSymbol,
|
|
58575
|
-
aliasTypeArguments
|
|
58576
|
-
);
|
|
58577
|
-
}
|
|
58578
|
-
return type;
|
|
58579
|
-
}
|
|
58580
|
-
function getNarrowConditionalTypeInstantiation(type, narrowMapper, mapper, aliasSymbol, aliasTypeArguments) {
|
|
58581
|
-
const root = type.root;
|
|
58582
|
-
if (root.outerTypeParameters) {
|
|
58583
|
-
const typeArguments = mapper ? map(root.outerTypeParameters, (t) => getMappedType(t, mapper)) : root.outerTypeParameters;
|
|
58584
|
-
let result;
|
|
58585
|
-
const newMapper = createTypeMapper(root.outerTypeParameters, typeArguments);
|
|
58586
|
-
const checkType = root.checkType;
|
|
58587
|
-
const distributionType = root.isDistributive ? getMappedType(checkType, combineTypeMappers(newMapper, narrowMapper)) : void 0;
|
|
58588
|
-
if (distributionType && checkType !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */)) {
|
|
58589
|
-
result = mapTypeWithAlias(getReducedType(distributionType), (t) => getNarrowConditionalType(root, narrowMapper, prependTypeMapping(checkType, t, newMapper)), aliasSymbol, aliasTypeArguments);
|
|
58590
|
-
if (result.flags & 1048576 /* Union */) {
|
|
58591
|
-
result = getIntersectionType(result.types, aliasSymbol, aliasTypeArguments);
|
|
58592
|
-
}
|
|
58593
|
-
} else {
|
|
58594
|
-
result = getNarrowConditionalType(root, narrowMapper, newMapper, aliasSymbol, aliasTypeArguments);
|
|
58595
|
-
}
|
|
58596
|
-
return result;
|
|
58597
|
-
}
|
|
58598
|
-
return type;
|
|
58599
|
-
}
|
|
58600
58399
|
function instantiateReverseMappedType(type, mapper) {
|
|
58601
58400
|
const innerMappedType = instantiateType(type.mappedType, mapper);
|
|
58602
58401
|
if (!(getObjectFlags(innerMappedType) & 32 /* Mapped */)) {
|
|
@@ -66038,7 +65837,7 @@ function createTypeChecker(host) {
|
|
|
66038
65837
|
return contextualType && !isGenericType(contextualType);
|
|
66039
65838
|
}
|
|
66040
65839
|
function getNarrowableTypeForReference(type, reference, checkMode) {
|
|
66041
|
-
const substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) && someType(type, isGenericTypeWithUnionConstraint) && (
|
|
65840
|
+
const substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) && someType(type, isGenericTypeWithUnionConstraint) && (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
|
|
66042
65841
|
return substituteConstraints ? mapType(type, getBaseConstraintOrType) : type;
|
|
66043
65842
|
}
|
|
66044
65843
|
function isExportOrExportExpression(location) {
|
|
@@ -66677,6 +66476,25 @@ function createTypeChecker(host) {
|
|
|
66677
66476
|
return t.flags & 2097152 /* Intersection */ ? forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t);
|
|
66678
66477
|
});
|
|
66679
66478
|
}
|
|
66479
|
+
function getThisTypeOfObjectLiteralFromContextualType(containingLiteral, contextualType) {
|
|
66480
|
+
let literal = containingLiteral;
|
|
66481
|
+
let type = contextualType;
|
|
66482
|
+
while (type) {
|
|
66483
|
+
const thisType = getThisTypeFromContextualType(type);
|
|
66484
|
+
if (thisType) {
|
|
66485
|
+
return thisType;
|
|
66486
|
+
}
|
|
66487
|
+
if (literal.parent.kind !== 302 /* PropertyAssignment */) {
|
|
66488
|
+
break;
|
|
66489
|
+
}
|
|
66490
|
+
literal = literal.parent.parent;
|
|
66491
|
+
type = getApparentTypeOfContextualType(
|
|
66492
|
+
literal,
|
|
66493
|
+
/*contextFlags*/
|
|
66494
|
+
void 0
|
|
66495
|
+
);
|
|
66496
|
+
}
|
|
66497
|
+
}
|
|
66680
66498
|
function getContextualThisParameterType(func) {
|
|
66681
66499
|
if (func.kind === 218 /* ArrowFunction */) {
|
|
66682
66500
|
return void 0;
|
|
@@ -66699,22 +66517,9 @@ function createTypeChecker(host) {
|
|
|
66699
66517
|
/*contextFlags*/
|
|
66700
66518
|
void 0
|
|
66701
66519
|
);
|
|
66702
|
-
|
|
66703
|
-
|
|
66704
|
-
|
|
66705
|
-
const thisType = getThisTypeFromContextualType(type);
|
|
66706
|
-
if (thisType) {
|
|
66707
|
-
return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral)));
|
|
66708
|
-
}
|
|
66709
|
-
if (literal.parent.kind !== 302 /* PropertyAssignment */) {
|
|
66710
|
-
break;
|
|
66711
|
-
}
|
|
66712
|
-
literal = literal.parent.parent;
|
|
66713
|
-
type = getApparentTypeOfContextualType(
|
|
66714
|
-
literal,
|
|
66715
|
-
/*contextFlags*/
|
|
66716
|
-
void 0
|
|
66717
|
-
);
|
|
66520
|
+
const thisType = getThisTypeOfObjectLiteralFromContextualType(containingLiteral, contextualType);
|
|
66521
|
+
if (thisType) {
|
|
66522
|
+
return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral)));
|
|
66718
66523
|
}
|
|
66719
66524
|
return getWidenedType(contextualType ? getNonNullableType(contextualType) : checkExpressionCached(containingLiteral));
|
|
66720
66525
|
}
|
|
@@ -66830,16 +66635,9 @@ function createTypeChecker(host) {
|
|
|
66830
66635
|
function getContextualTypeForReturnExpression(node, contextFlags) {
|
|
66831
66636
|
const func = getContainingFunction(node);
|
|
66832
66637
|
if (func) {
|
|
66833
|
-
const functionFlags = getFunctionFlags(func);
|
|
66834
|
-
const links = getNodeLinks(node);
|
|
66835
|
-
if (links.contextualReturnType) {
|
|
66836
|
-
if (functionFlags & 2 /* Async */) {
|
|
66837
|
-
return getUnionType([links.contextualReturnType, createPromiseLikeType(links.contextualReturnType)]);
|
|
66838
|
-
}
|
|
66839
|
-
return links.contextualReturnType;
|
|
66840
|
-
}
|
|
66841
66638
|
let contextualReturnType = getContextualReturnType(func, contextFlags);
|
|
66842
66639
|
if (contextualReturnType) {
|
|
66640
|
+
const functionFlags = getFunctionFlags(func);
|
|
66843
66641
|
if (functionFlags & 1 /* Generator */) {
|
|
66844
66642
|
const isAsyncGenerator = (functionFlags & 2 /* Async */) !== 0;
|
|
66845
66643
|
if (contextualReturnType.flags & 1048576 /* Union */) {
|
|
@@ -66852,7 +66650,7 @@ function createTypeChecker(host) {
|
|
|
66852
66650
|
contextualReturnType = iterationReturnType;
|
|
66853
66651
|
}
|
|
66854
66652
|
if (functionFlags & 2 /* Async */) {
|
|
66855
|
-
const contextualAwaitedType =
|
|
66653
|
+
const contextualAwaitedType = mapType(contextualReturnType, getAwaitedTypeNoAlias);
|
|
66856
66654
|
return contextualAwaitedType && getUnionType([contextualAwaitedType, createPromiseLikeType(contextualAwaitedType)]);
|
|
66857
66655
|
}
|
|
66858
66656
|
return contextualReturnType;
|
|
@@ -77946,55 +77744,17 @@ function createTypeChecker(host) {
|
|
|
77946
77744
|
const returnType = getReturnTypeOfSignature(signature);
|
|
77947
77745
|
const functionFlags = getFunctionFlags(container);
|
|
77948
77746
|
if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) {
|
|
77747
|
+
const exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType;
|
|
77949
77748
|
if (container.kind === 177 /* SetAccessor */) {
|
|
77950
77749
|
if (node.expression) {
|
|
77951
77750
|
error(node, Diagnostics.Setters_cannot_return_a_value);
|
|
77952
77751
|
}
|
|
77953
77752
|
} else if (container.kind === 175 /* Constructor */) {
|
|
77954
|
-
const exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType;
|
|
77955
77753
|
if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) {
|
|
77956
77754
|
error(node, Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class);
|
|
77957
77755
|
}
|
|
77958
77756
|
} else if (getReturnTypeFromAnnotation(container)) {
|
|
77959
77757
|
const unwrappedReturnType = unwrapReturnType(returnType, functionFlags) ?? returnType;
|
|
77960
|
-
let actualReturnType = unwrappedReturnType;
|
|
77961
|
-
const links = node.expression && getNodeLinks(node.expression);
|
|
77962
|
-
if (links && !links.contextualReturnType) {
|
|
77963
|
-
const outerTypeParameters = getOuterTypeParameters(
|
|
77964
|
-
container,
|
|
77965
|
-
/*includeThisTypes*/
|
|
77966
|
-
false
|
|
77967
|
-
);
|
|
77968
|
-
const typeParameters = appendTypeParameters(outerTypeParameters, getEffectiveTypeParameterDeclarations(container));
|
|
77969
|
-
const queryTypeParameters = typeParameters == null ? void 0 : typeParameters.filter(isQueryTypeParameter);
|
|
77970
|
-
if (queryTypeParameters) {
|
|
77971
|
-
const narrowMapper = createTypeMapper(queryTypeParameters, queryTypeParameters.map((tp) => {
|
|
77972
|
-
const originalName = tp.exprName;
|
|
77973
|
-
const fakeName = factory.cloneNode(originalName);
|
|
77974
|
-
setParent(fakeName, node.parent);
|
|
77975
|
-
setNodeFlags(fakeName, fakeName.flags | 8 /* Synthesized */);
|
|
77976
|
-
fakeName.flowNode = node.flowNode;
|
|
77977
|
-
const exprType2 = checkExpression(fakeName);
|
|
77978
|
-
if (getConstraintOfTypeParameter(tp)) {
|
|
77979
|
-
const narrowableConstraintType = mapType(tp.constraint, getBaseConstraintOrType);
|
|
77980
|
-
if (narrowableConstraintType === exprType2) {
|
|
77981
|
-
return tp;
|
|
77982
|
-
}
|
|
77983
|
-
}
|
|
77984
|
-
return exprType2;
|
|
77985
|
-
}));
|
|
77986
|
-
actualReturnType = instantiateNarrowType(
|
|
77987
|
-
unwrappedReturnType,
|
|
77988
|
-
narrowMapper,
|
|
77989
|
-
/*mapper*/
|
|
77990
|
-
void 0,
|
|
77991
|
-
/*noTopLevel*/
|
|
77992
|
-
true
|
|
77993
|
-
);
|
|
77994
|
-
}
|
|
77995
|
-
links.contextualReturnType = actualReturnType;
|
|
77996
|
-
}
|
|
77997
|
-
const exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType;
|
|
77998
77758
|
const unwrappedExprType = functionFlags & 2 /* Async */ ? checkAwaitedType(
|
|
77999
77759
|
exprType,
|
|
78000
77760
|
/*withAlias*/
|
|
@@ -78002,57 +77762,14 @@ function createTypeChecker(host) {
|
|
|
78002
77762
|
node,
|
|
78003
77763
|
Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member
|
|
78004
77764
|
) : exprType;
|
|
78005
|
-
if (
|
|
78006
|
-
checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType,
|
|
77765
|
+
if (unwrappedReturnType) {
|
|
77766
|
+
checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, node, node.expression);
|
|
78007
77767
|
}
|
|
78008
77768
|
}
|
|
78009
77769
|
} else if (container.kind !== 175 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeUndefinedVoidOrAny(container, returnType)) {
|
|
78010
77770
|
error(node, Diagnostics.Not_all_code_paths_return_a_value);
|
|
78011
77771
|
}
|
|
78012
77772
|
}
|
|
78013
|
-
function isQueryTypeParameter(typeParameter) {
|
|
78014
|
-
if (typeParameter.exprName) {
|
|
78015
|
-
return true;
|
|
78016
|
-
}
|
|
78017
|
-
if (isThisTypeParameter(typeParameter)) {
|
|
78018
|
-
return false;
|
|
78019
|
-
}
|
|
78020
|
-
if (!typeParameter.symbol) {
|
|
78021
|
-
return false;
|
|
78022
|
-
}
|
|
78023
|
-
const declaration = getDeclarationOfKind(typeParameter.symbol, 167 /* TypeParameter */);
|
|
78024
|
-
const owner = getTypeParameterOwner(declaration);
|
|
78025
|
-
if (!owner || !isFunctionLikeDeclaration(owner)) {
|
|
78026
|
-
return false;
|
|
78027
|
-
}
|
|
78028
|
-
const references = [];
|
|
78029
|
-
owner.parameters.forEach((parameter) => forEachChild(parameter, collectReferences));
|
|
78030
|
-
if (references.length === 1) {
|
|
78031
|
-
const reference = references[0];
|
|
78032
|
-
let exprName;
|
|
78033
|
-
if (isParameter(reference.parent) && reference.parent.parent === owner && (exprName = getNameOfDeclaration(reference.parent))) {
|
|
78034
|
-
typeParameter.exprName = exprName;
|
|
78035
|
-
return true;
|
|
78036
|
-
}
|
|
78037
|
-
}
|
|
78038
|
-
return false;
|
|
78039
|
-
function collectReferences(node) {
|
|
78040
|
-
if (isFunctionLikeDeclaration(node.parent) && node === node.parent.body) {
|
|
78041
|
-
return;
|
|
78042
|
-
}
|
|
78043
|
-
if (isNodeDescendantOf(node, owner.type)) {
|
|
78044
|
-
return;
|
|
78045
|
-
}
|
|
78046
|
-
if (isTypeReferenceNode(node)) {
|
|
78047
|
-
const type = getTypeFromTypeNode(node);
|
|
78048
|
-
if (type.flags & 262144 /* TypeParameter */ && isTypeIdenticalTo(type, typeParameter)) {
|
|
78049
|
-
references.push(node);
|
|
78050
|
-
}
|
|
78051
|
-
return;
|
|
78052
|
-
}
|
|
78053
|
-
forEachChild(node, collectReferences);
|
|
78054
|
-
}
|
|
78055
|
-
}
|
|
78056
77773
|
function checkWithStatement(node) {
|
|
78057
77774
|
if (!checkGrammarStatementInAmbientContext(node)) {
|
|
78058
77775
|
if (node.flags & 32768 /* AwaitContext */) {
|
|
@@ -80568,7 +80285,7 @@ function createTypeChecker(host) {
|
|
|
80568
80285
|
/*contextFlags*/
|
|
80569
80286
|
void 0
|
|
80570
80287
|
);
|
|
80571
|
-
const type =
|
|
80288
|
+
const type = getThisTypeOfObjectLiteralFromContextualType(containingLiteral, contextualType);
|
|
80572
80289
|
return type && !isTypeAny(type);
|
|
80573
80290
|
}
|
|
80574
80291
|
}
|