Skip to content

Function initializers as properties#61636

Closed
sidlamsal wants to merge 2 commits intomicrosoft:mainfrom
SeniorSeminarGroup:last2
Closed

Function initializers as properties#61636
sidlamsal wants to merge 2 commits intomicrosoft:mainfrom
SeniorSeminarGroup:last2

Conversation

@sidlamsal
Copy link
Copy Markdown

Fixes #59112

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
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
@typescript-bot
Copy link
Copy Markdown
Collaborator

With 6.0 out as the final release vehicle for this codebase, we're closing all PRs that don't fit the merge criteria for post-6.0 patches. If you think this was a mistake and this PR fits the post-6.0 patch criteria, please post to the 6.0 iteration issue with details (specifically, which PR and which patch criteria it satisfies).

Next steps for PRs:

  • For crash bugfixes or language service improvements, PRs are currently accepted at the typescript-go repo
  • Changes to type system behavior should wait until after 7.0, at which point mainline TypeScript development will resume in this repository with the Go codebase
  • Library file updates (lib.d.ts etc) continue to live in this repo or the DOM Generator repo as appropriate

@github-project-automation github-project-automation bot moved this from Waiting on author to Done in PR Backlog Mar 24, 2026
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: Done

Development

Successfully merging this pull request may close these issues.

Fix "isolatedDeclarations" QuickFix

5 participants