Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions internal/fourslash/_scripts/failingTests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,6 @@ TestQuickInfoForTypeParameterInTypeAlias1
TestQuickInfoForTypeParameterInTypeAlias2
TestQuickInfoForTypeofParameter
TestQuickInfoForUMDModuleAlias
TestQuickInfoFromContextualType
TestQuickInfoFunctionKeyword
TestQuickInfoGenerics
TestQuickInfoGetterSetter
Expand All @@ -471,7 +470,6 @@ TestQuickInfoJsDocNonDiscriminatedUnionSharedProp
TestQuickInfoJsdocTypedefMissingType
TestQuickInfoMappedSpreadTypes
TestQuickInfoMappedType
TestQuickInfoMappedTypeMethods
TestQuickInfoMappedTypeRecursiveInference
TestQuickInfoModuleVariables
TestQuickInfoNarrowedTypeOfAliasSymbol
Expand Down Expand Up @@ -526,7 +524,6 @@ TestQuickInfoTypeError
TestQuickInfoTypeOfThisInStatics
TestQuickInfoTypeOnlyNamespaceAndClass
TestQuickInfoUnionOfNamespaces
TestQuickInfoUnion_discriminated
TestQuickInfoWidenedTypes
TestQuickInfo_notInsideComment
TestQuickInforForSucessiveInferencesIsNotAny
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

func TestQuickInfoFromContextualType(t *testing.T) {
t.Parallel()
t.Skip()

defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `// @Filename: quickInfoExportAssignmentOfGenericInterface_0.ts
interface I {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

func TestQuickInfoMappedTypeMethods(t *testing.T) {
t.Parallel()
t.Skip()

defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `type M = { [K in 'one']: any };
const x: M = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

func TestQuickInfoUnion_discriminated(t *testing.T) {
t.Parallel()
t.Skip()

defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `// @Filename: quickInfoJsDocTags.ts
type U = A | B;
Expand Down
14 changes: 13 additions & 1 deletion internal/ls/hover.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ func (l *LanguageService) ProvideHover(ctx context.Context, documentURI lsproto.
c, done := program.GetTypeCheckerForFile(ctx, file)
defer done()
rangeNode := getNodeForQuickInfo(node)
quickInfo, documentation := l.getQuickInfoAndDocumentationForSymbol(c, c.GetSymbolAtLocation(node), rangeNode, contentFormat)
symbol := getSymbolAtLocationForQuickInfo(c, node)
quickInfo, documentation := l.getQuickInfoAndDocumentationForSymbol(c, symbol, rangeNode, contentFormat)
if quickInfo == "" {
return lsproto.HoverOrNull{}, nil
}
Expand Down Expand Up @@ -282,6 +283,17 @@ func getNodeForQuickInfo(node *ast.Node) *ast.Node {
return node
}

func getSymbolAtLocationForQuickInfo(c *checker.Checker, node *ast.Node) *ast.Symbol {
if objectElement := getContainingObjectLiteralElement(node); objectElement != nil {
if contextualType := c.GetContextualType(objectElement.Parent, checker.ContextFlagsNone); contextualType != nil {
if properties := c.GetPropertySymbolsFromContextualType(objectElement, contextualType, false /*unionSymbolOk*/); len(properties) == 1 {
return properties[0]
}
}
}
return c.GetSymbolAtLocation(node)
}

func inConstructorContext(node *ast.Node) bool {
if node.Kind == ast.KindConstructorKeyword {
return true
Expand Down