[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
Conversation
…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>
This was referenced Apr 5, 2026
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>
Contributor
Author
|
Commit pushed:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 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
After
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.IsAbbreviationto flag type abbreviations. The existingformatTypefunction shows the alias name (e.g.ConnectionAlias) whenHasTypeDefinition = trueon 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 withIsAbbreviation = true.Changes
DocumentationFormatter.fs:expandTypeAbbreviations— recursively unwraps alias chains to the concrete typetryGetExpandedAliasDisplay— returns the expanded display string only when it differs from the alias name; wrapped intry/catchso FCS errors never surfacegetValSignature— appends\n // = <expanded>when applicablegetFuncSignatureWithIdent(emptyargInfosbranch) — same for theval name: Typecase in function signaturesTest Status
✅ Build passes
⚠️ 4 pre-existing test failures unrelated to this change (
✅ All 24 type-alias-related tests pass
✅ All 224 hover/signature/tooltip tests that were previously passing continue to pass
objnullvsobjtype name change in newer FCS version — these fail onmaintoo)Closes #1203 (partially — the expansion of non-function aliases in hover tooltips)
Related: #653