Skip to content

Deal gracefully with missing hook.init #261

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

Merged
merged 2 commits into from
Nov 26, 2022

Conversation

aspiers
Copy link

@aspiers aspiers commented Dec 11, 2021

It seems that in some cases, declarations inside VariableDeclaration elements in the AST are missing the init property, e.g.:

image

So add a check to handle this gracefully.

It seems that in some cases, VariableDeclaration elements in the AST
are missing the init property.  So add a check to handle this
gracefully.
@aspiers
Copy link
Author

aspiers commented Dec 12, 2021

I think I tracked down the origin of this to this declaration:

image

which is transpiled code from https://github.com/ant-design/ant-design/blob/678cf4948beec6fb2fadec7f930035c78ade51e2/components/steps/index.tsx#L46

@aspiers
Copy link
Author

aspiers commented Dec 12, 2021

IOW, any uninitialised variable declaration would cause it. The reactime code seems to assume that the variable declaration must be a hook, but clearly that doesn't have to be the case.

Copy link
Contributor

@llam722 llam722 left a comment

Choose a reason for hiding this comment

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

Hi aspiers,
Great catch regarding the uninitialised variable declaration and implementation of the optional chaining. Thanks for the contribution on this issue!

@SamuelTr13 SamuelTr13 merged commit 6569971 into open-source-labs:master Nov 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants