Skip to content

Formatter: indent second operand of intersection operator on next line one indent more #56609

@GBrachetta

Description

@GBrachetta

I use "vscode.typescript-language-features" as my default JS/TS formatter, and when formatting long lines, the indentation could be improved.

As an example, this is the resulting code after "vscode.typescript-language-features":

const Label = React.forwardRef<
  React.ElementRef<typeof LabelPrimitive.Root>,
  React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
  VariantProps<typeof labelVariants> // <= This line isn't sufficiently indented.
>(({ className, ...props }, ref) => (
  <LabelPrimitive.Root
    className={cn(labelVariants(), className)}
    ref={ref}
    {...props}
  />
));

Please note that the 4th line isn't indented deeper.
What would be visually clearer would be:

const Label = React.forwardRef<
  React.ElementRef<typeof LabelPrimitive.Root>,
  React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
    VariantProps<typeof labelVariants> // <= This line indented deeper.
>(({ className, ...props }, ref) => (
  <LabelPrimitive.Root
    className={cn(labelVariants(), className)}
    ref={ref}
    {...props}
  />
));

Is there a way to wrap them in a way that the result looks like the second snippet?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureDomain: FormatterThe issue relates to the built-in formatterSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions