import ts from 'typescript' ; import * as guards from './guards' ; import * as node_ from './node' ; import * as utils from './utils' ; export function isAmbientNode ( node ) { const ambient = ( ts . getCombinedModifierFlags ( node ) & ts . ModifierFlags . Ambient ) === ts . ModifierFlags . Ambient ; return ambient || ts . isInterfaceDeclaration ( node ) || ts . isTypeAliasDeclaration ( node ) ; } export function isAmbient ( node ) { if ( isAmbientNode ( node ) || node . getSourceFile ( ) . isDeclarationFile ) { return true ; } for ( const ancestor of node_ . getAncestors ( node ) ) { if ( guards . isDeclaration ( ancestor ) && isAmbientNode ( ancestor ) ) { return true ; } } return false ; } export function getReturnTypeNode ( node ) { return utils . getValueOrUndefined ( node . type ) ; }