Skip to content

Support flow function type annotation with no parent#14014

Merged
JLHwung merged 2 commits into
babel:mainfrom
krosenberg:main
Dec 3, 2021
Merged

Support flow function type annotation with no parent#14014
JLHwung merged 2 commits into
babel:mainfrom
krosenberg:main

Conversation

@krosenberg

@krosenberg krosenberg commented Dec 1, 2021

Copy link
Copy Markdown
Contributor

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

babel-bot commented Dec 1, 2021

Copy link
Copy Markdown
Collaborator

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

@JLHwung JLHwung left a comment

Copy link
Copy Markdown
Contributor

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.

4 participants