@@ -178,7 +178,26 @@ export default class PackageTypingsGenerator {
178178 private static _followAliases ( symbol : ts . Symbol , typeChecker : ts . TypeChecker ) : IFollowAliasesResult {
179179 let current : ts . Symbol = symbol ;
180180
181+ // Is it ambient? We will examine all of the declarations we encounter
182+ // to see if any of them contains the "export" keyword; if not, then it's ambient.
183+ let isAmbient : boolean = true ;
184+
181185 while ( true ) { // tslint:disable-line:no-constant-condition
186+
187+ for ( const declaration of current . declarations || [ ] ) {
188+ if ( declaration . kind === ts . SyntaxKind . ExportSpecifier
189+ || declaration . kind === ts . SyntaxKind . ExportAssignment ) {
190+ isAmbient = false ;
191+ break ;
192+ }
193+
194+ const modifiers : ts . ModifierFlags = ts . getCombinedModifierFlags ( declaration ) ;
195+ if ( modifiers & ( ts . ModifierFlags . Export | ts . ModifierFlags . ExportDefault ) ) {
196+ isAmbient = false ;
197+ break ;
198+ }
199+ }
200+
182201 if ( ! ( current . flags & ts . SymbolFlags . Alias ) ) {
183202 break ;
184203 }
@@ -228,17 +247,6 @@ export default class PackageTypingsGenerator {
228247 current = currentAlias ;
229248 }
230249
231- // Is it ambient? We examine all of the declarations to see if any of them contains
232- // the "export" keyword; if not, then it's ambient.
233- let isAmbient : boolean = true ;
234- for ( const declaration of current . declarations || [ ] ) {
235- const modifiers : ts . ModifierFlags = ts . getCombinedModifierFlags ( declaration ) ;
236- if ( modifiers & ( ts . ModifierFlags . Export | ts . ModifierFlags . ExportDefault ) ) {
237- isAmbient = false ;
238- break ;
239- }
240- }
241-
242250 return {
243251 symbol : current ,
244252 importPackagePath : undefined ,
0 commit comments