@@ -4082,8 +4082,7 @@ namespace ts {
4082
4082
if (strictNullChecks && declaration.flags & NodeFlags.Ambient && isParameterDeclaration(declaration)) {
4083
4083
parentType = getNonNullableType(parentType);
4084
4084
}
4085
- const propType = getTypeOfPropertyOfType(parentType, text);
4086
- const declaredType = propType && getConstraintForLocation(propType, declaration.name);
4085
+ const declaredType = getConstraintForLocation(getTypeOfPropertyOfType(parentType, text), declaration.name);
4087
4086
type = declaredType && getFlowTypeOfReference(declaration, declaredType) ||
4088
4087
isNumericLiteralName(text) && getIndexTypeOfType(parentType, IndexKind.Number) ||
4089
4088
getIndexTypeOfType(parentType, IndexKind.String);
@@ -12382,7 +12381,7 @@ namespace ts {
12382
12381
12383
12382
function getTypeOfDestructuredProperty(type: Type, name: PropertyName) {
12384
12383
const text = getTextOfPropertyName(name);
12385
- return getTypeOfPropertyOfType(type, text) ||
12384
+ return getConstraintForLocation( getTypeOfPropertyOfType(type, text), name ) ||
12386
12385
isNumericLiteralName(text) && getIndexTypeOfType(type, IndexKind.Number) ||
12387
12386
getIndexTypeOfType(type, IndexKind.String) ||
12388
12387
unknownType;
@@ -13498,7 +13497,7 @@ namespace ts {
13498
13497
// and the type of the node includes type variables with constraints that are nullable, we fetch the
13499
13498
// apparent type of the node *before* performing control flow analysis such that narrowings apply to
13500
13499
// the constraint type.
13501
- if (isConstraintPosition(node) && forEachType(type, typeHasNullableConstraint)) {
13500
+ if (type && isConstraintPosition(node) && forEachType(type, typeHasNullableConstraint)) {
13502
13501
return mapType(getWidenedType(type), getBaseConstraintOrType);
13503
13502
}
13504
13503
return type;
0 commit comments