mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Dts for export * from "mod" and export { a, b as c,...} [from "mod"]
This commit is contained in:
+10
-4
@@ -1723,12 +1723,18 @@ module ts {
|
||||
}
|
||||
|
||||
function setDeclarationsOfIdentifierAsVisible(node: Identifier): Node[]{
|
||||
var exportSymbol: Symbol;
|
||||
if (node.parent && node.parent.kind === SyntaxKind.ExportAssignment) {
|
||||
var exportSymbol = resolveName(node.parent, node.text, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace, Diagnostics.Cannot_find_name_0, node);
|
||||
var result: Node[] = [];
|
||||
buildVisibleNodeList(exportSymbol.declarations);
|
||||
return result;
|
||||
exportSymbol = resolveName(node.parent, node.text, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace, Diagnostics.Cannot_find_name_0, node);
|
||||
}
|
||||
else if (node.parent.kind === SyntaxKind.ExportSpecifier) {
|
||||
exportSymbol = getTargetOfExportSpecifier(<ExportSpecifier>node.parent);
|
||||
}
|
||||
var result: Node[] = [];
|
||||
if (exportSymbol) {
|
||||
buildVisibleNodeList(exportSymbol.declarations);
|
||||
}
|
||||
return result;
|
||||
|
||||
function buildVisibleNodeList(declarations: Declaration[]) {
|
||||
forEach(declarations, declaration => {
|
||||
|
||||
+33
-2
@@ -905,7 +905,7 @@ module ts {
|
||||
}
|
||||
else {
|
||||
write("{ ");
|
||||
emitCommaList((<NamedImports>node.importClause.namedBindings).elements, emitImportSpecifier, resolver.isDeclarationVisible);
|
||||
emitCommaList((<NamedImports>node.importClause.namedBindings).elements, emitImportOrExportSpecifier, resolver.isDeclarationVisible);
|
||||
write(" }");
|
||||
}
|
||||
}
|
||||
@@ -916,7 +916,7 @@ module ts {
|
||||
writer.writeLine();
|
||||
}
|
||||
|
||||
function emitImportSpecifier(node: ImportSpecifier) {
|
||||
function emitImportOrExportSpecifier(node: ImportOrExportSpecifier) {
|
||||
if (node.propertyName) {
|
||||
writeTextOfNode(currentSourceFile, node.propertyName);
|
||||
write(" as ");
|
||||
@@ -924,6 +924,35 @@ module ts {
|
||||
writeTextOfNode(currentSourceFile, node.name);
|
||||
}
|
||||
|
||||
function emitExportSpecifier(node: ExportSpecifier) {
|
||||
emitImportOrExportSpecifier(node);
|
||||
|
||||
// Make all the declarations visible for the export name
|
||||
var nodes = resolver.setDeclarationsOfIdentifierAsVisible(node.propertyName || node.name);
|
||||
|
||||
// write each of these declarations asynchronously
|
||||
writeAsynchronousModuleElements(nodes);
|
||||
}
|
||||
|
||||
function emitExportDeclaration(node: ExportDeclaration) {
|
||||
emitJsDocComments(node);
|
||||
write("export ");
|
||||
if (node.exportClause) {
|
||||
write("{ ");
|
||||
emitCommaList(node.exportClause.elements, emitExportSpecifier);
|
||||
write(" }");
|
||||
}
|
||||
else {
|
||||
write("*");
|
||||
}
|
||||
if (node.moduleSpecifier) {
|
||||
write(" from ");
|
||||
writeTextOfNode(currentSourceFile, node.moduleSpecifier);
|
||||
}
|
||||
write(";");
|
||||
writer.writeLine();
|
||||
}
|
||||
|
||||
function writeModuleDeclaration(node: ModuleDeclaration) {
|
||||
emitJsDocComments(node);
|
||||
emitModuleElementDeclarationFlags(node);
|
||||
@@ -1608,6 +1637,8 @@ module ts {
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
// Import declaration without import clause is visible, otherwise it is not visible
|
||||
return emitModuleElement(node, /*isModuleElementVisible*/!(<ImportDeclaration>node).importClause);
|
||||
case SyntaxKind.ExportDeclaration:
|
||||
return emitExportDeclaration(<ExportDeclaration>node);
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
|
||||
Reference in New Issue
Block a user