Emit declaration if its identifier is used in export assignment of external module

This commit is contained in:
Sheetal Nandi
2014-07-11 14:35:10 -07:00
parent ea7c23eb63
commit 063399d228
11 changed files with 67 additions and 9 deletions

View File

@@ -5706,6 +5706,22 @@ module ts {
return false;
}
function isReferencedInExportAssignment(node: Declaration): boolean {
var exportAssignedSymbol = getExportAssignmentSymbol(getSymbolOfNode(node.parent));
if (exportAssignedSymbol) {
var symbol = getSymbolOfNode(node);
if (exportAssignedSymbol === symbol) {
// This symbol was export assigned symbol
return true;
}
// TODO(shkamat): if export assignment is alias, the alias target would make the node as referenced in export assignment
}
return false;
}
function getNodeCheckFlags(node: Node): NodeCheckFlags {
return getNodeLinks(node).flags;
}
@@ -5725,7 +5741,8 @@ module ts {
getNodeCheckFlags: getNodeCheckFlags,
getEnumMemberValue: getEnumMemberValue,
isTopLevelValueImportedViaEntityName: isTopLevelValueImportedViaEntityName,
shouldEmitDeclarations: shouldEmitDeclarations
shouldEmitDeclarations: shouldEmitDeclarations,
isReferencedInExportAssignment: isReferencedInExportAssignment
};
checkProgram();
return emitFiles(resolver);

View File

@@ -1922,16 +1922,13 @@ module ts {
return true;
}
if (node.parent.kind === SyntaxKind.SourceFile) {
// Global context nodes - emit this declaration
if (!(node.parent.flags & NodeFlags.ExternalModule)) {
return true;
}
// If this node is in external module, check if this is export assigned
if (node.parent.flags & NodeFlags.ExternalModule) {
return resolver.isReferencedInExportAssignment(node);
}
// TODO(shkamat): check if this node is part of export assignment in the external module
return false;
// emit the declaration if this is global source file
return node.parent.kind === SyntaxKind.SourceFile;
}
function emitDeclarationFlags(node: Declaration) {

View File

@@ -601,6 +601,7 @@ module ts {
getNodeCheckFlags(node: Node): NodeCheckFlags;
getEnumMemberValue(node: EnumMember): number;
shouldEmitDeclarations(): boolean;
isReferencedInExportAssignment(node: Declaration): boolean;
}
export enum SymbolFlags {