From https://github.com/microsoft/vscode/issues/76583
TypeScript Version: [email protected]
Search Terms:
Code
function f({x}, y) { return y; }
Trigger quick fixes on {x}
Bug:
A quick fix which removes the destructing is returned, but there is no quick fix to convert the first paramter to a _. Replacing a parameter with _ is available for normal parameters:
function f(x, y) { return y; }
@mjbvz seems like the OP is a complaint that we broke their code by observably changing the function parameter ordering
Changing { x } to _ has observable runtime effects (calling with null no longer throws, for example). We should change it to { } and leave it alone after that; I don't see any benefit to changing it to _ - it just creates new scope pollution
Perhaps related: #32196
function f({ x }, y) { return y; }
For the first parameter should be two quick-fix options
@RyanCavanaugh Is it true?
What about the following case?
function f({ x, x1, x2 }, y) { return y; }
I think it should swap from singular to all available to remove:
to
and the remove destructuring should stick around
Most helpful comment
@mjbvz seems like the OP is a complaint that we broke their code by observably changing the function parameter ordering
Changing
{ x }to_has observable runtime effects (calling withnullno longer throws, for example). We should change it to{ }and leave it alone after that; I don't see any benefit to changing it to_- it just creates new scope pollution