import * as ts from 'typescript' ; import { Scope } from '../../scope/scope' ; import { core } from '../../core/core' ; import { GetMockPropertiesFromSymbol } from '../mock/mockProperties' ; import { GetNullDescriptor } from '../null/null' ; import { GetDescriptor } from '../descriptor' ; export const GetVariableDeclarationDescriptor = ( node , scope ) => { const typeChecker = core . typeChecker ; const coreTs = core . ts ; if ( node . type ) { return GetDescriptor ( node . type , scope ) ; } const symbol = typeChecker . getSymbolAtLocation ( node . name ) ; if ( ! symbol ) { throw new Error ( `The type checker failed to look up a symbol for \`${ node . getText ( ) }'. 
        Perhaps, the checker was searching an outdated source.` ) ; } const type = typeChecker . getTypeOfSymbolAtLocation ( symbol , node ) ; const typeToNode = typeChecker . typeToTypeNode ( type , undefined , undefined ) ; if ( ! typeToNode ) { throw new Error ( `The type checker failed to look up a node for \`${ node . getText ( ) }'. 
        Perhaps, the checker was searching an outdated source.` ) ; } if ( coreTs . isTypeLiteralNode ( typeToNode ) ) { const properties = typeChecker . getPropertiesOfType ( type ) ; return GetMockPropertiesFromSymbol ( properties , [ ] , scope ) ; } if ( coreTs . isLiteralTypeNode ( typeToNode ) ) { return GetDescriptor ( typeToNode . literal , scope ) ; } return GetNullDescriptor ( ) ; } ;