_From @jrieken on March 27, 2018 12:43_
re #46589
Organize import should rewrite imports with lots destructuring to the named variant, e.g
import {
TaskDefinitionDTO, TaskExecutionDTO, TaskPresentationOptionsDTO, ProcessExecutionOptionsDTO, ProcessExecutionDTO,
ShellExecutionOptionsDTO, ShellExecutionDTO, TaskDTO, TaskHandleDTO
} from '../shared/tasks';
should become
import * as [tasks] from '../shared/tasks';
_Copied from original issue: Microsoft/vscode#46682_
Moved upstream for more feedback. Again, we could consider adding this as an option but I would not want it enabled it by default. It may be a better fit for a refactoring actually
@jrieken what is the intended meaning of the illegal syntax [tasks] ?
It's also not clear this always improves your file. For example, if you had some code somewhere:
return { ShellExecutionDTO, TaskDTO, TaskHandleDTO };
we'd have to un-shortcut the object literal:
return { ShellExecutionDTO: tasks.ShellExecutionDTO, TaskDTO: tasks.TasksDTO, TaskHandleDTO: tasks.TaskHandleDTO };
I'd very much be on board with an explicit command to un-destructure the import, but I can't imagine doing it automatically wouldn't raise some complaints.
Maybe a "Group destructured import to local 'tasks'" fix appears when you have 4 or more destructurings in an import?
@jrieken what is the intended meaning of the illegal syntax [tasks]
Well, it's a placeholder because TypeScript is unlikely to pick a name I like. It's similar to extract variable which is always followed by a rename.
It's also not clear this always improves your file. For example, if you had some code somewhere:
Understood, but a corner case if you ask me.
Related to #19260 or potentially a duplicate of #19260.
Closing this due to lack for much user feedback over the past two years.
As noted, TS already has refactorings to convert between the two styles of imports. Changing styles automatically sounds more like something a linter should handle
Most helpful comment
Maybe a "
Group destructured import to local 'tasks'" fix appears when you have 4 or more destructurings in an import?