mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-12-12 11:50:54 -06:00
Allow trailing commas on lambda type parameter lists (#59612)
This commit is contained in:
parent
562b815ba3
commit
03bca1d8fe
@ -4508,7 +4508,7 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
|
||||
if (isFunctionLike(parentNode) && parentNode.typeArguments) { // Quick info uses type arguments in place of type parameters on instantiated signatures
|
||||
return emitTypeArguments(parentNode, parentNode.typeArguments);
|
||||
}
|
||||
emitList(parentNode, typeParameters, ListFormat.TypeParameters);
|
||||
emitList(parentNode, typeParameters, ListFormat.TypeParameters | (isArrowFunction(parentNode) ? ListFormat.AllowTrailingComma : ListFormat.None));
|
||||
}
|
||||
|
||||
function emitParameters(parentNode: Node, parameters: NodeArray<ParameterDeclaration>) {
|
||||
|
||||
@ -100,6 +100,17 @@ describe("unittests:: PrinterAPI", () => {
|
||||
ts.ScriptKind.TSX,
|
||||
));
|
||||
});
|
||||
|
||||
// https://github.com/microsoft/TypeScript/issues/59587
|
||||
printsCorrectly("lambda type parameter lists in tsx", {}, printer => {
|
||||
return printer.printFile(ts.createSourceFile(
|
||||
"source.tsx",
|
||||
String.raw`export const id = <T,>(id: T): T => id`,
|
||||
ts.ScriptTarget.ESNext,
|
||||
/*setParentNodes*/ undefined,
|
||||
ts.ScriptKind.TSX,
|
||||
));
|
||||
});
|
||||
});
|
||||
|
||||
describe("No duplicate ref directives when emiting .d.ts->.d.ts", () => {
|
||||
|
||||
@ -0,0 +1 @@
|
||||
export const id = <T,>(id: T): T => id;
|
||||
Loading…
x
Reference in New Issue
Block a user