Print trailing comma after a single TS generic in arrow fns (#14113)

This commit is contained in:
Ozan H 2022-01-10 17:37:05 +03:00 committed by GitHub
parent a6d77d07b4
commit 1c32b670ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 17 additions and 6 deletions

View File

@ -12,9 +12,13 @@ export function TSTypeAnnotation(this: Printer, node: t.TSTypeAnnotation) {
export function TSTypeParameterInstantiation( export function TSTypeParameterInstantiation(
this: Printer, this: Printer,
node: t.TSTypeParameterInstantiation, node: t.TSTypeParameterInstantiation,
parent: t.Node,
): void { ): void {
this.token("<"); this.token("<");
this.printList(node.params, node, {}); this.printList(node.params, node, {});
if (parent.type === "ArrowFunctionExpression" && node.params.length === 1) {
this.token(",");
}
this.token(">"); this.token(">");
} }

View File

@ -1 +1 @@
async <T>(a: T): T => a; async <T,>(a: T): T => a;

View File

@ -0,0 +1,2 @@
// Verify typescript doesn't change anything inside type parameter declaration
const foo = <T,>(a: T): T => a;

View File

@ -0,0 +1,3 @@
{
"plugins": ["jsx", "typescript"]
}

View File

@ -0,0 +1,2 @@
// Verify typescript doesn't change anything inside type parameter declaration
const foo = <T,>(a: T): T => a;

View File

@ -1,2 +1,2 @@
// Same as `generic`. Verify that JSX doesn't change things. // Same as `generic`. Verify that JSX doesn't change things.
<T>(a: T): T => a; <T,>(a: T): T => a;

View File

@ -1 +1 @@
<T>(a: T): T => a; <T,>(a: T): T => a;

View File

@ -1,3 +1,3 @@
<T>() => 1; <T,>() => 1;
<T>(x) => 1; <T,>(x) => 1;

View File

@ -4,6 +4,6 @@ function a() {
} }
function d() { function d() {
let e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : <T>() => {}; let e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : <T,>() => {};
let T; let T;
} }