Reputation: 14417
I don't know if I have remembered correctly but can Typescript interface
members be defined with multiple types?
psuedo typescript...:
interface IModel {
field : string | Array;
}
Where IModel.field
can be either a string
or an Array
Upvotes: 0
Views: 383
Reputation: 7641
interface IModel {
field : string | Array<any>;
}
class MyClass1 implements IModel {
field : string;
}
class MyClass2 implements IModel {
field : Array<any>;
}
Indecisive implementation (Typescript Playground);
class MyClass3 implements IModel {
field : string | Array<any>;
}
Upvotes: 2