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

Conditional operator confusion with variable named async #10314

Open
DullReferenceException opened this issue Aug 9, 2019 · 1 comment

Comments

@DullReferenceException
Copy link

commented Aug 9, 2019

Bug Report

Current Behavior
With @babel/preset-flow, when a variable is named async, the compiler gets confused within a conditional operator and emits a syntax error.

Input Code

// @flow

import * as async from 'async';

true ? async.waterfall() : null;
/repl: Unexpected token, expected "=>" (5:31)

  3 | import * as async from 'async';
  4 | 
> 5 | true ? async.waterfall() : null;
    |                                ^
  6 | 

Expected behavior/code
It's expected that async would be treated as a normal variable; it's seemingly only within this particular type of expression that things act oddly. Also, the flow compiler when not going through babel does not seem to have this issue.

Note that working around this is easy enough; I'm just reporting the bug to be a good citizen.

Babel Configuration (.babelrc, package.json, cli command)

{
  "presets": [
    ["@babel/preset-env", {
      "targets": {
        "node": "10.15"
      }
    }],
    "@babel/preset-flow"
  ],
  "plugins": ["add-module-exports"]
}

Environment

  • Babel version(s): 7.5.5 (@babel/core 7.5.5)
  • Node version: v10.15.3
  • npm version: 6.10.3
  • OS: macOS 10.14.6
  • Monorepo: no
  • How you are using Babel: cli and register
@babel-bot

This comment has been minimized.

Copy link
Collaborator

commented Aug 9, 2019

Hey @DullReferenceException! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.