How to fix Discriminant property 'X' cannot be used for narrowing in TypeScript | DevErrors