Repository navigation
organizeImports needs to be called twice to be stableΒ #57030
Description
Activity
I've investigated, and this behavior existed pre-5.3, and seems to be because
organizeImports`s detection detects the first sort as case-insensitive, and the second sort as case-sensitive. I'm currently working on improving the detection, and currently, this issue can be manually avoided by adding"typescript.unstable": { "organizeImportsIgnoreCase": true, }to your editor settings
For me using it even twice does not usually fix the issue where VS code sometimes starts to using case insensitive sorting. I had to set typescript to version 4.9.5 to get stable sort. With that version this problem does not occur.
So eagerly waiting for fix for this before I need to update Typescript version in my project.
rubiesonthesky could you provide some more details about the cases you experience this on? I would like to make sure the issues are fixed with #57267
Isabel Duan (@iisaduan) I will try to check if I can replicate it and have some minimal reproduction.
Reacted by Isabel Duanrubiesonthesky If you've been unable to get a minimal repro, can you test this version in your repository? #57267 (comment)
Isabel Duan (@iisaduan) My biggest problem is usually imports like these which I would like to sort case in-sensitive way. It seems that I have lost the correct config for that, because it was not needed with TS 4.9.5. I'll try to dig it up and test later.
import {BehaviorSubject, Observable, forkJoin, of} from 'rxjs';
Found the config... Will test drive it few days to see if the problem is still there.
"typescript.unstable": { "organizeImportsIgnoreCase": true, },
rubiesonthesky To clarify, is that config the setting you already had? And how are you invoking
organizeImports? (through VScode?)import {BehaviorSubject, Observable, forkJoin, of} from 'rxjs';
(also, with this case in particular, it is already sorted in a case-sensitive way so
case sensitivity = autoshould always tell that it is case-sensitive.)Thank you for testing!
- locked as resolved and limited conversation to collaborators
on Oct 22, 2025
π Search Terms
organizeImports
π Version & Regression Information
β― Playground Link
No response
π» Code
π Actual behavior
This needs to be organized twice in order to be stable. The first time we get
import {I, M, R} from 'a';
import {abc, Abc} from 'b';
and the second time we get
import {I, M, R} from 'a';
import {Abc, abc} from 'b';
π Expected behavior
I'd expect
import {I, M, R} from 'a';
import {Abc, abc} from 'b';
the first time around
Additional information about the issue
No response