Handling Unexpected JSON Enum Values in TypeScript
I want to parse a json response. It has a property
I create my schema and enum that represents these 3 values:
Now the API I'm using adds an additional property without me knowing: "pending".
How would I create my schema so that it becomes "resistant" to this change?
* How could I give status the value
* How could I give it a default Enum case if any cases doesn't match, e.g.
status which can be of 3 possible values: "completed", "in_progress", "queued".I create my schema and enum that represents these 3 values:
Now the API I'm using adds an additional property without me knowing: "pending".
How would I create my schema so that it becomes "resistant" to this change?
* How could I give status the value
null if any of the Enum cases doesn't match?* How could I give it a default Enum case if any cases doesn't match, e.g.
Unknown?