Answer the question
In order to leave comments, you need to log in
How to correctly describe a type in typesctipt?
I just can’t understand why it’s impossible to destructure the action parameter in the reducer
Without destructuring, everything works as it should, as soon as I try, errors from the typescript immediately appear that there is no such property
Here is the code with destructuring
Here is the code without
Answer the question
In order to leave comments, you need to log in
The thing is that the profileActionsType type is a discriminated union
The post field is present in only one of its subtypes, so extracting this field from the full type is an error from the point of view of typescript.
Checking for a specific value in the type field is fine as a type guard , which ts will understand.
PS Posting code with pictures is prohibited by the rules of the service
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question