Closed
Description
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
- Type parameters and arguments not always treated as a list in src/service/formatting/formatting.ts in
TypeScript/src/services/formatting/formatting.ts
Line 1308 in ce85d64
- After that, the condition that the trailing comma is recognized in a list only checks for call-like expressions:
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
Labels
No labels