Skip to content

Commit 3715af1

Browse files
committed
Show call and construct signatures when using aliases
1 parent 471d80d commit 3715af1

File tree

2 files changed

+38
-4
lines changed

2 files changed

+38
-4
lines changed

src/services/services.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2749,7 +2749,7 @@ module ts {
27492749
var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, symbolFlags);
27502750
var hasAddedSymbolInfo: boolean;
27512751
// Class at constructor site need to be shown as constructor apart from property,method, vars
2752-
if (symbolKind !== ScriptElementKind.unknown || symbolFlags & SymbolFlags.Signature || symbolFlags & SymbolFlags.Class) {
2752+
if (symbolKind !== ScriptElementKind.unknown || symbolFlags & SymbolFlags.Class || symbolFlags & SymbolFlags.Import) {
27532753
// If it is accessor they are allowed only if location is at name of the accessor
27542754
if (symbolKind === ScriptElementKind.memberGetAccessorElement || symbolKind === ScriptElementKind.memberSetAccessorElement) {
27552755
symbolKind = ScriptElementKind.memberVariableElement;
@@ -2790,6 +2790,18 @@ module ts {
27902790
symbolKind = ScriptElementKind.constructorImplementationElement;
27912791
addPrefixForAnyFunctionOrVar(type.symbol, symbolKind);
27922792
}
2793+
else if (symbolFlags & SymbolFlags.Import) {
2794+
symbolKind = ScriptElementKind.alias;
2795+
displayParts.push(punctuationPart(SyntaxKind.OpenParenToken));
2796+
displayParts.push(textPart(symbolKind));
2797+
displayParts.push(punctuationPart(SyntaxKind.CloseParenToken));
2798+
displayParts.push(spacePart());
2799+
if (useConstructSignatures) {
2800+
displayParts.push(keywordPart(SyntaxKind.NewKeyword));
2801+
displayParts.push(spacePart());
2802+
}
2803+
addFullSymbolName(symbol);
2804+
}
27932805
else {
27942806
addPrefixForAnyFunctionOrVar(symbol, symbolKind);
27952807
}

tests/cases/fourslash/quickInfoOnInternalAliases.ts

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,16 @@
88
//// export class /*1*/c {
99
//// };
1010
//// }
11+
//// export function foo() {
12+
//// }
1113
////}
1214
/////**This is on import declaration*/
1315
////import /*2*/internalAlias = m1.m2./*3*/c;
1416
////var /*4*/newVar = new /*5*/internalAlias();
1517
////var /*6*/anotherAliasVar = /*7*/internalAlias;
16-
18+
////import /*8*/internalFoo = m1./*9*/foo;
19+
////var /*10*/callVar = /*11*/internalFoo();
20+
////var /*12*/anotherAliasFoo = /*13*/internalFoo;
1721

1822
goTo.marker('1');
1923
verify.quickInfoIs("class m1.m2.c", "class comment;");
@@ -28,10 +32,28 @@ goTo.marker('4');
2832
verify.quickInfoIs("(var) newVar: internalAlias", "");
2933

3034
goTo.marker('5');
31-
verify.quickInfoIs("import internalAlias = m1.m2.c", "This is on import declaration");
35+
verify.quickInfoIs("(alias) new internalAlias(): internalAlias\nimport internalAlias = m1.m2.c", "");
3236

3337
goTo.marker('6');
3438
verify.quickInfoIs("(var) anotherAliasVar: typeof internalAlias", "");
3539

3640
goTo.marker('7');
37-
verify.quickInfoIs("import internalAlias = m1.m2.c", "This is on import declaration");
41+
verify.quickInfoIs("import internalAlias = m1.m2.c", "This is on import declaration");
42+
43+
goTo.marker('8');
44+
verify.quickInfoIs('import internalFoo = m1.foo', "");
45+
46+
goTo.marker('9');
47+
verify.quickInfoIs("(function) m1.foo(): void", "");
48+
49+
goTo.marker('10');
50+
verify.quickInfoIs("(var) callVar: void", "");
51+
52+
goTo.marker('11');
53+
verify.quickInfoIs("(alias) internalFoo(): void\nimport internalFoo = m1.foo", "");
54+
55+
goTo.marker('12');
56+
verify.quickInfoIs("(var) anotherAliasFoo: () => void", "");
57+
58+
goTo.marker('13');
59+
verify.quickInfoIs("import internalFoo = m1.foo", "");

0 commit comments

Comments
 (0)