Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix: Exclude generator functions from convert-to-class suggestions#62066

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Copilot wants to merge3 commits intomain
base:main
Choose a base branch
Loading
fromcopilot/fix-62056

Conversation

Copilot
Copy link
Contributor

@CopilotCopilotAI commentedJul 14, 2025
edited
Loading

Generator functions (function*) were incorrectly triggering the TS80002 diagnostic "This constructor function may be converted to a class declaration". This is incorrect because generator functions have special semantics that are incompatible with class constructors.

Problem:

function*gen(){}gen.prototype.next=gen.prototype.next;gen.prototype.return=gen.prototype.return;

The above code would incorrectly trigger the convert-to-class suggestion, even though generator functions cannot be meaningfully converted to classes.

Solution:
Added checks in thecanBeConvertedToClass function to exclude generator functions by testing forFunctionFlags.Generator in both function declaration and function expression paths.

Changes:

  • Modifiedsrc/services/suggestionDiagnostics.ts to exclude generator functions
  • Added comprehensive test coverage for generator declarations, generator expressions, and mixed scenarios
  • Verified that regular constructor functions continue to work correctly

Testing:

  • All existing tests pass
  • New tests verify generator functions don't trigger the diagnostic
  • Regular constructor functions still correctly trigger the diagnostic when appropriate

Fixes#62056.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Clickhere to start the survey.

@typescript-bottypescript-bot added the For Milestone BugPRs that fix a bug with a specific milestone labelJul 14, 2025
CopilotAIand others added2 commitsJuly 14, 2025 17:13
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Copy link
Member

@RyanCavanaughRyanCavanaugh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Runnpx hereby format and commit that

@CopilotCopilotAI changed the title[WIP] Generator functions trigger TS80002Fix: Exclude generator functions from convert-to-class suggestionsJul 14, 2025
@CopilotCopilotAI requested a review fromRyanCavanaughJuly 14, 2025 17:31
Copilot finished work on behalf ofRyanCavanaughJuly 14, 2025 17:31
@CopilotCopilot SWE Agent
Copy link
ContributorAuthor

Runnpx hereby format and commit that

Rannpx hereby format - no formatting changes were needed as the code is already properly formatted.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@RyanCavanaughRyanCavanaughRyanCavanaugh approved these changes

At least 1 approving review is required to merge this pull request.

Labels
For Milestone BugPRs that fix a bug with a specific milestone
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Generator functions trigger TS80002
3 participants
@Copilot@RyanCavanaugh@typescript-bot

[8]ページ先頭

©2009-2025 Movatter.jp