Print trailing comma after a single TS generic in arrow fns (#14113)
This commit is contained in:
parent
a6d77d07b4
commit
1c32b670ce
@ -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(">");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
async <T>(a: T): T => a;
|
async <T,>(a: T): T => a;
|
||||||
@ -0,0 +1,2 @@
|
|||||||
|
// Verify typescript doesn't change anything inside type parameter declaration
|
||||||
|
const foo = <T,>(a: T): T => a;
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"plugins": ["jsx", "typescript"]
|
||||||
|
}
|
||||||
@ -0,0 +1,2 @@
|
|||||||
|
// Verify typescript doesn't change anything inside type parameter declaration
|
||||||
|
const foo = <T,>(a: T): T => a;
|
||||||
@ -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;
|
||||||
@ -1 +1 @@
|
|||||||
<T>(a: T): T => a;
|
<T,>(a: T): T => a;
|
||||||
@ -1,3 +1,3 @@
|
|||||||
<T>() => 1;
|
<T,>() => 1;
|
||||||
|
|
||||||
<T>(x) => 1;
|
<T,>(x) => 1;
|
||||||
|
|||||||
@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user