This used to work fine, but after a fresh install I've started getting this error. I haven't been able to narrow down exactly which module upgraded recently. This is potentially related to #266. I'm also unsure if the problem is with babel-eslint.
I'm using Babel, flow, and babel-eslint. Flow doesn't complain with the below, but eslint does:
// @flow
function setIfNotDefault<T>(obj: Object, key: string, val: T, def: T) {
if (val !== def) {
obj[key] = val;
}
}
0:0 error Parsing error: Object.defineProperty called on non-object
I've started running into this too and it definitely seems related to parsing of generic parameters. I don't think it's limited to functions either. It looks like it's also triggered by <…> in type declarations, at least in some cases.
If it really just started to happen recently, then it might be a regression in babylon. In the latest release of babylon there was one change related to flow.
I think it must be some pretty recent update somewhere that is causing it because I only started noticing it in the last couple days after doing fresh installs. This is with packages that are only a few weeks old and didn't trigger the error originally.
I tried to install older versions of eslint and related packages but couldn't track down where the error first started showing up.
The recent change in babylon was https://github.com/babel/babylon/pull/25
edit: which might of broke something
Just like @hzoo said. I confirmed that locking the babylon dependency at 6.8.0 with npm-shrinkwrap solves the problem.
Confirmed for me, [email protected] works, [email protected] breaks.
Ok https://github.com/babel/babel-eslint/pull/322 - Need to change some logic in babel-eslint to account for the change in babylon and push a patch
The only place should be in https://github.com/babel/babel-eslint/issues/321
Is there a simple workaround for this?
current workaround is pinning to 6.8.0 like mentioned above
Thanks a lot @hzoo ! Been struggling with this for a while. 6.8.0 sorted me out :)
Hi, I'm getting this issue at the moment. I don't really know what I'm doing with npm. Can some tell me how to pin babylon? I tried just npm install [email protected] but this didn't work.
Just "npm rm babylon" and then "npm install [email protected] --save[-dev] --save-exact". Did the trick for me.
Ok thanks to @danez this should be fixed in babel 6.10.2 (babel-eslint uses babel-types, etc), so will need to npm install again
The tests still fail. I think because the new TypeParameter is not visited/marked as seen.
Most helpful comment
Just "npm rm babylon" and then "npm install [email protected] --save[-dev] --save-exact". Did the trick for me.