import ts from 'typescript' ; import { Parameter } from '../Components/Parameter' ; import { ComponentFactory } from './ComponentFactory' ; export namespace ParameterFactory { export function create ( parameterSymbol , checker ) { const result = new Parameter ( parameterSymbol . getName ( ) ) ; const declarations = < ts . ParameterDeclaration [ ] > parameterSymbol . getDeclarations ( ) ; let declaration ; if ( declarations !== undefined ) { result . hasInitializer = ComponentFactory . hasInitializer ( declarations [ 0 ] ) ; result . isOptional = ComponentFactory . isOptional ( declarations [ 0 ] ) ; declaration = declarations [ 0 ] ; } result . parameterType = checker . typeToString ( checker . getTypeOfSymbolAtLocation ( parameterSymbol , parameterSymbol . valueDeclaration ) , declaration ) ; return result ; } }