Skip to content
New issue

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

Support flow function type annotation with no parent #14014

Merged
merged 2 commits into from Dec 3, 2021

Conversation

krosenberg
Copy link
Contributor

@krosenberg krosenberg commented Dec 1, 2021

I have a use case where I want to generate code for a FunctionTypeAnnotation node, and the node has no parent. When the node is passed into the FunctionTypeAnnotation handler, it assumes a parent exists.
I've added a check for the parent so that we don't try to read .type off of an undefined parent.

@babel-bot
Copy link
Collaborator

babel-bot commented Dec 1, 2021

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/50100/

@nicolo-ribaudo nicolo-ribaudo added the PR: Bug Fix 🐛 A type of pull request used for our changelog categories label Dec 1, 2021
Copy link
Contributor

@JLHwung JLHwung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should mark parent as t.Node | void so such errors can be caught by type checkers. Can you update the function typings?

@JLHwung JLHwung merged commit 4079ee5 into babel:main Dec 3, 2021
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Mar 4, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Bug Fix 🐛 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants