Reputation: 894
interface Inter {
a: number;
b: string;
}
let variable:(blabla);
=> right here.
I want to set the above to (number | string)
using Inter
's properties.
Is there any way to do this? Thanks for reading !
Upvotes: 0
Views: 64
Reputation: 250186
You can use a type query with a type that is a union of all keys, which you can get keyof
:
let val: Inter[keyof Inter]; // will be string | number
Upvotes: 3