Is there a way to automatically sort TypeScript interface keys? I'm already using Prettier and VSCode so ideally the solution would be with those but I'm open to any solutions.
For example,
// before
interface MyInterface {
foo: number;
bar: number;
baz: number;
}
// after sort
interface MyInterface {
bar: number;
baz: number;
foo: number;
}
Lots of plugins are available for VSCode. "Sort" by "Henrik Sjööh" works nicely.
After installing the plugin, highlight the interface and press alt+shift+s
(option+shift+s
on MacOS) and the interface will be reordered.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With