Skip to content

Adding an import with quick fix should respect sort order #16119

Closed
@JoshuaKGoldberg

Description

@JoshuaKGoldberg

TypeScript Version: 2.3

Code

Before the suggested B import is added:

import { A, C } from "./letters";

const b: B = new B(); // suggestion to import B from "./letters";

After:

import { A, C, B } from "./letters"; // TSLint's ordered-import rule is now offering a quick fix

const b: B = new B();

Expected behavior:

If the imports are sorted, adding a new one should add in sorted order. In this case it would be { A, B, C }.

Actual behavior:

The added import is tacked onto the end.

If the preference for keeping imports sorted will be added in #10020, it seems like it would make sense to respect that order in individual adds as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: Quick FixesEditor-provided fixes, often called code actions.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions