I'm not really familiar with CraftyJS and the documentation could use a little TLC - unless I've missed something it looks as if calling requires
is simply amalgamating everying into a single object - last-in takes precedence. No inheritance so no superclass - just one flat object.
Perhaps there's a better way but I could only get it to "override" the function by simply assigning it inside the init
function after you've imported your required components.
Crafty.c('TestB', {
init: function() {
this.requires('TestA');
this.foo = function(){
console.log('call B foo');
}
}
});