Fixed default import from export equals

(cherry picked from commit c4a10cfcdd)
This commit is contained in:
Bill Ticehurst
2016-03-09 19:13:14 -08:00
parent b760fc0ae0
commit 3ebf0fc383
8 changed files with 117 additions and 4 deletions
+1 -1
View File
@@ -278,7 +278,7 @@ namespace ts {
function declareSymbol(symbolTable: SymbolTable, parent: Symbol, node: Declaration, includes: SymbolFlags, excludes: SymbolFlags): Symbol {
Debug.assert(!hasDynamicName(node));
const isJsModuleExport = node.kind === SyntaxKind.BinaryExpression ? getSpecialPropertyAssignmentKind(node) === SpecialPropertyAssignmentKind.ModuleExports : false;
const isJsModuleExport = getSpecialPropertyAssignmentKind(node) === SpecialPropertyAssignmentKind.ModuleExports;
const isDefaultExport = node.flags & NodeFlags.Default;
// The exported symbol for an export default function/class node is always named "default"
+6 -3
View File
@@ -892,8 +892,12 @@ namespace ts {
function getTargetOfImportClause(node: ImportClause): Symbol {
const moduleSymbol = resolveExternalModuleName(node, (<ImportDeclaration>node.parent).moduleSpecifier);
if (moduleSymbol) {
const exportDefaultSymbol = resolveSymbol(moduleSymbol.exports["default"]);
const exportDefaultSymbol = moduleSymbol.exports["export="] ?
getPropertyOfType(getTypeOfSymbol(moduleSymbol.exports["export="]), "default") :
resolveSymbol(moduleSymbol.exports["default"]);
if (!exportDefaultSymbol && !allowSyntheticDefaultImports) {
error(node.name, Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol));
}
@@ -967,8 +971,7 @@ namespace ts {
let symbolFromVariable: Symbol;
// First check if module was specified with "export=". If so, get the member from the resolved type
if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports["export="]) {
const members = (getTypeOfSymbol(targetSymbol) as ResolvedType).members;
symbolFromVariable = members && members[name.text];
symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name.text);
}
else {
symbolFromVariable = getPropertyOfVariable(targetSymbol, name.text);
+3
View File
@@ -1105,6 +1105,9 @@ namespace ts {
/// Given a BinaryExpression, returns SpecialPropertyAssignmentKind for the various kinds of property
/// assignments we treat as special in the binder
export function getSpecialPropertyAssignmentKind(expression: Node): SpecialPropertyAssignmentKind {
if (!isInJavaScriptFile(expression)) {
return SpecialPropertyAssignmentKind.None;
}
if (expression.kind !== SyntaxKind.BinaryExpression) {
return SpecialPropertyAssignmentKind.None;
}