Skip to content

flow type annotations with default parameters in arrow functions fail eslint due to Parsing error: Assigning to rvalue #2493

@davidjnelson

Description

@davidjnelson

If I have code like this:

let hello = (greeting:string = ' world') : string => {
console.log('hello' + greeting);
};

hello();

I get this error when I run: node_modules/eslint/bin/eslint.js .:

Parsing error: Assigning to rvalue

If I don't use arrow functions it works fine, ie:

let hello = function (greeting:string = ' world') : string {
console.log('hello' + greeting);
};

hello();

I created a repo to help reproduce it:

https://github.com/davidjnelson/flow-issues

For now I'll workaround by not using arrow functions and manually binding the this context when using default parameters, but I'd sure like them together :-) Thanks so much!

Metadata

Metadata

Assignees

No one assigned

    Labels

    outdatedA 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