We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
As an example:
type Props = | { type: 'foo', item: { id: number, parentId: number | null } } | { type: 'bar', item: { id: number, parentId: number } } function test(props: Props) { // This works const yay = props.type === 'foo' ? props.item.id : `/parents/${props.item.parentId}/items/${props.item.id}` // This does not const { type, item } = props const boo = type === 'foo' ? item.id : `/parents/${item.parentId}/items/${item.id}` }
I'm running v0.46. Curiously, the try flow REPL doesn't exhibit an error, I'm only getting it locally.
Any ideas?
The text was updated successfully, but these errors were encountered:
This shouldn't really work. When you destructure a union, types get flattened.
Sorry, something went wrong.
Hmm... I guess that makes sense. Thanks for pointing that out. I imagine it would be hard/impossible to keep the union with destructuring?
@vkurchatkin Why is that?
Some related issues: #6146 #6805 #6594 #6408 #5745 #4772
No branches or pull requests
As an example:
I'm running v0.46. Curiously, the try flow REPL doesn't exhibit an error, I'm only getting it locally.
Any ideas?
The text was updated successfully, but these errors were encountered: