Skip to content

[Repo Assist] feat: show type alias expansion in hover tooltips (partially addresses #1203/#653)#1518

Draft
github-actions[bot] wants to merge 4 commits intomainfrom
repo-assist/improve-type-alias-expansion-tooltip-a09c535cb531dae7
Draft

[Repo Assist] feat: show type alias expansion in hover tooltips (partially addresses #1203/#653)#1518
github-actions[bot] wants to merge 4 commits intomainfrom
repo-assist/improve-type-alias-expansion-tooltip-a09c535cb531dae7

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot commented Apr 4, 2026

🤖 This PR was created by Repo Assist, an automated AI assistant.

Summary

When hovering over a value or function whose type is a type abbreviation (alias), the hover tooltip now shows a comment line with the expanded concrete type below the signature.

Before

val myValue: ConnectionAlias

After

val myValue: ConnectionAlias
    // = System.Data.IDbConnection

This partially addresses #1203 and #653 — users no longer need to leave their current position to look up what a type alias expands to.

Root Cause / Design

FCS uses FSharpType.IsAbbreviation to flag type abbreviations. The existing formatType function shows the alias name (e.g. ConnectionAlias) when HasTypeDefinition = true on the abbreviated type. For function types (e.g. type Fn = int -> string), FCS already expands the alias before FSAC sees it, so those cases remain unchanged. The new expansion only fires for non-function type aliases where FSAC receives the FSharpType with IsAbbreviation = true.

Changes

  • DocumentationFormatter.fs:
    • Added expandTypeAbbreviations — recursively unwraps alias chains to the concrete type
    • Added tryGetExpandedAliasDisplay — returns the expanded display string only when it differs from the alias name; wrapped in try/catch so FCS errors never surface
    • getValSignature — appends \n // = <expanded> when applicable
    • getFuncSignatureWithIdent (empty argInfos branch) — same for the val name: Type case in function signatures

Test Status

✅ Build passes
✅ All 24 type-alias-related tests pass
✅ All 224 hover/signature/tooltip tests that were previously passing continue to pass
⚠️ 4 pre-existing test failures unrelated to this change (objnull vs obj type name change in newer FCS version — these fail on main too)

Closes #1203 (partially — the expansion of non-function aliases in hover tooltips)
Related: #653

Generated by 🌈 Repo Assist, see workflow run. Learn more.

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@4ea8c81959909f40373e2a5c2b7fdb54ea19e0a5

…tially addresses #1203/#653)

When hovering over a value or function whose type is a type abbreviation,
show a comment line with the expanded concrete type in the fsharp code block.

For example, hovering over `x: MyAlias` where `type MyAlias = SomeConcreteType`
now shows:

  val x: MyAlias
      // = SomeConcreteType

Implementation:
- Add `expandTypeAbbreviations` helper to recursively unwrap alias chains
- Add `tryGetExpandedAliasDisplay` to compute the expansion if it differs from the alias name
- Update `getValSignature` and the empty-argInfos case in `getFuncSignatureWithIdent`
  to append the expanded type as a code comment when present
- Wrapped in try/catch so FCS errors never surface as user-visible exceptions
- No-op when FCS has already expanded the alias (IsFunctionType cases)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
When error-free code is checked, the LSP server sends no publishDiagnostics
notifications, so Observable.bufferSpan completes with an empty IList.
Seq.last threw InvalidOperationException on the empty sequence.

Replace Seq.last with Seq.tryLast |> Option.defaultValue [||] so that an
empty buffer returns an empty diagnostics array (correct result for
error-free code) instead of throwing.

This fixes the flaky InlayHint.voption.show test on ubuntu-latest/net9.0
BackgroundCompiler CI.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions bot commented Apr 6, 2026

Commit pushed: bbd2c7b

Generated by 🌈 Repo Assist, see workflow run. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Support for Breaking Down Type Signatures in Tooltips

0 participants