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
Wenlu Wang (@Kingwl) While this does sound nice in theory I believe there would issues around unions. Type gurads work differently on union types so not everything that can be done with a union could be done with the distructured constituents. For example:
letu!: {type: 'number';payload: number}|{type: 'string',payload: string}if(u.type==="number"){u.payload.toExponential// payload is number}else{u.payload.big// payload is string}let{ type, payload }=uif(type==="number"){payload.toExponential// error payload is string | number}else{payload.big// error payload is string | number}
This is not a reason not to implement this, but great care should be taken not to offer this refactoring when resulting code would break because of type guards.
Reacted by Wenlu Wang, Ryan Cavanaugh, Anton Lobov and Kuzminov Alexander
Activity
RyanCavanaugh commentedon Feb 15, 2019
This doesn't deserve an example of what it would do?
Kingwl commentedon Feb 18, 2019
Updated
dragomirtitian commentedon Feb 18, 2019
Wenlu Wang (@Kingwl) While this does sound nice in theory I believe there would issues around unions. Type gurads work differently on union types so not everything that can be done with a union could be done with the distructured constituents. For example:
This is not a reason not to implement this, but great care should be taken not to offer this refactoring when resulting code would break because of type guards.
Kingwl commentedon Apr 19, 2019
I‘m very interested in this one if we accept the pr
whimzyLive commentedon Dec 19, 2019
any updates on this feature?
RyanCavanaugh commentedon Dec 20, 2019
@wimzyLive no
Kingwl commentedon Dec 22, 2019
I start working on this one :XD
bigaru commentedon Aug 19, 2020
It seems to be a duplicate of #25946
Kingwl commentedon Aug 19, 2020
Arooran Thanabalasingam (@bigaru)
Indeed. Thanks!