Merge pull request #24760 from krk/codefix-asterisk

addMethodDeclaration codefix creates a generator function when target…
This commit is contained in:
Mohamed Hegazy 2018-06-08 08:57:49 -07:00 committed by GitHub
commit b4dea5ecce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 2 deletions

View File

@ -111,7 +111,7 @@ namespace ts.codefix {
}
export function createMethodFromCallExpression(
{ typeArguments, arguments: args }: CallExpression,
{ typeArguments, arguments: args, parent: parent }: CallExpression,
methodName: string,
inJs: boolean,
makeStatic: boolean,
@ -120,7 +120,7 @@ namespace ts.codefix {
return createMethod(
/*decorators*/ undefined,
/*modifiers*/ makeStatic ? [createToken(SyntaxKind.StaticKeyword)] : undefined,
/*asteriskToken*/ undefined,
/*asteriskToken*/ isYieldExpression(parent) ? createToken(SyntaxKind.AsteriskToken) : undefined,
methodName,
/*questionToken*/ undefined,
/*typeParameters*/ inJs ? undefined : map(typeArguments, (_, i) =>

View File

@ -0,0 +1,21 @@
/// <reference path='fourslash.ts' />
////class C {
//// *method() {
//// yield* this.y();
//// }
////}
verify.codeFixAll({
fixId: "addMissingMember",
fixAllDescription: "Add all missing members",
newFileContent:
`class C {
*method() {
yield* this.y();
}
*y(): any {
throw new Error("Method not implemented.");
}
}`,
});

View File

@ -0,0 +1,21 @@
/// <reference path='fourslash.ts' />
////class C {
//// method() {
//// yield* this.y();
//// }
////}
verify.codeFixAll({
fixId: "addMissingMember",
fixAllDescription: "Add all missing members",
newFileContent:
`class C {
method() {
yield* this.y();
}
y(): any {
throw new Error("Method not implemented.");
}
}`,
});