import { compileSpecs , TypeSpecs } from './typeSpecs' ; import { tools } from 'type-r' ; import { ComponentClass } from './common' ; export interface ContextDefinition { context : TypeSpecs ; childContext : TypeSpecs ; } export interface ContextProto { _context : TypeSpecs ; _childContext : TypeSpecs ; } export default function onDefine ( this , { context , childContext } , BaseClass ) { const { prototype } = this ; if ( context ) { prototype . _context = tools . defaults ( context , BaseClass . prototype . _context || { } ) ; this . contextTypes = compileSpecs ( context ) . propTypes ; } if ( childContext ) { prototype . _childContext = tools . defaults ( childContext , BaseClass . prototype . _childContext ) ; this . childContextTypes = compileSpecs ( childContext ) . propTypes ; } }