Skip to content

Commit 807ee7f

Browse files
authored
Set UseAliasDefinedOutsideCurrentScope in hover (#1516)
1 parent 2c67ab1 commit 807ee7f

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package fourslash_test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/microsoft/typescript-go/internal/fourslash"
7+
"github.com/microsoft/typescript-go/internal/testutil"
8+
)
9+
10+
func TestHoverAliasInImportedFile(t *testing.T) {
11+
t.Parallel()
12+
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
13+
const content = `
14+
// @filename: other2.ts
15+
export type SomeAliasType<T> = { value: T };
16+
17+
// @filename: other.ts
18+
import { SomeAliasType } from './other2';
19+
20+
declare function isSomeAliasType(x: any): x is SomeAliasType<any>;
21+
22+
export { isSomeAliasType };
23+
24+
// @filename: main.ts
25+
import { isSomeAliasType } from './other';
26+
27+
export function processValue(value: any) {
28+
if (/*1*/isSomeAliasType(value)) {
29+
console.log("ok");
30+
}
31+
}
32+
`
33+
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
34+
f.VerifyQuickInfoAt(t, "1", "(alias) function isSomeAliasType(x: any): x is SomeAliasType<any>", "")
35+
}

internal/ls/hover.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515

1616
const (
1717
symbolFormatFlags = checker.SymbolFormatFlagsWriteTypeParametersOrArguments | checker.SymbolFormatFlagsUseOnlyExternalAliasing | checker.SymbolFormatFlagsAllowAnyNodeKind | checker.SymbolFormatFlagsUseAliasDefinedOutsideCurrentScope
18-
typeFormatFlags = checker.TypeFormatFlagsNone
18+
typeFormatFlags = checker.TypeFormatFlagsUseAliasDefinedOutsideCurrentScope
1919
)
2020

2121
func (l *LanguageService) ProvideHover(ctx context.Context, documentURI lsproto.DocumentUri, position lsproto.Position) (lsproto.HoverResponse, error) {

0 commit comments

Comments
 (0)