Skip to content

TypeScript: Comma as separator for single-line type literal #11

@KSXGitHub

Description

@KSXGitHub

Is your feature request related to a problem? Please describe.

I want to write this code:

type MyObject = { foo: number, bar: string }

But dprint-plugin-typescript converts it to semicolons:

type MayObject = { foo: number; bar: string }

which it is not what I want.

Describe the solution you'd like

While I prefer commas as separator, others might prefer semicolons, so I suggest a configuration key should be introduced to specify whether the separator should be commas or semicolons:

  • objectLiteralTypeSeparator: 'comma' | 'semicolon'
  • singleLineObjectLiteralTypeSeparator: 'comma' | 'semicolon''
  • multiLineObjectLiteralTypeSeparator: 'comma' | 'semicolon' | 'none'

Describe alternatives you've considered

Additional context

I have set .semi_colons(SemiColons::Asi) in my own formatter, so I would prefer multi-line object literal type to not have separator.

Metadata

Metadata

Assignees

No one assigned

    Labels

    configurationConfigurable formatting behaviour.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions