Reputation: 13
I get this compile error:
property 'prototype' does not exist on value of type 'Base'
on the following class, how can I get typescript to recognise the prototype object as a type of native Object from a constructor Function?
interface IBase {
extend: any;
prototype : any;
}
declare var Base : IBase;
class Base implements IBase {
constructor() {}
public extend( mixins : any ) : void {
_.extend( this.prototype, mixins );
}
}
Upvotes: 0
Views: 1710
Reputation: 220974
this.prototype
is probably not what you mean, since instances of Base
don't have a prototype
property (see yourself at runtime). Base
, however, does:
interface IBase {
extend: any;
}
class Base implements IBase {
constructor() {}
public extend( mixins : any ) : void {
_.extend(Base.prototype, mixins );
}
}
Of course, at this point, extend
might as well be static, since it applies to all Base
instances. Did you mean this instead?
public extend( mixins : any ) : void {
_.extend(this, mixins);
}
Upvotes: 3