Closed panrafal closed 8 years ago
ugh!
I feel like this will bite us soon, have you had any chance to look at it?
Agree this is a problem, unfortunately not yet, I'm tied up with other projects at the moment. PR would be gratefully accepted.
What does it mean? In babel 6.7 this plugin just won't work?
Support for this will be removed in version 6.8.
Rewire fix it in this way: https://github.com/speedskater/babel-plugin-rewire/commit/80d717a3014cac97e3fa6b8e60f991e30d977b76
Hope could be helpful... I really like this plugin and I don't wanna miss it!
I have traced the error message. All of these errors come from this line:
function getTypeChecker (id: Identifier|QualifiedTypeIdentifier, scope: Scope): NodePath|false {
const binding = scope.getBinding(id.name);
if (binding === undefined) {
return false;
}
Unfortunately, knowing that is not enough to solve the issue. I have looked into how https://github.com/speedskater/babel-plugin-rewire/commit/80d717a3014cac97e3fa6b8e60f991e30d977b76 fixed the issue and came up with:
function getTypeChecker (id: Identifier|QualifiedTypeIdentifier, scope: Scope): NodePath|false {
const binding = (!t.isFlow || (!t.isFlow(id) && !t.isFlow(id.parent))) ? scope.getBinding(id.name) : undefined;
However, in this case, t.isFlow(id) && !t.isFlow(id.parent))
is true
, therefore the function ends up calling scope.getBinding(id.name)
anyway.
I know too little about type bindings and this particular issue to solve it. However, it could be a stepping stone for whoever tries after me.
Here is the PR that introduced the change.
https://phabricator.babeljs.io/rBC9b229f1f089277a928ec6786b5c4791a7d8c1b96
The change has been introduced by @amasad. I guess we will need to wait until he follows up with an explanation.
A solution would be to look for the variable that is defined for every type instead of the type itself.
@phpnode can this be assigned a priority?
@gajus it's high priority, i've started work on v4 which avoids this problem but it's a way from being releasable. I tried hacking around this issue in the existing plugin and ran into problems, but I will try again because it will be faster than waiting for v4.
Fixed in 3.9.0
On the newest Babel 6.7 (with babel-traverse 6.7.2) the below warning shows up. It's caused by this PR: https://github.com/babel/babel/pull/3414