import * as ts from 'typescript' ; export function isExpectedIdentifierVariableStatement ( identifier ) { return ( node ) => { let res = false ; node . forEachChild ( child => { if ( ts . isVariableDeclarationList ( child ) ) { child . forEachChild ( child => { if ( ts . isVariableDeclaration ( child ) ) { if ( ts . isIdentifier ( child . name ) ) { res = child . name . text === identifier ; } } } ) ; } } ) ; return res ; } ; } export function getVariableDeclarationFromVariableStatement ( node ) { let decl = null ; node . forEachChild ( child => { if ( ts . isVariableDeclarationList ( child ) ) { child . forEachChild ( child => { if ( ts . isVariableDeclaration ( child ) ) { decl = child ; } } ) ; } } ) ; return decl ; } export function getMethodNamesFromVariableDeclaration ( node ) { const names = [ ] ; if ( ! node ) return names ; if ( ! ts . isIdentifier ( node . name ) ) return names ; node . forEachChild ( child => { if ( ts . isObjectLiteralExpression ( child ) ) { child . forEachChild ( child => { if ( ts . isMethodDeclaration ( child ) || ts . isPropertyAssignment ( child ) ) { if ( ts . isIdentifier ( child . name ) ) { names . push ( child . name . text ) ; } } } ) ; } } ) ; return names ; }