You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bad inference for destructured object parameter with default value #22644
Search Terms: object literal parameter inference destructuring default value
Code
constfn1=(options: {headers?: {}})=>{};// No error as expectedfn1({headers: {foo: 1}});constfn2=({ headers ={}})=>{};// Unexpected error: Property 'foo' does not exist on type '{}'.fn2({headers: {foo: 1}});
This is an issue exposed by #19513. We're not properly widening types in types implied by object destructuring patterns. Looks like a fairly simple fix.
Activity
RyanCavanaugh commentedon Mar 16, 2018
Regression from 2.6 -> 2.7
ahejlsberg commentedon Mar 17, 2018
This is an issue exposed by #19513. We're not properly widening types in types implied by object destructuring patterns. Looks like a fairly simple fix.
OliverJAsh commentedon Mar 18, 2018
Thank you!