Refactor: Introduce object destruction
See original GitHub issueSearch Terms
refactor, object destruction
Suggestion
A refactor that extract all property access expression to a object destruction or convert back
Use Cases
Examples
const item = {
a: 1, b: 2
}
call(item.a, item.b)
to
const item = {
a: 1, b: 2
}
const { a, b } = item
call(a, b)
Checklist
My suggestion meets these guidelines:
- This wouldn’t be a breaking change in existing TypeScript/JavaScript code
- This wouldn’t change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn’t a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
- This feature would agree with the rest of TypeScript’s Design Goals.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:9 (8 by maintainers)
Top Results From Across the Web
How to refactor method of class with a lot of arguments?
Create an object to hold those 20 arguments and pass that object to the method. For example: public void MyMethod(MyArguments args) { //...
Read more >31 Days of Refactoring - · Los Techies
This entails passing a reference to the class that will be returning the computation to a new object that has the multiple methods...
Read more >Refactoring optional chaining into a large codebase - Lea Verou
When looking to use the optional chaining operator within Firefox DevTools, one thing we had to consider is how it affects project-wide search ......
Read more >Terraform 1.3 Release Introduces Simplified Refactoring ...
The moved block was introduced in version 1.1 to provide a ... Moving or renaming an object informs Terraform to destroy the object...
Read more >Refactoring Teddy Bear Destruction - Event Handling and Menus ...
Video created by Sistema de Universidades do ColoradoUniversidade do Colorado for the course "Intermediate Object-Oriented Programming for Unreal Games".
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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.
I start working on this one :XD