Skip to content

Avoid constructing empty extends clauses in hovers#3507

Open
DanielRosenwasser wants to merge 7 commits intomainfrom
failingVerboseHover
Open

Avoid constructing empty extends clauses in hovers#3507
DanielRosenwasser wants to merge 7 commits intomainfrom
failingVerboseHover

Conversation

@DanielRosenwasser
Copy link
Copy Markdown
Member

Fixes #3506

Co-authored-by: Copilot <copilot@github.com>
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

Fixes a hover/quick info crash in the TypeScript-Go language server when expanding class declarations whose base type cannot be represented as a valid extends heritage expression (e.g., mixin constructors returning intersections).

Changes:

  • Skip emitting an extends heritage clause when no valid ExpressionWithTypeArguments nodes can be constructed for the base types.
  • Add a new fourslash test covering hover verbosity on a class extending a mixin constructor that returns an intersection type.
  • Add the corresponding reference baseline for the new fourslash test.
Show a summary per file
File Description
internal/checker/nodebuilder_hover.go Filters out nil heritage expressions and avoids constructing an empty extends clause during hover expansion.
internal/fourslash/tests/quickinfoVerbosityClassWithMixinBase_test.go New regression test exercising hover verbosity expansion for a mixin base returning an intersection.
testdata/baselines/reference/fourslash/quickInfo/quickinfoVerbosityClassWithMixinBase1.baseline New expected hover output baseline for the added test.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 1

defer testutil.RecoverAndFail(t, "Panic on fourslash test")

// Expanded hover serializes Derived's generated class declaration,
// including the class heritage clause for a constructor returning an intersection.
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

The comment says the expanded hover includes the class heritage clause, but the expected baseline output for verbosity level 1 shows class Derived {} with no extends .... Please update the comment to describe the actual intended behavior (e.g. that we omit an extends clause when we can't construct any heritage expressions) so the test remains self-explanatory.

Suggested change
// including the class heritage clause for a constructor returning an intersection.
// omitting an extends clause when no heritage expression can be constructed
// from a constructor type returning an intersection.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

@gabritto gabritto left a comment

Choose a reason for hiding this comment

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

In light of the recent issues we've had in this same code path, I'm wondering if maybe the right thing to do here is to just print the heritage clauses as they exist in the declaration(s). I think we're not supposed to expand those, so I'm not sure anything is gained by reconstructing the heritage clauses from the base types, which potentially loses information that the declaration had...

// ^^^^^^^
// | ----------------------------------------------------------------------
// | ```typescript
// | class Derived
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.

Could we somehow just print extends Mixin here?

DanielRosenwasser and others added 2 commits April 22, 2026 20:56
Co-authored-by: Copilot <copilot@github.com>
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.

Verbose quick info crash when base type constructs an intersection

3 participants