Skip to content

Commit 6430211

Browse files
authored
fix(38868): add separator for type parameters (#39621)
1 parent db79030 commit 6430211

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

src/services/textChanges.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ namespace ts.textChanges {
469469
public insertTypeParameters(sourceFile: SourceFile, node: SignatureDeclaration, typeParameters: readonly TypeParameterDeclaration[]): void {
470470
// If no `(`, is an arrow function `x => x`, so use the pos of the first parameter
471471
const start = (findChildOfKind(node, SyntaxKind.OpenParenToken, sourceFile) || first(node.parameters)).getStart(sourceFile);
472-
this.insertNodesAt(sourceFile, start, typeParameters, { prefix: "<", suffix: ">" });
472+
this.insertNodesAt(sourceFile, start, typeParameters, { prefix: "<", suffix: ">", joiner: ", " });
473473
}
474474

475475
private getOptionsForInsertNodeBefore(before: Node, inserted: Node, blankLineBetween: boolean): InsertNodeOptions {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/// <reference path='fourslash.ts' />
2+
// @strict: true
3+
/////**
4+
//// * @typedef Foo
5+
//// * @template L, R
6+
//// */
7+
/////**
8+
//// * @param {function(R): boolean} a
9+
//// * @param {function(R): L} b
10+
//// * @returns {function(R): Foo.<L, R>}
11+
//// * @template L, R
12+
//// */
13+
////function foo(a, b) {
14+
////}
15+
16+
verify.codeFix({
17+
description: ts.Diagnostics.Annotate_with_type_from_JSDoc.message,
18+
index: 2,
19+
newFileContent:
20+
`/**
21+
* @typedef Foo
22+
* @template L, R
23+
*/
24+
/**
25+
* @param {function(R): boolean} a
26+
* @param {function(R): L} b
27+
* @returns {function(R): Foo.<L, R>}
28+
* @template L, R
29+
*/
30+
function foo<L, R>(a: (arg0: R) => boolean, b: (arg0: R) => L): (arg0: R) => Foo<L, R> {
31+
}`,
32+
});

0 commit comments

Comments
 (0)