-
Notifications
You must be signed in to change notification settings - Fork 798
Port TypeScript PR #62950: Ignore computed name parents when looking up containing functions #2461
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
…up containing functions Co-authored-by: RyanCavanaugh <[email protected]>
Co-authored-by: RyanCavanaugh <[email protected]>
jakebailey
left a comment
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.
where is getContainingFunctionDeclaration?
internal/checker/utilities.go
Outdated
| return nil | ||
| } | ||
|
|
||
| func getContainingClassStaticBlock(node *ast.Node) *ast.Node { |
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.
It's suspect that this is ported but the func is unused
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.
Removed in c0af02c. It was unused since the equivalent TypeScript logic (in addInheritedMembers) isn't in the Go codebase.
RyanCavanaugh
left a comment
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.
@copilot also add the new tests from the upstream PR as local tests in this repo
…am PR Co-authored-by: RyanCavanaugh <[email protected]>
Added in c0af02c:
|
RyanCavanaugh
left a comment
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.
@copilot getContainingClassStaticBlock appears to have no callers, remove it from the codebase
Ports microsoft/TypeScript#62950
When looking up containing functions from within a computed property name (e.g.,
[yield 0]), the compiler would incorrectly treat the method being defined as the containing function, causing infinite recursion during contextual typing.Changes
GetContainingFunction(internal/ast/utilities.go): Skip overComputedPropertyNamenodes by jumping tonode.Parent.ParentgetContainingFunctionOrClassStaticBlock(internal/checker/utilities.go): Same fixThis also fixes
awaitexpressions in computed property names inside class static blocks now correctly reporting errors.Tests Added
Added tests from the upstream PR as local tests:
yieldInComputedNameOfContextuallyTypedObjectNoCrash1.ts- tests yield in computed property nameclassStaticBlock29.ts- tests await in computed property name inside class static blockNot Ported
getContainingFunctionDeclaration- only used byconvertParamsToDestructuredObjectrefactor service which doesn't exist in the Go codebase yetgetContainingClassStaticBlock- no callers in the Go codebaseOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.