Skip to content

TypeScript enums fail to unquote #17641

Description

@Zamiell

Prettier 3.5.3

Prettier forces object keys to become unquoted, unless the quotes are actually necessary. This is fantastic! However, the same treatment does not apply to enums for some reason.

I propose that this is a bug: enums should be treated the same as objects.

Why? For all the exact same reasons that we want objects to be formatted this way (i.e. having superfluous quotes is pointless).

This playground showcases the problem: Playground link

--parser typescript

Input:

const SomeObject = {
  "someKey": "someValue",
}

enum SomeEnum {
  "someKey" = "someValue",
}

Output:

const SomeObject = {
  someKey: "someValue",
};

enum SomeEnum {
  "someKey" = "someValue",
}

Expected output:

const SomeObject = {
  someKey: "someValue",
};

enum SomeEnum {
  someKey = "someValue",
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    lang:typescriptIssues affecting TypeScript-specific constructs (not general JS issues)locked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions