Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 9, 2026

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.

function* g() {
  let x: any = {
    *[yield 0]() {}  // yield should be in context of g(), not the method
  };
}

Changes

  • GetContainingFunction (internal/ast/utilities.go): Skip over ComputedPropertyName nodes by jumping to node.Parent.Parent
  • getContainingFunctionOrClassStaticBlock (internal/checker/utilities.go): Same fix
  • getContainingClassStaticBlock (internal/checker/utilities.go): Added new function with same computed property name handling, for parity with TypeScript

This also fixes await expressions in computed property names inside class static blocks now correctly reporting errors.

Original prompt

Port microsoft/TypeScript#62950

Custom agent used: Strada to Corsa Port Expert
A Go and TypeScript expert who can easily figure out how to port PRs from one language to another


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Port TypeScript pull request 62950 Port TypeScript PR #62950: Ignore computed name parents when looking up containing functions Jan 9, 2026
Copilot AI requested a review from RyanCavanaugh January 9, 2026 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants