How to use the 'in' operator to narrow down the properties and methods of an object with union type in TypeScript?
Originally Published Here ๐!
To narrow down the properties and methods of an object with union type we can use the in operator in TypeScript.
TL;DR
// Editor type
type Editor = {
name: string;
};
// Admin type
type Admin = {
name: string;
rol...
melvingeorge-me.hashnode.dev3 min read