Repository navigation
source.organizeImports affects export object #61588
Description
Activity
RyanCavanaugh commented
on Apr 17, 2025 MemberMore actionsConfirmed. No setting change required here, just need to invoke the "Organize Imports" command from the palette.
Reacted by André Krebs- addedBugA bug in TypeScriptA bug in TypeScriptHelp WantedYou can do thisYou can do this
on Apr 17, 2025 Ryan Cavanaugh (@RyanCavanaugh) I noticed the behavior seems tied to the default settings for
organizeImportsCollation("ordinal") andorganizeImportsNumericCollation(false). Given those defaults, it looks like the current sorting is working as designed (reference: #52115).That said, the issue has a
Help Wantedlabel, were you thinking of potentially changing those defaults?Initially when I looked at this, I thought that the problem is that the detection code isn't working (which applies when the user hasn't set anything explicitly), however rereading this, the two different blocks have two different sortings. The imports are not sorted naturally, but the exports are sorted naturally. So no matter what we're doing, we're going to resort one of the blocks.
I can't say I like the edit that was chosen here, but, is there anything actually wrong here outside the suboptimal columns?
I am uncertain whether Jake Bailey (@jakebailey) 's question was directed at me, but I would like to offer my two cents on this regardless.
Choosing sample 1 through 13 for my example was not ideal, I agree. However, I am not taking issue in the order of the keys, but with the way they are put on the same line in some instances. I would like to add, that this only happens once a certain number of keys has been reached.
Through the issue mentioned by Idan Goshen (@idango10) I learned that the
organizeImportssetting is in fact supposed to affect the export as well. I see how the two are related, though the naming of the setting specifically mentions "imports" and thus I was surprised by the actual behaviour. Paired with the fact that I was not able to find any official documentation for this setting and its various sub-settings, I do think this is misleading and could likely confuse other users as well.To me it would be sufficient if keys remained in a one-per-line configuration, as this is important for readability in this scenario.
Would renaming the settings or splitting import and export sorting be plausible to avoid confusion and/or conflicts with other import/export sorting?
- addedDomain: LS: Organize ImportsIssues with the organize imports featureIssues with the organize imports feature
on Oct 15, 2025 - locked as resolved and limited conversation to collaborators
on Dec 3, 2025 RyanCavanaugh commented
on Dec 3, 2025 MemberMore actionsClosing language service bugs related to the 6.0 implementation. For more information, see #62827
Does this issue occur when all extensions are disabled?: Yes/No
Yes
Steps to Reproduce:
With
"source.OrganizeImports" = "explicit"exports of a TypeScript file are also affected.I set up an example that looks like this:
When I add a newline and save the file it results in this:
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