Skip to content

Parsing and generating flow type moves parentheses #10517

@andy-hanson

Description

@andy-hanson

Bug Report

Input Code

packages/babel-generator/test/fixtures/types/ArrowFunctionExpression2/input.js:

const pair = <T>(a: T): (T => T[]) => b => [a, b]

packages/babel-generator/test/fixtures/types/ArrowFunctionExpression2/options.json:

{ "plugins": ["flow"] }

Expected behavior/code
The output should be the same as the input, with the parentheses around (T => T[]).

Current Behavior
Output code is:

const pair = <T>(a: T): (T) => T[] => b => [a, b];

The parentheses have moved from (T => T[]) to (T) => T[].
Flow now gives a parse error on the output, where it worked for the original.

Environment

  • Babel version(s): master
  • Node/npm version: Node 10/npm 6
  • OS: Linux Mint 18.1
  • Monorepo: yes
  • How you are using Babel: env TEST_ONLY=babel-generator make test

Metadata

Metadata

Assignees

No one assigned

    Labels

    Has PRoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issuepkg: generator

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions