fp-ts
fp-ts copied to clipboard
Incorrect ReadonlyArray.difference Override Referenced with flip
🐛 Bug report
Current Behavior
using
flip
fromfp-ts/lib/function
andReadonlyArray.difference
fromfp-ts/ReadonlyArray
Applying flip to ReadonlyArray.difference
uses the non-curried override of the difference method rather than the curried override. This results in the use of a deprecated flip
override being used to to flip a non-curried method, and the resulting flipped function does not work as expected.
Below is on a fresh project after installing typescript and fp-ts:
Expected behavior
The flip function should use the curried version of ReadonlyArray.difference
by using the non-deprecated version of flip.
Below is same code as above but using a custom curried difference function:
Reproducible example
See screenshots above
Suggested solution(s)
It seems weird to me that the deprecated override of a function is being used when the non-deprecated override can be used. Maybe there's a way to use the deprecated one only if the the non-deprecated override can't be applied?
Additional context
Your environment
Which versions of fp-ts are affected by this issue? Did this work in previous versions of fp-ts?
Using [email protected]
. Haven't tried with previous versions
Software | Version(s) |
---|---|
fp-ts | 2.13.1 |
TypeScript | 4.8.4 |
Maybe there's a way to use the deprecated one only if the the non-deprecated override can't be applied?
I'm not sure we can impose which override ts will choose in this specific case
Seems the preference comes from the order of signatures in the .d.ts
file for ReadonlyArray. Tested with:
Problem described above
Current order of function signatures in fp-ts
Proposed order of function signatures (deprecated first)
Result, non-deprecated function signature being used first