mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-09 07:55:10 -05:00
Handel export default declaration completions
This commit is contained in:
@@ -2404,6 +2404,11 @@ module ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// If this is the default export, get the name of the declaration if it exists
|
||||
if (displayName === "default" && symbol.valueDeclaration && (symbol.valueDeclaration.flags & NodeFlags.Default) && symbol.valueDeclaration.localSymbol && symbol.valueDeclaration.localSymbol.name) {
|
||||
displayName = symbol.valueDeclaration.localSymbol.name;
|
||||
}
|
||||
|
||||
let firstCharCode = displayName.charCodeAt(0);
|
||||
// First check of the displayName is not external module; if it is an external module, it is not valid entry
|
||||
if ((symbol.flags & SymbolFlags.Namespace) && (firstCharCode === CharacterCodes.singleQuote || firstCharCode === CharacterCodes.doubleQuote)) {
|
||||
@@ -2620,7 +2625,7 @@ module ts {
|
||||
previousToken.getStart() :
|
||||
position;
|
||||
|
||||
let scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile);
|
||||
let scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile;
|
||||
|
||||
/// TODO filter meaning based on the current context
|
||||
let symbolMeanings = SymbolFlags.Type | SymbolFlags.Value | SymbolFlags.Namespace | SymbolFlags.Alias;
|
||||
|
||||
12
tests/cases/fourslash/exportDefaultClass.ts
Normal file
12
tests/cases/fourslash/exportDefaultClass.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
/// <reference path='./fourslash.ts'/>
|
||||
|
||||
////export default class C {
|
||||
//// method() { /*1*/ }
|
||||
////}
|
||||
//// /*2*/
|
||||
|
||||
goTo.marker('1');
|
||||
verify.completionListContains("C", "class C", /*documentation*/ undefined, "class");
|
||||
|
||||
goTo.marker('2');
|
||||
verify.completionListContains("C", "class C", /*documentation*/ undefined, "class");
|
||||
12
tests/cases/fourslash/exportDefaultFunction.ts
Normal file
12
tests/cases/fourslash/exportDefaultFunction.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
/// <reference path='./fourslash.ts'/>
|
||||
|
||||
////export default function func() {
|
||||
//// /*1*/
|
||||
////}
|
||||
//// /*2*/
|
||||
|
||||
goTo.marker('1');
|
||||
verify.completionListContains("func", "function func(): void", /*documentation*/ undefined, "function");
|
||||
|
||||
goTo.marker('2');
|
||||
verify.completionListContains("func", "function func(): void", /*documentation*/ undefined, "function");
|
||||
Reference in New Issue
Block a user