Reputation: 389
If I have a variable like this:
let x: number | string | undefined;
Is it possible to create an interface that supports all these types? Something like:
let x: MyCustomInterface;
Thanks!
Upvotes: 1
Views: 167
Reputation: 175078
No, interfaces do not support unions inside of themselves. You can make a type alias though:
type MyCustomType = number | string | undefined;
let x: MyCustomType;
Upvotes: 2