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
tsc produces invalid typings for parameter destructuring #3912
If parameter names are optional, this should produce a valid .d.ts file. If parameter names are required, tsc should throw an error, or at least warn me that there is an issue.
Parameter names are required in some form or another. {prop: boolean} is a destructuring parameter (a new ES6 feature) that takes the first argument and assigns its prop property into the boolean variable.
See #2023 for the bug about destructured parameters creating invalid .d.ts files
Hey Ryan. I don't think this is a duplicate of #2023, as I'm not attempting to destructure anything here. Since parameter names are required (thank you for clarifying!), the issue is now that tsc does not throw any errors, and silently produces invalid output.
This was tested using the latest version of tsc, taken from master/bin/tsc. Some sort of error should be produced at compile-time instead of generating invalid output, right?
Activity
RyanCavanaugh commentedon Jul 17, 2015
Parameter names are required in some form or another.
{prop: boolean}is a destructuring parameter (a new ES6 feature) that takes the first argument and assigns itspropproperty into thebooleanvariable.See #2023 for the bug about destructured parameters creating invalid .d.ts files
uber5001 commentedon Jul 17, 2015
Hey Ryan. I don't think this is a duplicate of #2023, as I'm not attempting to destructure anything here. Since parameter names are required (thank you for clarifying!), the issue is now that
tscdoes not throw any errors, and silently produces invalid output.This was tested using the latest version of tsc, taken from master/bin/tsc. Some sort of error should be produced at compile-time instead of generating invalid output, right?
RyanCavanaugh commentedon Jul 17, 2015
You're right. Thanks for following up -- I misread the linked bug.
ahejlsberg commentedon Jul 21, 2015
Sadly, this is not a bug. The ES6 destructuring syntax is eerily similar to the syntax for object types. The following is perfectly valid ES6:
Not entirely clear how we'd make something like that an error.
mhegazy commentedon Jul 21, 2015
Just to clarify, the issue here is that the declaration file generated is not valid. there is an extra ":" emitted after "prop" in:
[-]Can function signatures lack parameter names?[/-][+]tsc produces invalid typings for parameter destructuring[/+]Fix #3912: emit declaration for binding elements correctelly
Fix #3912: emit declaration for binding elements correctelly
Merge pull request #4257 from Microsoft/fix3912