Skip to content

Syntax Error for Flow type parameter defaults in function declarations #6326

@taylorgoolsby

Description

@taylorgoolsby

Recently flowtype released https://github.com/facebook/flow/releases/tag/v0.103.0

This includes facebook/flow@c18ee0d
which is a fix for facebook/flow#6875.

This new syntax is not supported by prettier.

Environments:

  • Prettier Version: 1.18.2
  • Running Prettier via: CLI
  • Runtime: Node.js v10.15.0
  • Operating System: macOS

Steps to reproduce:

function foo<T: any = number>(): any {}

Expected behavior:

src/foo.js 20ms

Actual behavior:

src/foo.js
[error] src/foo.js: SyntaxError: Unexpected token
[error] > 1 | function foo<T: any = number>(
[error]     |                     ^

Metadata

Metadata

Assignees

No one assigned

    Labels

    lang:flowIssues affecting Flow-specific constructs (not general JS issues)locked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.type:testsIssues about tests that are not correct, should be added, or similar

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions