Skip to content

Type parameters in generics indented incorrectly when formattedΒ #49151

Closed
@TRCYX

Description

@TRCYX

Bug Report

πŸ”Ž Search Terms

generic indent indentation format type parameters

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about formatting & generics

⏯ Playground Link

Playground link with relevant code

Same as below.

πŸ’» Code

export class C<E
    > {

    x: any;
    constructor<T,
        >(x: T) { this.x = x; }
}


declare function f<T,
    >(x: T): T;

const id = <
    C,
    >(x: C): C => { return x; }

type TYP<
    E
    > = E[];

interface INT<
    E, F
    > { }

export const x = class <E
    >{ };

πŸ™ Actual behavior

The above code is already formatted.

πŸ™‚ Expected behavior

All right angular brackets should be unindented. Note that under certain circumstances the trailing comma is necessary to reproduce the bug, while sometimes it does not matter.

Seems related to

Also related to PR #42341 which fixes a similar case in issue #15782, but only fixes the problem for instantiating a generic type, not for type parameters and arguments in general.

I've started trying to write a fix for this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions