import { Class } from '../utils/Class' ; param component param createIfNotExists export function getComponentId < T > ( component , createIfNotExists = false ) { if ( component . hasOwnProperty ( COMPONENT_CLASS_ID ) ) { return ( component as ComponentId < T > ) [ COMPONENT_CLASS_ID ] ; } else if ( createIfNotExists ) { return ( component as ComponentId < T > ) [ COMPONENT_CLASS_ID ] = componentClassId ++ ; } return undefined ; } internal export function getComponentClass < T extends K , K > ( component , resolveClass ? ) { let componentClass = Object . getPrototypeOf ( component ) . constructor as Class < T > ; if ( resolveClass ) { if ( ! ( component instanceof resolveClass || componentClass === resolveClass ) ) { throw new Error ( 'Resolve class should be an ancestor of component class' ) ; } componentClass = resolveClass as Class < T > ; } return componentClass ; } let COMPONENT_CLASS_ID = '__componentClassId__' ; let componentClassId = 1 ; type ComponentId < T > = Class < T > & { [ key ] : number ; } ;