mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 04:43:37 -05:00
Emit declaration if its identifier is used in export assignment of external module
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -601,6 +601,7 @@ module ts {
|
||||
getNodeCheckFlags(node: Node): NodeCheckFlags;
|
||||
getEnumMemberValue(node: EnumMember): number;
|
||||
shouldEmitDeclarations(): boolean;
|
||||
isReferencedInExportAssignment(node: Declaration): boolean;
|
||||
}
|
||||
|
||||
export enum SymbolFlags {
|
||||
|
||||
Reference in New Issue
Block a user