mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-24 11:43:18 -05:00
Use binding pattern for type inference result {}
The binding pattern provides additional information when the contextual
type is not found and would otherwise fix a type parameter to `{}`.
This commit is contained in:
@@ -11455,6 +11455,12 @@ namespace ts {
|
||||
const links = getSymbolLinks(parameter);
|
||||
if (!links.type) {
|
||||
links.type = instantiateType(contextualType, mapper);
|
||||
// if inference didn't come up with anything but {}, fall back to the binding pattern if present.
|
||||
if (links.type === emptyObjectType &&
|
||||
(parameter.valueDeclaration.name.kind === SyntaxKind.ObjectBindingPattern ||
|
||||
parameter.valueDeclaration.name.kind === SyntaxKind.ArrayBindingPattern)) {
|
||||
links.type = getTypeFromBindingPattern(<BindingPattern>parameter.valueDeclaration.name);
|
||||
}
|
||||
assignBindingElementTypes(<ParameterDeclaration>parameter.valueDeclaration);
|
||||
}
|
||||
else if (isInferentialContext(mapper)) {
|
||||
|
||||
Reference in New Issue
Block a user