Cherry-pick PR #33240 into release-3.6 (#33244)

Component commits:
339e1320c4 Bind typedef/enum on all assignment decl kinds
This fixes a crash on exports, but the code now handles all kinds
returned from getAssignmentDeclarationPropertyAccessKind.
This commit is contained in:
TypeScript Bot
2019-09-04 13:35:59 -07:00
committed by Nathan Shively-Sanders
parent 9cbb7ea29c
commit 49b910e4d4
7 changed files with 84 additions and 1 deletions

View File

@@ -1815,7 +1815,23 @@ namespace ts {
if (isTopLevel) {
bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel, !!findAncestor(declName, d => isPropertyAccessExpression(d) && d.name.escapedText === "prototype"));
const oldContainer = container;
container = isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name : declName.parent.expression;
switch (getAssignmentDeclarationPropertyAccessKind(declName.parent)) {
case AssignmentDeclarationKind.ExportsProperty:
case AssignmentDeclarationKind.ModuleExports:
container = file;
break;
case AssignmentDeclarationKind.ThisProperty:
container = declName.parent.expression;
break;
case AssignmentDeclarationKind.PrototypeProperty:
container = (declName.parent.expression as PropertyAccessExpression).name;
break;
case AssignmentDeclarationKind.Property:
container = isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name : declName.parent.expression;
break;
case AssignmentDeclarationKind.None:
return Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration");
}
declareModuleMember(typeAlias, SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes);
container = oldContainer;
}