Skip to content

Organise Imports should introduce 'named' import #22925

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

Closed
mjbvz opened this issue Mar 27, 2018 · 6 comments
Closed

Organise Imports should introduce 'named' import #22925

mjbvz opened this issue Mar 27, 2018 · 6 comments
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Domain: Organize Imports Issues with the organize imports feature Domain: Refactorings e.g. extract to constant or function, rename symbol Suggestion An idea for TypeScript Won't Fix The severity and priority of this issue do not warrant the time or complexity needed to fix it

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Mar 27, 2018

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

@mjbvz
Copy link
Contributor Author

mjbvz commented Mar 27, 2018

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

@mjbvz mjbvz removed their assignment Mar 27, 2018
@mhegazy mhegazy added Suggestion An idea for TypeScript Domain: Refactorings e.g. extract to constant or function, rename symbol Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Domain: Organize Imports Issues with the organize imports feature labels Mar 27, 2018
@RyanCavanaugh
Copy link
Member

@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.

@RyanCavanaugh
Copy link
Member

RyanCavanaugh commented Mar 28, 2018

Maybe a "Group destructured import to local 'tasks'" fix appears when you have 4 or more destructurings in an import?

@jrieken
Copy link
Member

jrieken commented Mar 28, 2018

@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.

@DanielRosenwasser
Copy link
Member

Related to #19260 or potentially a duplicate of #19260.

@mjbvz
Copy link
Contributor Author

mjbvz commented Oct 28, 2020

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

@mjbvz mjbvz closed this as completed Oct 28, 2020
@mjbvz mjbvz added the Won't Fix The severity and priority of this issue do not warrant the time or complexity needed to fix it label Oct 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Domain: Organize Imports Issues with the organize imports feature Domain: Refactorings e.g. extract to constant or function, rename symbol Suggestion An idea for TypeScript Won't Fix The severity and priority of this issue do not warrant the time or complexity needed to fix it
Projects
None yet
Development

No branches or pull requests

5 participants