import ts from 'typescript' ; import { Interface } from '../Components/Interface' ; import { ComponentFactory } from './ComponentFactory' ; export namespace InterfaceFactory { export function create ( interfaceSymbol , checker ) { const result = new Interface ( interfaceSymbol . getName ( ) ) ; const declaration = < ts . InterfaceDeclaration [ ] | undefined > interfaceSymbol . getDeclarations ( ) ; if ( interfaceSymbol . members !== undefined ) { result . members = ComponentFactory . serializeMethods ( interfaceSymbol . members , checker ) ; result . typeParameters = ComponentFactory . serializeTypeParameters ( interfaceSymbol . members , checker ) ; } if ( declaration !== undefined && declaration . length > 0 ) { const heritageClauses = declaration [ declaration . length - 1 ] . heritageClauses ; if ( heritageClauses !== undefined ) { heritageClauses . forEach ( ( heritageClause ) : void => { if ( heritageClause . token === ts . SyntaxKind . ExtendsKeyword ) { result . extendsInterface = ComponentFactory . getExtendsHeritageClauseNames ( heritageClause ) ; } } ) ; } } return result ; } }