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
Optional destructured parameters do not work with default values #17080
Here's another example of this that I wrote up before searching for an existing issue:
interfaceFoo{readonlybar?: number;}functionperformFoo({ bar }: Foo={}){useBar(bar);// `bar` should have type `number | undefined`, so this shouldn't compile.}functionuseBar(bar: number){alert('The number is: '+bar);}performFoo();
We've started using this pattern in our code, so I'm also interested in a fix for this.
If someone takes up fixing this, here is another potentially useful test case:
interfaceFoo{readonlybar?: number;}functionperformFoo({ bar =null}: Foo={}){useBar(bar);// `bar` should have type `number | null`, so this call shouldn't compile.}functionuseBar(bar: number|undefined){alert('The number is: '+bar);}performFoo();
I fixed the issue in PR #21328
Update: Added testcases, signed CLA
Update2: Issue #17667 is not (totally) fixed by this. Only the part with the optionality (inclusion of undefined).
Activity
mhegazy commentedon Aug 28, 2017
Nathan Shively-Sanders (@sandersn) we talked about this one before, any thoughts here?
whatisaphone commentedon Sep 29, 2017
Here's another example of this that I wrote up before searching for an existing issue:
We've started using this pattern in our code, so I'm also interested in a fix for this.
whatisaphone commentedon Oct 3, 2017
If someone takes up fixing this, here is another potentially useful test case:
Fixes microsoft#17080
Lazarus535 commentedon Jan 22, 2018
I fixed the issue in PR #21328
Update: Added testcases, signed CLA
Update2: Issue #17667 is not (totally) fixed by this. Only the part with the optionality (inclusion of undefined).
Fixes microsoft#17080
Fixes microsoft#17080
Fixes microsoft#17080
Merge pull request #21328 from Lazarus535/master