Skip to content
Open
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
2 changes: 0 additions & 2 deletions internal/fourslash/_scripts/failingTests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,6 @@ TestQuickInfoJSDocFunctionThis
TestQuickInfoJsDocGetterSetterNoCrash1
TestQuickInfoJsdocTypedefMissingType
TestQuickInfoJSExport
TestQuickInfoMappedSpreadTypes
TestQuickInfoMappedType
TestQuickInfoMeaning
TestQuickInfoModuleVariables
Expand Down Expand Up @@ -409,7 +408,6 @@ TestQuickInfoTypeOfThisInStatics
TestQuickInfoTypeOnlyNamespaceAndClass
TestQuickInfoUnionOfNamespaces
TestQuickInfoUntypedModuleImport
TestQuickinfoWrongComment
TestRecursiveInternalModuleImport
TestRegexDetection
TestSelfReferencedExternalModule
Expand Down
37 changes: 37 additions & 0 deletions internal/fourslash/tests/hoverMappedTypePropertyJSDoc_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package fourslash_test

import (
"testing"

"github.com/microsoft/typescript-go/internal/fourslash"
"github.com/microsoft/typescript-go/internal/testutil"
)

func TestHoverMappedTypePropertyJSDoc(t *testing.T) {
t.Parallel()
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `
// @filename: a.ts
export declare const A: Readonly<{
/**
* x prop
*/
readonly X: 200;

/**
* y prop
*/
readonly Y: 201;
}>;

A.X/*1*/;

// @filename: b.ts
import { A } from './a';

A.X/*2*/;
`
f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content)
defer done()
f.VerifyBaselineHover(t)
}
2 changes: 1 addition & 1 deletion internal/ls/hover.go
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ func getQuickInfoAndDeclarationAtLocation(c *checker.Checker, symbol *ast.Symbol
writeTypeClassified(t, container, typeFormatFlags)
}
}
setDeclaration(symbol.ValueDeclaration)
setDeclaration(core.OrElse(symbol.ValueDeclaration, core.FirstOrNil(symbol.Declarations)))
Comment thread
a-tarasyuk marked this conversation as resolved.
}
if flags&ast.SymbolFlagsEnumMember != 0 {
writeNewLine()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// === QuickInfo ===
=== /a.ts ===
// export declare const A: Readonly<{
// /**
// * x prop
// */
// readonly X: 200;
//
// /**
// * y prop
// */
// readonly Y: 201;
// }>;
//
// A.X;
// ^
// | ----------------------------------------------------------------------
// | ```typescript
// | (property) X: 200
// | ```
// | x prop
// | ----------------------------------------------------------------------
//
=== /b.ts ===
// import { A } from './a';
//
// A.X;
// ^
// | ----------------------------------------------------------------------
// | ```typescript
// | (property) X: 200
// | ```
// | x prop
// | ----------------------------------------------------------------------
//


[
{
"marker": {
"Position": 130,
"LSPosition": {
"line": 12,
"character": 3
},
"Name": "1",
"Data": {}
},
"item": {
"contents": {
"kind": "markdown",
"value": "```typescript\n(property) X: 200\n```\nx prop"
},
"range": {
"start": {
"line": 12,
"character": 2
},
"end": {
"line": 12,
"character": 3
}
}
}
},
{
"marker": {
"Position": 29,
"LSPosition": {
"line": 2,
"character": 3
},
"Name": "2",
"Data": {}
},
"item": {
"contents": {
"kind": "markdown",
"value": "```typescript\n(property) X: 200\n```\nx prop"
},
"range": {
"start": {
"line": 2,
"character": 2
},
"end": {
"line": 2,
"character": 3
}
}
}
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
// | ```typescript
// | (property) language?: string | undefined
// | ```
// |
// | A language id, like `typescript`.
// | ----------------------------------------------------------------------
[
{
Expand All @@ -46,7 +46,7 @@
"item": {
"contents": {
"kind": "markdown",
"value": "```typescript\n(property) language?: string | undefined\n```\n"
"value": "```typescript\n(property) language?: string | undefined\n```\nA language id, like `typescript`."
},
"range": {
"start": {
Expand Down