Skip to content

source.organizeImports affects export object #61588

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
Zitrooone opened this issue Apr 16, 2025 · 1 comment
Open

source.organizeImports affects export object #61588

Zitrooone opened this issue Apr 16, 2025 · 1 comment
Labels
Bug A bug in TypeScript Help Wanted You can do this
Milestone

Comments

@Zitrooone
Copy link

Zitrooone commented Apr 16, 2025

Does this issue occur when all extensions are disabled?: Yes/No
Yes

  • VS Code Version: 1.99.2 (user setup)
  • OS Version: Windows_NT x64 10.0.26100

Steps to Reproduce:

With "source.OrganizeImports" = "explicit" exports of a TypeScript file are also affected.
I set up an example that looks like this:

import sample1 from './sampleImports/sample1'
import sample10 from './sampleImports/sample10'
import sample11 from './sampleImports/sample11'
import sample12 from './sampleImports/sample12'
import sample13 from './sampleImports/sample13'
import sample2 from './sampleImports/sample2'
import sample3 from './sampleImports/sample3'
import sample4 from './sampleImports/sample4'
import sample5 from './sampleImports/sample5'
import sample6 from './sampleImports/sample6'
import sample7 from './sampleImports/sample7'
import sample8 from './sampleImports/sample8'
import sample9 from './sampleImports/sample9'

export {
    sample1,
    sample2,
    sample3,
    sample4,
    sample5,
    sample6,
    sample7,
    sample8,
    sample9,
    sample10,
    sample11,
    sample12,
    sample13,
}

When I add a newline and save the file it results in this:

import sample1 from './sampleImports/sample1'
import sample10 from './sampleImports/sample10'
import sample11 from './sampleImports/sample11'
import sample12 from './sampleImports/sample12'
import sample13 from './sampleImports/sample13'
import sample2 from './sampleImports/sample2'
import sample3 from './sampleImports/sample3'
import sample4 from './sampleImports/sample4'
import sample5 from './sampleImports/sample5'
import sample6 from './sampleImports/sample6'
import sample7 from './sampleImports/sample7'
import sample8 from './sampleImports/sample8'
import sample9 from './sampleImports/sample9'


export {
    sample1, sample10,
    sample11,
    sample12,
    sample13, sample2,
    sample3,
    sample4,
    sample5,
    sample6,
    sample7,
    sample8,
    sample9
}

I expect the order of the exports to be untouched.
We are using an EsLint Plugin to sort the exports alphabetically (which is not happy with the result of the import organization), but the issue stems from the setting. Launching VS Code without any extension produces the same result.
The example can be found here: https://github.com/Zitrooone/vscode-organizeImports-test

@mjbvz mjbvz transferred this issue from microsoft/vscode Apr 16, 2025
@mjbvz mjbvz removed their assignment Apr 16, 2025
@RyanCavanaugh
Copy link
Member

Confirmed. No setting change required here, just need to invoke the "Organize Imports" command from the palette.

@RyanCavanaugh RyanCavanaugh added Bug A bug in TypeScript Help Wanted You can do this labels Apr 17, 2025
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Apr 17, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Bug A bug in TypeScript Help Wanted You can do this
Projects
None yet
Development

No branches or pull requests

3 participants