How to fix Expression produces a union type that is too complex to represent in TypeScript | DevErrors