@@ -14,6 +14,7 @@ import { DeclarationMetadata } from '../collector/DeclarationMetadata';
14
14
import { SymbolMetadata } from '../collector/SymbolMetadata' ;
15
15
import { ReleaseTag } from '../aedoc/ReleaseTag' ;
16
16
import { Text , InternalError } from '@microsoft/node-core-library' ;
17
+ import { AstImport } from '../analyzer/AstImport' ;
17
18
18
19
export class ReviewFileGenerator {
19
20
/**
@@ -35,15 +36,31 @@ export class ReviewFileGenerator {
35
36
36
37
for ( const entity of collector . entities ) {
37
38
if ( entity . exported ) {
38
- // Emit all the declarations for this entry
39
- for ( const astDeclaration of entity . astSymbol . astDeclarations || [ ] ) {
39
+ if ( ! entity . astSymbol . astImport ) {
40
+ // Emit all the declarations for this entry
41
+ for ( const astDeclaration of entity . astSymbol . astDeclarations || [ ] ) {
40
42
41
- output . append ( ReviewFileGenerator . _getAedocSynopsis ( collector , astDeclaration ) ) ;
43
+ output . append ( ReviewFileGenerator . _getAedocSynopsis ( collector , astDeclaration ) ) ;
42
44
43
- const span : Span = new Span ( astDeclaration . declaration ) ;
44
- ReviewFileGenerator . _modifySpan ( collector , span , entity , astDeclaration ) ;
45
- span . writeModifiedText ( output ) ;
46
- output . append ( '\n\n' ) ;
45
+ const span : Span = new Span ( astDeclaration . declaration ) ;
46
+ ReviewFileGenerator . _modifySpan ( collector , span , entity , astDeclaration ) ;
47
+ span . writeModifiedText ( output ) ;
48
+ output . append ( '\n\n' ) ;
49
+ }
50
+ } else {
51
+ // This definition is reexported from another package, so write it as an "export" line
52
+ // In general, we don't report on external packages; if that's important we assume API Extractor
53
+ // would be enabled for the upstream project. But see GitHub issue #896 for a possible exception.
54
+ const astImport : AstImport = entity . astSymbol . astImport ;
55
+
56
+ if ( astImport . exportName === '*' ) {
57
+ output . append ( `export * as ${ entity . nameForEmit } ` ) ;
58
+ } else if ( entity . nameForEmit !== astImport . exportName ) {
59
+ output . append ( `export { ${ astImport . exportName } as ${ entity . nameForEmit } }` ) ;
60
+ } else {
61
+ output . append ( `export { ${ astImport . exportName } }` ) ;
62
+ }
63
+ output . append ( ` from '${ astImport . modulePath } ';\n` ) ;
47
64
}
48
65
}
49
66
}
0 commit comments