flow-typed / flow-typed

A central repository for Flow library definitions
https://flow-typed.github.io/flow-typed/
MIT License
3.77k stars 1.33k forks source link

Issue with Ramda placeholder `__`. #1626

Open AndrewSouthpaw opened 6 years ago

AndrewSouthpaw commented 6 years ago

@LoganBarnett

I've been inconsistently running into issues with __ where flow thinks its presence means the function is actually being invoked. So a simple example:

difference(__, [1,2,3])([1])

When I run flow this way, I get:

Error: frontend/src/modules/lesson_plan/selectors.js:44
 44: const foo = difference(R.__, [1,2,3])([1])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function call. Function cannot be called on
 44: const foo = difference(R.__, [1,2,3])([1])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ array type

Inexplicably I can't replicate this in Flow Try.

Anyone else encounter such strange behavior?

LoganBarnett commented 6 years ago

@AndrewSouthpaw this makes sense to me, because the current definition of difference is not a curried function.

declare function difference<T>(
    xs1: Array<T>,
    ...rest: Array<void>
  ): (xs2: Array<T>) => Array<T>;
  declare function difference<T>(xs1: Array<T>, xs2: Array<T>): Array<T>;

Come to think of it, even our manually curried functions we've been adding won't work with __ either. For future PRs I make, I'll be sure to make the functions a CurriedFunction.