Skip to content

Commit 383f01d

Browse files
committed
Handel export default declaration completions
1 parent bea7221 commit 383f01d

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

src/services/services.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2404,6 +2404,11 @@ module ts {
24042404
return undefined;
24052405
}
24062406

2407+
// If this is the default export, get the name of the declaration if it exists
2408+
if (displayName === "default" && symbol.valueDeclaration && (symbol.valueDeclaration.flags & NodeFlags.Default) && symbol.valueDeclaration.localSymbol && symbol.valueDeclaration.localSymbol.name) {
2409+
displayName = symbol.valueDeclaration.localSymbol.name;
2410+
}
2411+
24072412
let firstCharCode = displayName.charCodeAt(0);
24082413
// First check of the displayName is not external module; if it is an external module, it is not valid entry
24092414
if ((symbol.flags & SymbolFlags.Namespace) && (firstCharCode === CharacterCodes.singleQuote || firstCharCode === CharacterCodes.doubleQuote)) {
@@ -2620,7 +2625,7 @@ module ts {
26202625
previousToken.getStart() :
26212626
position;
26222627

2623-
let scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile);
2628+
let scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile;
26242629

26252630
/// TODO filter meaning based on the current context
26262631
let symbolMeanings = SymbolFlags.Type | SymbolFlags.Value | SymbolFlags.Namespace | SymbolFlags.Alias;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/// <reference path='./fourslash.ts'/>
2+
3+
////export default class C {
4+
//// method() { /*1*/ }
5+
////}
6+
//// /*2*/
7+
8+
goTo.marker('1');
9+
verify.completionListContains("C", "class C", /*documentation*/ undefined, "class");
10+
11+
goTo.marker('2');
12+
verify.completionListContains("C", "class C", /*documentation*/ undefined, "class");
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/// <reference path='./fourslash.ts'/>
2+
3+
////export default function func() {
4+
//// /*1*/
5+
////}
6+
//// /*2*/
7+
8+
goTo.marker('1');
9+
verify.completionListContains("func", "function func(): void", /*documentation*/ undefined, "function");
10+
11+
goTo.marker('2');
12+
verify.completionListContains("func", "function func(): void", /*documentation*/ undefined, "function");

0 commit comments

Comments
 (0)