How to fix Mapped type 'X' cannot use 'in' with non-union type in TypeScript | DevErrors