Skip to content

Conditional operator confusion with variable named async #10314

@DullReferenceException

Description

@DullReferenceException

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: flowoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions