- Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issueSpecIssues related to the TypeScript language specificationIssues related to the TypeScript language specification
Milestone
Description
function foo({ x, y = {}} = { x: 0, y: {}}) { } foo(); // Fine foo({ x: 0, y: 0 }); // Fine foo({ x: 0 }); // Error
The last line should not be an error because the y property has a default initializer. The error goes away if I remove the default initializer { x: 0, y: {}}
on the parent.
I think the rule would be that even if we get the type of a parameter / variable / binding element from an initializer, we still have to traverse the binding pattern to determine whether binding properties are optional.
wildeyes
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issueSpecIssues related to the TypeScript language specificationIssues related to the TypeScript language specification