-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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.
There was a problem hiding this 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
$ hereby runtests-parallel
$ hereby baseline-accept
and then committing the updates in tests/baselines/reference
excludes = SymbolFlags.MethodExcludes; | ||
} | ||
else { | ||
includes = SymbolFlags.Method | SymbolFlags.Property; |
There was a problem hiding this comment.
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)!)) { |
There was a problem hiding this comment.
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
if (isFunctionLikeDeclaration(getAssignedExpandoInitializer(declaration)!)) { | |
if (isPrototypeProperty && isFunctionLikeDeclaration(getAssignedExpandoInitializer(declaration)!)) { |
and the default case at the bottom of the function will apply.
Fixes #59112