mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-07-04 14:56:16 -05:00
fix(38868): add separator for type parameters (#39621)
This commit is contained in:
@@ -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 {
|
||||
|
||||
32
tests/cases/fourslash/annotateWithTypeFromJSDoc23.ts
Normal file
32
tests/cases/fourslash/annotateWithTypeFromJSDoc23.ts
Normal file
@@ -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> {
|
||||
}`,
|
||||
});
|
||||
Reference in New Issue
Block a user