diff --git a/internal/fourslash/_scripts/failingTests.txt b/internal/fourslash/_scripts/failingTests.txt index 7e671cbede..a54667b7b0 100644 --- a/internal/fourslash/_scripts/failingTests.txt +++ b/internal/fourslash/_scripts/failingTests.txt @@ -454,7 +454,6 @@ TestQuickInfoForTypeParameterInTypeAlias1 TestQuickInfoForTypeParameterInTypeAlias2 TestQuickInfoForTypeofParameter TestQuickInfoForUMDModuleAlias -TestQuickInfoFromContextualType TestQuickInfoFunctionKeyword TestQuickInfoGenerics TestQuickInfoGetterSetter @@ -471,7 +470,6 @@ TestQuickInfoJsDocNonDiscriminatedUnionSharedProp TestQuickInfoJsdocTypedefMissingType TestQuickInfoMappedSpreadTypes TestQuickInfoMappedType -TestQuickInfoMappedTypeMethods TestQuickInfoMappedTypeRecursiveInference TestQuickInfoModuleVariables TestQuickInfoNarrowedTypeOfAliasSymbol @@ -526,7 +524,6 @@ TestQuickInfoTypeError TestQuickInfoTypeOfThisInStatics TestQuickInfoTypeOnlyNamespaceAndClass TestQuickInfoUnionOfNamespaces -TestQuickInfoUnion_discriminated TestQuickInfoWidenedTypes TestQuickInfo_notInsideComment TestQuickInforForSucessiveInferencesIsNotAny diff --git a/internal/fourslash/tests/gen/quickInfoFromContextualType_test.go b/internal/fourslash/tests/gen/quickInfoFromContextualType_test.go index cffaadcafc..7ce07026be 100644 --- a/internal/fourslash/tests/gen/quickInfoFromContextualType_test.go +++ b/internal/fourslash/tests/gen/quickInfoFromContextualType_test.go @@ -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 { diff --git a/internal/fourslash/tests/gen/quickInfoMappedTypeMethods_test.go b/internal/fourslash/tests/gen/quickInfoMappedTypeMethods_test.go index aa599f2a08..60a3ef6150 100644 --- a/internal/fourslash/tests/gen/quickInfoMappedTypeMethods_test.go +++ b/internal/fourslash/tests/gen/quickInfoMappedTypeMethods_test.go @@ -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 = { diff --git a/internal/fourslash/tests/gen/quickInfoUnion_discriminated_test.go b/internal/fourslash/tests/gen/quickInfoUnion_discriminated_test.go index db39343a15..f4fbac65dc 100644 --- a/internal/fourslash/tests/gen/quickInfoUnion_discriminated_test.go +++ b/internal/fourslash/tests/gen/quickInfoUnion_discriminated_test.go @@ -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; diff --git a/internal/ls/hover.go b/internal/ls/hover.go index 6d5dffee0d..808efe7dbf 100644 --- a/internal/ls/hover.go +++ b/internal/ls/hover.go @@ -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 } @@ -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