mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Contextual typing checks property assignments for type annotation (#43598)
Property assignments can have a type annotation in JS. This PR adds a check for it in contextual typing. Fixes #43379
This commit is contained in:
committed by
GitHub
parent
b9c1e98544
commit
d5af89c552
@@ -25218,6 +25218,10 @@ namespace ts {
|
||||
|
||||
function getContextualTypeForObjectLiteralElement(element: ObjectLiteralElementLike, contextFlags?: ContextFlags) {
|
||||
const objectLiteral = <ObjectLiteralExpression>element.parent;
|
||||
const propertyAssignmentType = isPropertyAssignment(element) && getContextualTypeForVariableLikeDeclaration(element);
|
||||
if (propertyAssignmentType) {
|
||||
return propertyAssignmentType;
|
||||
}
|
||||
const type = getApparentTypeOfContextualType(objectLiteral, contextFlags);
|
||||
if (type) {
|
||||
if (hasBindableName(element)) {
|
||||
|
||||
Reference in New Issue
Block a user