I have a Typescript class which includes a generic which needs to extend another class and implement an interface. Here is an example
interface IHasImage {
Typescript is not so restrictive as Java or C# so you can do things like that:
interface IHasImage {
imageUrl():string;
}
class Model {
}
// use the Model class like an interface
interface IHasImageModel extends IHasImage, Model{
}
class View {
constructor(arg :T){
arg.imageUrl();
}
}
Edit: In TypeScript 1.6 you can use Intersection types:
interface IHasImage {
imageUrl():string;
}
class Model {
}
class View {
constructor(arg :T){
arg.imageUrl();
}
}