Skip to content
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

Babel warning with Flow bindings. #208

Open
AndrewSouthpaw opened this issue Dec 28, 2017 · 4 comments
Open

Babel warning with Flow bindings. #208

AndrewSouthpaw opened this issue Dec 28, 2017 · 4 comments

Comments

@AndrewSouthpaw
Copy link

I'm reopening the closed issue #108 because it's not actually resolved and the old one isn't getting any attention.

The warning, as from before:

You or one of the Babel plugins you are using are using Flow declarations as bindings.
Support for this will be removed in version 6.8. To find out the caller, grep for this
message and change it to a `console.trace()`.

Here's a typical stack trace:

at Scope.warnOnFlowBinding (node_modules/babel-core/node_modules/babel-traverse/lib/scope/index.js:1020:15)
at Scope.getBinding (node_modules/babel-core/node_modules/babel-traverse/lib/scope/index.js:1030:32)
at getVariableNameAndBinding (node_modules/babel-plugin-rewire/lib/babel-plugin-rewire.js:47:83)
at RewireState.Identifier (node_modules/babel-plugin-rewire/lib/babel-plugin-rewire.js:176:33)
at NodePath._call (node_modules/babel-core/node_modules/babel-traverse/lib/path/context.js:76:18)
at NodePath.call (node_modules/babel-core/node_modules/babel-traverse/lib/path/context.js:48:17)
at NodePath.visit (node_modules/babel-core/node_modules/babel-traverse/lib/path/context.js:105:12)
at TraversalContext.visitQueue (node_modules/babel-core/node_modules/babel-traverse/lib/context.js:150:16)
at TraversalContext.visitSingle (node_modules/babel-core/node_modules/babel-traverse/lib/context.js:108:19)
at TraversalContext.visit (node_modules/babel-core/node_modules/babel-traverse/lib/context.js:192:19)
at Function.traverse.node (node_modules/babel-core/node_modules/babel-traverse/lib/index.js:114:17)
at NodePath.visit (node_modules/babel-core/node_modules/babel-traverse/lib/path/context.js:115:19)
at TraversalContext.visitQueue (node_modules/babel-core/node_modules/babel-traverse/lib/context.js:150:16)
at TraversalContext.visitMultiple (node_modules/babel-core/node_modules/babel-traverse/lib/context.js:103:17)
at TraversalContext.visit (node_modules/babel-core/node_modules/babel-traverse/lib/context.js:190:19)
at Function.traverse.node (node_modules/babel-core/node_modules/babel-traverse/lib/index.js:114:17)

It would be great to get some input from @speedskater on the issue, since it appears to be have been fixed previously. Support for flow bindings is dropped for v7, so I want to make sure rewire isn't accidentally doing flow bindings. From what I can tell of the original fix in rewire that is the case, but I'm having trouble making much sense of the repo, as I'm unfamiliar with Babel plugins. 😞

@tjmehta
Copy link

tjmehta commented Mar 22, 2018

You or one of the Babel plugins you are using are using Flow declarations as bindings.
        Support for this will be removed in version 6.8. To find out the caller, grep for this
        message and change it to a `console.trace()`.

    at Scope.warnOnFlowBinding (<project>/node_modules/babel-core/node_modules/babel-traverse/lib/scope/index.js:1019:15)
    at Scope.getOwnBinding (<project>/node_modules/babel-core/node_modules/babel-traverse/lib/scope/index.js:1034:17)
    at Scope.getBinding (<project>/node_modules/babel-core/node_modules/babel-traverse/lib/scope/index.js:1028:27)
    at getVariableNameAndBinding (<project>/node_modules/babel-plugin-rewire/lib/babel-plugin-rewire.js:47:83)
    at RewireState.Identifier (<project>/node_modules/babel-plugin-rewire/lib/babel-plugin-rewire.js:61:32)
    at NodePath._call (<project>/node_modules/babel-core/node_modules/babel-traverse/lib/path/context.js:76:18)
    at NodePath.call (<project>/node_modules/babel-core/node_modules/babel-traverse/lib/path/context.js:48:17)
    at NodePath.visit (<project>/node_modules/babel-core/node_modules/babel-traverse/lib/path/context.js:105:12)
    at TraversalContext.visitQueue (<project>/node_modules/babel-core/node_modules/babel-traverse/lib/context.js:150:16)
    at TraversalContext.visitSingle (<project>/node_modules/babel-core/node_modules/babel-traverse/lib/context.js:108:19)```

@AndrewSouthpaw
Copy link
Author

AndrewSouthpaw commented May 10, 2018

Well, I finally figured out what's causing it... any code that uses a type importing shorthand, e.g. import React, { type Node } from 'react' will trigger the warning. The problem goes away when you split the type imports from the regular imports, e.g.

import React from 'react'
import type { Node } from 'react'

I'm not sure if that lies in the court of rewire or babel... thoughts?

@SanCoder-Q
Copy link

@AndrewSouthpaw That is very helpful. Thank you.

@SanCoder-Q
Copy link

One more case is when there is a name of the entry in the root file same as the one being imported.

import type { Props as AnotherProps } from './another';
type Props = ...

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

No branches or pull requests

3 participants