Best practices for asserting Typescript types for relationships
Unanswered
Braque du Bourbonnais posted this in #help-forum
Braque du BourbonnaisOP
When fetching data from the API using
Right now, I'm casting the props like the attached image. However, then I need to cast again or use
depth=1
or more, how can I assert that the response has all the relationships filled in rather than strings? Typescript properly assumes every relationship is string | Media
for example, but I know that the value is Media
, because I provided depth=1
.Right now, I'm casting the props like the attached image. However, then I need to cast again or use
ts-ignore
when I'm using the component. What's the best practice for asserting Typescript types when you know something is one of the optional values?