Skip to content

Function initializers as properties #61636

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sidlamsal
Copy link

Fixes #59112

@Copilot Copilot AI review requested due to automatic review settings May 1, 2025 02:13
@github-project-automation github-project-automation bot moved this to Not started in PR Backlog May 1, 2025
@typescript-bot typescript-bot added the For Milestone Bug PRs that fix a bug with a specific milestone label May 1, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the binder logic for expando initializers when they are function‐like, distinguishing between prototype properties and non‑prototype properties.

  • When the expando is assigned to a prototype, only the Method flag is set; otherwise, both Method and Property flags are combined.

Copy link
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

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

This change needs tests. This probably changes tonnes of existing tests, so it's a matter of

  1. $ hereby runtests-parallel
  2. $ hereby baseline-accept

and then committing the updates in tests/baselines/reference

excludes = SymbolFlags.MethodExcludes;
}
else {
includes = SymbolFlags.Method | SymbolFlags.Property;
Copy link
Member

Choose a reason for hiding this comment

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

This should just be Property, I'm pretty sure. They're a function property, but don't have useful this semantics, static vs instance distinction, etc.

@@ -3491,8 +3491,14 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
let excludes = SymbolFlags.None;
// Method-like
if (isFunctionLikeDeclaration(getAssignedExpandoInitializer(declaration)!)) {
Copy link
Member

Choose a reason for hiding this comment

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

Since you don't need a custom includes you can reduce this code change down to

Suggested change
if (isFunctionLikeDeclaration(getAssignedExpandoInitializer(declaration)!)) {
if (isPrototypeProperty && isFunctionLikeDeclaration(getAssignedExpandoInitializer(declaration)!)) {

and the default case at the bottom of the function will apply.

@github-project-automation github-project-automation bot moved this from Not started to Waiting on author in PR Backlog May 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Milestone Bug PRs that fix a bug with a specific milestone
Projects
Status: Waiting on author
Development

Successfully merging this pull request may close these issues.

Fix "isolatedDeclarations" QuickFix
3 participants