From e34d2ca94b5e5be4355ef2cd61e557dfdf54199a Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 25 Oct 2025 11:06:39 -0700 Subject: [PATCH] Properly handle hovering on `this` --- internal/ls/hover.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/ls/hover.go b/internal/ls/hover.go index d432908aa7..d6337b7838 100644 --- a/internal/ls/hover.go +++ b/internal/ls/hover.go @@ -108,6 +108,10 @@ func formatQuickInfo(quickInfo string) string { } func getQuickInfoAndDeclarationAtLocation(c *checker.Checker, symbol *ast.Symbol, node *ast.Node) (string, *ast.Node) { + container := getContainerNode(node) + if node.Kind == ast.KindThisKeyword && ast.IsInExpressionContext(node) { + return c.TypeToStringEx(c.GetTypeAtLocation(node), container, typeFormatFlags), nil + } isAlias := symbol != nil && symbol.Flags&ast.SymbolFlagsAlias != 0 if isAlias { symbol = c.GetAliasedSymbol(symbol) @@ -129,7 +133,6 @@ func getQuickInfoAndDeclarationAtLocation(c *checker.Checker, symbol *ast.Symbol // If the symbol has a type meaning and we're in a type context, remove value-only meanings flags &^= ast.SymbolFlagsVariable | ast.SymbolFlagsFunction } - container := getContainerNode(node) var b strings.Builder if isAlias { b.WriteString("(alias) ")