You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add Support for Breaking Down Type Signatures in Tooltips #1203
typeGetNumberFromDb= IDbConnection -> int
letgetNumberFromDb:GetNumberFromDb =fun conn ->1letaddNumberFunc' (dbFunc :GetNumberFromDb)otherNumber conn =letnumber= dbFunc conn
printfn "I got a number: %i" number
number + otherNumber
typeAddNumberFunc= int -> IDbConnection -> int
letaddNumberFunc:AddNumberFunc =
addNumberFunc' getNumberFromDb
letsomeHigherOrderFunction' (addNum :AddNumberFunc)num conn =
addNum num conn
// other logic heretypeSomeHigherOrderFunction= int -> IDbConnection -> int
letsomeHigherOrderFunction:SomeHigherOrderFunction =
someHigherOrderFunction' addNumberFunc
When hovering over function parameters with a type signature such as below
You can see the tooltip shows us the alias of the type signature (AddNumberFunc). I would like to propose we add the ability for navigating the type signatures further so you don't have to leave your current spot in the code to read and understand the signature.
Ideas/Suggestions:
Create a 'mathetical proof' style signature. We'd have to account for type aliases for primitive types and other sorts of F# magic. Depending on the size of the 'proof' placing this under the 'Open the documentation' section may prove better. Maybe adding configuration of some sorts as well?
addNumberFunc : AddNumberFunc
addNumberFunc : int -> IDbConnection -> int
If this is found to be a reasonable idea/suggestion, I'd be willing to help contribute. I would just need guidance on areas of the codebase to search and refactor
Checklist
I have looked through existing issues to make sure that this feature has not been requested before
I have provided a descriptive title for this issue
I am aware that even valid feature requests may be rejected if they do not align with the project's goals
I or my company would be willing to contribute this feature
I agree this would be very nice to have but I think something like this should live in FSharp.Compiler.Service. If it's possible to prototype in FsAutocomplete, I'm for it but I get the feeling you'll hit some pain points and will have to push into FCS.
I also recall reading issues about this becoming extremely complicated as you can compound aliases:
typeFooer= string
typeMyFoo= int -> int
typeFooItAgain= MyFoo -> Task<Fooer>typeSlightlyDifferentFooIt= FooItAgain
I can't recall any direct issues about this from a quick search though.
Great feature request! Here's an updated look at what's needed, based on the current codebase.
Current behaviour
When you hover over addNumberFunc : AddNumberFunc, FSAC displays:
valaddNumberFunc:AddNumberFunc
The format function in DocumentationFormatter.fs formats AddNumberFunc using typ.TypeDefinition.DisplayName (because the alias HasTypeDefinition = true), so it shows the alias name — not the expanded form.
Why FCS changes aren't needed
@TheAngryByrd is right that resolving deep alias chains is complex, but the underlying FCS API already has what's needed:
FSharpType.IsAbbreviation — true when the type is an abbreviation
FSharpType.AbbreviatedType — the next level of the abbreviation chain (may itself be an abbreviation)
Recursive unwrapping is straightforward:
let recexpandAlias(t:FSharpType)=if t.IsAbbreviation then expandAlias t.AbbreviatedType else t
Implementation sketch
The best place to add this is in DocumentationFormatter.getValSignature and DocumentationFormatter.getFuncSignatureWithIdent:
After computing retType (e.g., "AddNumberFunc"), check if the underlying type is an abbreviation.
Recursively unwrap to get the expanded form.
If the expanded display differs from the alias display, append it as a comment line in the code block:
valaddNumberFunc:AddNumberFunc// = int -> IDbConnection -> int
For SymbolUse.Val, check v.FullType.IsAbbreviation.
For SymbolUse.Function and SymbolUse.ClosureOrNestedFunction, check func.ReturnParameter.Type.IsAbbreviation and/or func.FullType.IsAbbreviation for the non-curried case.
Caveats
The expansion appears inside a fsharp code block in the hover tooltip, so // = ... renders as a code comment — looks natural.
Deeply nested aliases (e.g., type Bar = Foo where type Foo = int -> string) are handled by the recursive unwrap loop.
The feature should be gated on a config option (e.g., fsharp.tooltips.expandTypeAliases: bool, defaulting to false) to avoid surprising users who prefer concise tooltips.
Repo Assist is looking into implementing this as a PR.
Activity
TheAngryByrd commentedon Nov 15, 2023
I agree this would be very nice to have but I think something like this should live in
FSharp.Compiler.Service. If it's possible to prototype inFsAutocomplete, I'm for it but I get the feeling you'll hit some pain points and will have to push into FCS.I also recall reading issues about this becoming extremely complicated as you can compound aliases:
I can't recall any direct issues about this from a quick search though.
1eyewonder commentedon Nov 15, 2023
Sounds good. I'll bring it up over there and see how plausible it is. I agree the compounding will be fun to say the least
nojaf commentedon Nov 16, 2023
Aren't tooltips in FSAC their own thing? I always thought you gents rolled your own thing for tooltips.
TheAngryByrd commentedon Nov 16, 2023
I think it's all the backing needed for it, like getting aliases of aliases and such. Like there's a bug about them: ionide/ionide-vscode-fsharp#1947
github-actions commentedon Apr 4, 2026
🤖 This is an automated response from Repo Assist.
Great feature request! Here's an updated look at what's needed, based on the current codebase.
Current behaviour
When you hover over
addNumberFunc : AddNumberFunc, FSAC displays:The
formatfunction inDocumentationFormatter.fsformatsAddNumberFuncusingtyp.TypeDefinition.DisplayName(because the aliasHasTypeDefinition = true), so it shows the alias name — not the expanded form.Why FCS changes aren't needed
@TheAngryByrdis right that resolving deep alias chains is complex, but the underlying FCS API already has what's needed:FSharpType.IsAbbreviation— true when the type is an abbreviationFSharpType.AbbreviatedType— the next level of the abbreviation chain (may itself be an abbreviation)Recursive unwrapping is straightforward:
Implementation sketch
The best place to add this is in
DocumentationFormatter.getValSignatureandDocumentationFormatter.getFuncSignatureWithIdent:retType(e.g.,"AddNumberFunc"), check if the underlying type is an abbreviation.For
SymbolUse.Val, checkv.FullType.IsAbbreviation.For
SymbolUse.FunctionandSymbolUse.ClosureOrNestedFunction, checkfunc.ReturnParameter.Type.IsAbbreviationand/orfunc.FullType.IsAbbreviationfor the non-curried case.Caveats
fsharpcode block in the hover tooltip, so// = ...renders as a code comment — looks natural.type Bar = Foowheretype Foo = int -> string) are handled by the recursive unwrap loop.fsharp.tooltips.expandTypeAliases: bool, defaulting tofalse) to avoid surprising users who prefer concise tooltips.Repo Assist is looking into implementing this as a PR.
feat: show type alias expansion in value/function hover tooltips (par…