Skip to content

codefix for new method should include asterisk for generator functions #24728

@krk

Description

@krk

Search Terms

asterisk, addMethodDeclaration

Suggestion

When a new method is created that is used by a yield * expression, generated method should have an asterisk before its name.

Use Cases

VSCode would create generator functions when the addMissingMember codefix is applied to an invocation inside a YieldExpression.

Examples

New method created by vscode for this block:

class A {
  private *a() {
    yield* this.abc();
  }
}

is:

abc(): any {
  throw new Error("Method not implemented.");
}

and while it is apparent that return type should be changed, it is not obvious to convert the new abc funciton to a generator function such as:

*abc(): any {
  throw new Error("Method not implemented.");
}

Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript / JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. new expression-level syntax)

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: LS: Quick FixesEditor-provided fixes, often called code actions.FixedA PR has been merged for this issueGood First IssueWell scoped, documented and has the green lightHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions