Skip to content

auto-import with alphabetized order by default #33839

Closed
@shiqimei

Description

@shiqimei

Search Terms

auto-import; import; auto import

Suggestion

Support auto-import with alphabetized order by default

Use Cases

image
Currently, Typescript auto-import by adding the new module at the end. But it does not obey tslint rule: ordered-imports It will be better if typescript can auto-import with alphabetized order by default :)

Examples

import { B } from 'moduleB';
...
const a = new A(); // Ctrl+. -> Do you want to import A?

then

import { A, B } from 'moduleB'; // A is auto-imported in front of B
...
const a = new a();
...
classs ModuleA implements IModuleA { // Ctrl+. -> Do you want to import IModuleA?
...

then

import { IModuleA } from 'moduleA'; // moduleA is auto-imported above moduleB
import { A, B } from 'moduleB';
...
const a = new a();
...
class ModuleA implements IModuleA {
...

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.

Metadata

Metadata

Assignees

Labels

Experience EnhancementNoncontroversial enhancementsFix AvailableA PR has been opened for this issueSuggestionAn idea for TypeScriptVS Code PriorityCritical issues that VS Code needs fixed in the current TypeScript milestone

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions