How to fix Type 'X' is not assignable to inferred conditional type in TypeScript | DevErrors