@@ -8971,9 +8971,8 @@ namespace ts {
8971
8971
return undefined;
8972
8972
}
8973
8973
8974
- function getConstraintDeclaration(type: TypeParameter) {
8975
- const decl = type.symbol && getDeclarationOfKind<TypeParameterDeclaration>(type.symbol, SyntaxKind.TypeParameter);
8976
- return decl && getEffectiveConstraintOfTypeParameter(decl);
8974
+ function getConstraintDeclaration(type: TypeParameter): TypeNode | undefined {
8975
+ return mapDefined(filter(type.symbol && type.symbol.declarations, isTypeParameterDeclaration), getEffectiveConstraintOfTypeParameter)[0];
8977
8976
}
8978
8977
8979
8978
function getInferredTypeParameterConstraint(typeParameter: TypeParameter) {
@@ -15154,9 +15153,9 @@ namespace ts {
15154
15153
* Return true if type was inferred from an object literal, written as an object type literal, or is the shape of a module
15155
15154
* with no call or construct signatures.
15156
15155
*/
15157
- function isObjectTypeWithInferableIndex(type: Type) {
15158
- return type.symbol && (type.symbol.flags & (SymbolFlags.ObjectLiteral | SymbolFlags.TypeLiteral | SymbolFlags.Enum | SymbolFlags.ValueModule)) !== 0 &&
15159
- !typeHasCallOrConstructSignatures(type);
15156
+ function isObjectTypeWithInferableIndex(type: Type): boolean {
15157
+ return !!( type.symbol && (type.symbol.flags & (SymbolFlags.ObjectLiteral | SymbolFlags.TypeLiteral | SymbolFlags.Enum | SymbolFlags.ValueModule)) !== 0 &&
15158
+ !typeHasCallOrConstructSignatures(type)) || !!(getObjectFlags(type) & ObjectFlags.ReverseMapped && isObjectTypeWithInferableIndex((type as ReverseMappedType).source)) ;
15160
15159
}
15161
15160
15162
15161
function createSymbolWithType(source: Symbol, type: Type | undefined) {
@@ -15558,6 +15557,13 @@ namespace ts {
15558
15557
};
15559
15558
}
15560
15559
15560
+ function cloneInferredPartOfContext(context: InferenceContext): InferenceContext | undefined {
15561
+ const inferences = filter(context.inferences, hasInferenceCandidates);
15562
+ return inferences.length ?
15563
+ createInferenceContextWorker(map(inferences, cloneInferenceInfo), context.signature, context.flags, context.compareTypes) :
15564
+ undefined;
15565
+ }
15566
+
15561
15567
function getMapperFromContext<T extends InferenceContext | undefined>(context: T): TypeMapper | T & undefined {
15562
15568
return context && context.mapper;
15563
15569
}
@@ -17603,7 +17609,7 @@ namespace ts {
17603
17609
assumeTrue = !assumeTrue;
17604
17610
}
17605
17611
const valueType = getTypeOfExpression(value);
17606
- if ((type.flags & TypeFlags.Unknown) && (operator === SyntaxKind.EqualsEqualsEqualsToken) && assumeTrue ) {
17612
+ if ((type.flags & TypeFlags.Unknown) && assumeTrue && (operator === SyntaxKind.EqualsEqualsEqualsToken || operator === SyntaxKind.ExclamationEqualsEqualsToken) ) {
17607
17613
if (valueType.flags & (TypeFlags.Primitive | TypeFlags.NonPrimitive)) {
17608
17614
return valueType;
17609
17615
}
@@ -21615,7 +21621,7 @@ namespace ts {
21615
21621
const returnContext = createInferenceContext(signature.typeParameters!, signature, context.flags);
21616
21622
const returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper);
21617
21623
inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType);
21618
- context.returnMapper = some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(returnContext) : undefined;
21624
+ context.returnMapper = some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(cloneInferredPartOfContext( returnContext) ) : undefined;
21619
21625
}
21620
21626
}
21621
21627
@@ -25855,7 +25861,7 @@ namespace ts {
25855
25861
for (const member of node.members) {
25856
25862
if (member.kind === SyntaxKind.Constructor) {
25857
25863
for (const param of (member as ConstructorDeclaration).parameters) {
25858
- if (isParameterPropertyDeclaration(param) && !isBindingPattern(param.name)) {
25864
+ if (isParameterPropertyDeclaration(param, member ) && !isBindingPattern(param.name)) {
25859
25865
addName(instanceNames, param.name, param.name.escapedText, DeclarationMeaning.GetOrSetAccessor);
25860
25866
}
25861
25867
}
@@ -27619,7 +27625,7 @@ namespace ts {
27619
27625
const parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration);
27620
27626
const name = local.valueDeclaration && getNameOfDeclaration(local.valueDeclaration);
27621
27627
if (parameter && name) {
27622
- if (!isParameterPropertyDeclaration(parameter) && !parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) {
27628
+ if (!isParameterPropertyDeclaration(parameter, parameter.parent ) && !parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) {
27623
27629
addDiagnostic(parameter, UnusedKind.Parameter, createDiagnosticForNode(name, Diagnostics._0_is_declared_but_its_value_is_never_read, symbolName(local)));
27624
27630
}
27625
27631
}
@@ -28890,11 +28896,13 @@ namespace ts {
28890
28896
let nextType: Type | undefined;
28891
28897
if (methodName !== "throw") {
28892
28898
const methodParameterType = methodParameterTypes ? getUnionType(methodParameterTypes) : unknownType;
28893
- const resolvedMethodParameterType = resolver.resolveIterationType(methodParameterType, errorNode) || anyType;
28894
28899
if (methodName === "next") {
28895
- nextType = resolvedMethodParameterType;
28900
+ // The value of `next(value)` is *not* awaited by async generators
28901
+ nextType = methodParameterType;
28896
28902
}
28897
28903
else if (methodName === "return") {
28904
+ // The value of `return(value)` *is* awaited by async generators
28905
+ const resolvedMethodParameterType = resolver.resolveIterationType(methodParameterType, errorNode) || anyType;
28898
28906
returnTypes = append(returnTypes, resolvedMethodParameterType);
28899
28907
}
28900
28908
}
@@ -29383,11 +29391,10 @@ namespace ts {
29383
29391
const constraint = getEffectiveConstraintOfTypeParameter(source);
29384
29392
const sourceConstraint = constraint && getTypeFromTypeNode(constraint);
29385
29393
const targetConstraint = getConstraintOfTypeParameter(target);
29386
- if (sourceConstraint) {
29387
- // relax check if later interface augmentation has no constraint
29388
- if (!targetConstraint || !isTypeIdenticalTo(sourceConstraint, targetConstraint)) {
29389
- return false;
29390
- }
29394
+ // relax check if later interface augmentation has no constraint, it's more broad and is OK to merge with
29395
+ // a more constrained interface (this could be generalized to a full heirarchy check, but that's maybe overkill)
29396
+ if (sourceConstraint && targetConstraint && !isTypeIdenticalTo(sourceConstraint, targetConstraint)) {
29397
+ return false;
29391
29398
}
29392
29399
29393
29400
// If the type parameter node has a default and it is not identical to the default
0 commit comments