how to handle multiple return type in action in typescript #5369
-
Hi,
|
Beta Was this translation helpful? Give feedback.
Answered by
machour
Feb 5, 2023
Replies: 1 comment 2 replies
-
Since you're returning two different structures, TypeScript needs you to test things for yourself: if (actionData && "baz" in actionData) {
console.log(actionData.baz); // TypeScript is happy here
} |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
tomer-yechiel
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Since you're returning two different structures, TypeScript needs you to test things for yourself: