-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Refactor: Introduce object destruction #29917
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This doesn't deserve an example of what it would do? |
Updated |
@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: let u!: { 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 } = u
if(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. |
I‘m very interested in this one if we accept the pr |
any updates on this feature? |
@wimzyLive no |
I start working on this one :XD |
It seems to be a duplicate of #25946 |
@bigaru |
Search Terms
refactor, object destruction
Suggestion
A refactor that extract all property access expression to a object destruction or convert back
Use Cases
Examples
to
Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: