@@ -128,7 +128,12 @@ export default class DtsGenerator {
128128 private _fetchEntryForSymbol ( symbol : ts . Symbol ) : Entry {
129129 const followedSymbol : ts . Symbol = DtsGenerator . _followAliases ( symbol , this . _typeChecker ) ;
130130
131- const entry : Entry = this . _createEntry ( symbol . name , followedSymbol ) ;
131+ let entry : Entry = this . _entriesBySymbol . get ( followedSymbol ) ;
132+ if ( entry ) {
133+ return entry ;
134+ }
135+
136+ entry = this . _createEntry ( symbol . name , followedSymbol ) ;
132137
133138 for ( const declaration of followedSymbol . declarations ) {
134139 console . log ( PrettyPrinter . dumpTree ( declaration ) ) ;
@@ -144,6 +149,7 @@ export default class DtsGenerator {
144149 this . _processInterfaceDeclaration ( entry , declaration as ts . InterfaceDeclaration ) ;
145150 break ;
146151 }
152+
147153 }
148154
149155 return entry ;
@@ -158,11 +164,13 @@ export default class DtsGenerator {
158164 const interfaceDts : dts . InterfaceDeclaration = dts . create . interface ( entry . localName ) ;
159165 entry . dtsDeclarations . push ( interfaceDts ) ;
160166
161- const type : ts . Type = this . _typeChecker . getTypeAtLocation ( declaration ) ;
162- const baseTypes : ts . TypeReference [ ] = type . getBaseTypes ( ) as ts . TypeReference [ ] ;
163- for ( const baseType of baseTypes ) {
164- const baseDts : dts . NamedTypeReference = this . _getTypeReferenceDts ( baseType ) ;
165- interfaceDts . baseTypes . push ( baseDts ) ;
167+ for ( const heritageClause of declaration . heritageClauses || [ ] ) {
168+ for ( const baseTypeDeclaration of heritageClause . types || [ ] ) {
169+ const baseType : ts . TypeReference = this . _typeChecker . getTypeAtLocation (
170+ baseTypeDeclaration ) as ts . TypeReference ;
171+ const baseDts : dts . NamedTypeReference = this . _getTypeReferenceDts ( baseType ) ;
172+ interfaceDts . baseTypes . push ( baseDts ) ;
173+ }
166174 }
167175 }
168176
0 commit comments