Completion for default export should be '.default' (#16742)

* Completion for default export should be '.default'

* Don't include empty string in name table

* getSymbolsInScope() should return local symbols, not exported symbols

* Fix bug: getSymbolAtLocation should work for local symbol too
This commit is contained in:
Andy
2017-07-11 07:23:32 -07:00
committed by GitHub
parent a94e0c36b0
commit aa2d1008bf
20 changed files with 200 additions and 158 deletions

View File

@@ -11875,6 +11875,8 @@ namespace ts {
}
function getTypeOfSymbolAtLocation(symbol: Symbol, location: Node) {
symbol = symbol.exportSymbol || symbol;
// If we have an identifier or a property access at the given location, if the location is
// an dotted name expression, and if the location is not an assignment target, obtain the type
// of the expression (which will reflect control flow analysis). If the expression indeed
@@ -22281,11 +22283,6 @@ namespace ts {
}
switch (location.kind) {
case SyntaxKind.SourceFile:
if (!isExternalOrCommonJsModule(<SourceFile>location)) {
break;
}
// falls through
case SyntaxKind.ModuleDeclaration:
copySymbols(getSymbolOfNode(location).exports, meaning & SymbolFlags.ModuleMember);
break;
@@ -22337,7 +22334,7 @@ namespace ts {
* @param meaning meaning of symbol to filter by before adding to symbol table
*/
function copySymbol(symbol: Symbol, meaning: SymbolFlags): void {
if (symbol.flags & meaning) {
if (getCombinedLocalAndExportSymbolFlags(symbol) & meaning) {
const id = symbol.name;
// We will copy all symbol regardless of its reserved name because
// symbolsToArray will check whether the key is a reserved name and

View File

@@ -3598,6 +3598,11 @@ namespace ts {
}
return previous[previous.length - 1];
}
/** See comment on `declareModuleMember` in `binder.ts`. */
export function getCombinedLocalAndExportSymbolFlags(symbol: Symbol): SymbolFlags {
return symbol.exportSymbol ? symbol.exportSymbol.flags | symbol.flags : symbol.flags;
}
}
namespace ts {