Skip to content

quoteProps consistent adds quotes around constructor definition #17694

Description

@mattico

Prettier 3.6.2
Playground link

--parser babel-ts
--single-quote
--quote-props consistent

Input:

class FilterStateDefaults {
  constructor(userAuth: UserAuthorization) {
    this.customer = userAuth.isInternal ? undefined : userAuth.customer;
  }

  'customer': string | undefined;
  'line-width': string[] = [];
}

Output:

class FilterStateDefaults {
  'constructor'(userAuth: UserAuthorization) {
    this.customer = userAuth.isInternal ? undefined : userAuth.customer;
  }

  'customer': string | undefined;
  'line-width': string[] = [];
}

Expected output:

class FilterStateDefaults {
  constructor(userAuth: UserAuthorization) {
    this.customer = userAuth.isInternal ? undefined : userAuth.customer;
  }

  'customer': string | undefined;
  'line-width': string[] = [];
}

Why?

It feels wrong to have unnecessary quotes around the constructor function name. I think what I'd want is separate format options for properties and member functions. I'd set properties to consistent and functions to as-needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    lang:javascriptIssues affecting JSlang:typescriptIssues affecting TypeScript-specific constructs (not general JS issues)status:needs discussionIssues needing discussion and a decision to be made before action can be taken

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions