Skip to content

Commit

Permalink
fix(38868): add separator for type parameters (#39621)
Browse files Browse the repository at this point in the history
  • Loading branch information
a-tarasyuk authored Jul 16, 2020
1 parent db79030 commit 6430211
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/services/textChanges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ namespace ts.textChanges {
public insertTypeParameters(sourceFile: SourceFile, node: SignatureDeclaration, typeParameters: readonly TypeParameterDeclaration[]): void {
// If no `(`, is an arrow function `x => x`, so use the pos of the first parameter
const start = (findChildOfKind(node, SyntaxKind.OpenParenToken, sourceFile) || first(node.parameters)).getStart(sourceFile);
this.insertNodesAt(sourceFile, start, typeParameters, { prefix: "<", suffix: ">" });
this.insertNodesAt(sourceFile, start, typeParameters, { prefix: "<", suffix: ">", joiner: ", " });
}

private getOptionsForInsertNodeBefore(before: Node, inserted: Node, blankLineBetween: boolean): InsertNodeOptions {
Expand Down
32 changes: 32 additions & 0 deletions tests/cases/fourslash/annotateWithTypeFromJSDoc23.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/// <reference path='fourslash.ts' />
// @strict: true
/////**
//// * @typedef Foo
//// * @template L, R
//// */
/////**
//// * @param {function(R): boolean} a
//// * @param {function(R): L} b
//// * @returns {function(R): Foo.<L, R>}
//// * @template L, R
//// */
////function foo(a, b) {
////}

verify.codeFix({
description: ts.Diagnostics.Annotate_with_type_from_JSDoc.message,
index: 2,
newFileContent:
`/**
* @typedef Foo
* @template L, R
*/
/**
* @param {function(R): boolean} a
* @param {function(R): L} b
* @returns {function(R): Foo.<L, R>}
* @template L, R
*/
function foo<L, R>(a: (arg0: R) => boolean, b: (arg0: R) => L): (arg0: R) => Foo<L, R> {
}`,
});

0 comments on commit 6430211

Please sign in to comment.