How to make var of multiple types
Example
<code>interface Iroot {
a:any;
}
interface IType1
{
first:any;
}
interface IType2
{
second:any
}
interface Iq {
variable : IType1 | IType2;
}
var a: Iq;
</code>
<code>interface Iroot {
a:any;
}
interface IType1
{
first:any;
}
interface IType2
{
second:any
}
interface Iq {
variable : IType1 | IType2;
}
var a: Iq;
</code>
interface Iroot {
a:any;
}
interface IType1
{
first:any;
}
interface IType2
{
second:any
}
interface Iq {
variable : IType1 | IType2;
}
var a: Iq;
how make variable of Iq type than it be IType1 or IType2
In my case TS say – Property ‘first’ does not exist on type ‘IType1 | IType2’
I need that work only a.first =1 or a.second =2
1