vs-code-typescript-class-organizer icon indicating copy to clipboard operation
vs-code-typescript-class-organizer copied to clipboard

Feature request: Setting for disabling/enabling automatic sorting by name

Open ArnieGA opened this issue 1 year ago • 1 comments

The organizing of member groups is absolutely great, until you notice that the fields/properties defined in interfaces/types get automatically sorted in ascending fashion, by name.

For example:

// This is the way I'd wish for the following interface to remain written
interface Example {
    id: string;
    name: string;
    description: string;
    creds: string[];
}
// This is the result from the extension, after saving the file:
interface Example {
    creds: string[];
    description: string;
    id: string;
    name: string;
}

It would be very very helpful to have control over this feature --the automatic sorting of fields/properties pretty much obligated me to disable the extension.

Thank you for your time!

ArnieGA avatar Jan 15 '24 14:01 ArnieGA

Just to add that when you have one field that depends on another, TypeScript requires that they be in the right order - sorting them by name can cause a syntax error:

class Example {
  public readonly activeContacts = this.contacts.filter(...); // Error Property 'contacts' is used before its initialization.
  public readonly contacts = [];
}

mlamothe avatar May 03 '24 12:05 mlamothe