GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
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
Works towards #5828
Prevent getFunctionParent from returning Program
Remove isProgram test from callback
We also need to remove the FunctionParent alias from the Program type definition.
Remove FunctionParent alias from Program
Don't error if function parent isn't found, return null
I expect lots of plugin tests to fail, but otherwise, to solve the original issue itself, do you think I got it right so far @jridgewell @boopathi?
why is this change required ?
because in another instance of the code, it freaks out #5923 (comment)
maybe there's a better way to deal with it though, open to suggestions :)
Scope's getFunctionParent throws. paths' getFunctionParent doesn't throw and silently fails by returning null. Looks like you have swapped this behaviour.
to keep both consistent, what do you think of not throwing in both cases and returning null?
(although i'm letting scope's getProgramParent() throw since that would mean something is weird?)
I don't have strong feelings on this decision, but I do agree that the name and the behavior seem contradictory.
If we do go with this change, the doc comment on this function also needs to be updated.
So this is just an alias to BabelNodeFunction?
yeah, I'm hoping that was the right thing to do ..
This wouldn't work, because getFunctionParent() either returns the function path or throws. It never returns a falsy value and thus getProgramParent() is never called.
@nicolo-ribaudo you're correct, that's why I made it to return null if it can't find a function path - #5923 (comment)
Oh sorry, I confused it with path.getFunctionParent() 😅
Fix failing tests
This should be documented as a breaking change too
Document update to function behaviour
fix: Can’t use getScopeParent() to register fn decls
Behavior was broken in Babel 7; see babel/babel#5923