mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Fixed default import from export equals
(cherry picked from commit c4a10cfcdd)
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user