File tree 1 file changed +8
-1
lines changed
1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -2293,10 +2293,17 @@ namespace ts {
2293
2293
return type && (type.flags & TypeFlags.Any) !== 0;
2294
2294
}
2295
2295
2296
+ // Return the type of a binding element parent. We check SymbolLinks first to see if a type has been
2297
+ // assigned by contextual typing.
2298
+ function getTypeForBindingElementParent(node: VariableLikeDeclaration) {
2299
+ let symbol = getSymbolOfNode(node);
2300
+ return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node);
2301
+ }
2302
+
2296
2303
// Return the inferred type for a binding element
2297
2304
function getTypeForBindingElement(declaration: BindingElement): Type {
2298
2305
let pattern = <BindingPattern>declaration.parent;
2299
- let parentType = getTypeForVariableLikeDeclaration (<VariableLikeDeclaration>pattern.parent);
2306
+ let parentType = getTypeForBindingElementParent (<VariableLikeDeclaration>pattern.parent);
2300
2307
// If parent has the unknown (error) type, then so does this binding element
2301
2308
if (parentType === unknownType) {
2302
2309
return unknownType;
You can’t perform that action at this time.
0 commit comments