addMethodDeclaration codefix creates a generator function when target is child of a YieldExpression, resolves #24728

This commit is contained in:
krk
2018-06-07 20:59:06 +03:00
parent d0ae03c4cc
commit acbda14450
3 changed files with 46 additions and 2 deletions
+4 -2
View File
@@ -111,16 +111,18 @@ namespace ts.codefix {
}
export function createMethodFromCallExpression(
{ typeArguments, arguments: args }: CallExpression,
{ typeArguments, arguments: args, parent: parent }: CallExpression,
methodName: string,
inJs: boolean,
makeStatic: boolean,
preferences: UserPreferences,
): MethodDeclaration {
const asterisk = parent.kind === SyntaxKind.YieldExpression ? createToken(SyntaxKind.AsteriskToken) : undefined;
return createMethod(
/*decorators*/ undefined,
/*modifiers*/ makeStatic ? [createToken(SyntaxKind.StaticKeyword)] : undefined,
/*asteriskToken*/ undefined,
/*asteriskToken*/ asterisk,
methodName,
/*questionToken*/ undefined,
/*typeParameters*/ inJs ? undefined : map(typeArguments, (_, i) =>