ts-toolbelt
ts-toolbelt copied to clipboard
Infering an F.Curry type as it's "full" signature results in unexpected behavior
🐞 Bug Report
Describe the bug
Inferring a curry "full" signature type results in parameters being inferred as unknown.
Reproduce the bug
// @ts-ignore
const sorter = (a: string, b: string) => 1;
const curriedSorter = curry(sorter)
const sort = <T>(fn: (a: T, b: T) => number, list: T[]): T[] => {
list.sort(fn)
return list
}
const curriedSort = curry(sort)
const test041: string[] = curriedSort(curriedSorter)(['a', 'b'])
produces the following error:
tests/Function.ts:93:13 - error TS2345: Argument of type 'Curry<(a: string, b: string) => number>' is not assignable to parameter of type 'x | ((a: unknown, b: unknown) => number)'.
Type 'Curry<(a: string, b: string) => number>' is not assignable to type '(a: unknown, b: unknown) => number'.
Types of parameters 'a' and 'a' are incompatible.
Type 'unknown' is not assignable to type 'string | x'.
Type 'unknown' is not assignable to type 'x'.
Type 'unknown' is not assignable to type 'unique symbol'.
93 curriedSort(curriedSorter)
Expected behavior
Should compile properly
Possible Solution
Add the full signature as an overload (using intersection doesn't work!)
Additional context
The issue was discovered during the work on https://github.com/DefinitelyTyped/DefinitelyTyped/pull/53478
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
@millsp can you please address this?
Any updates on this? 🙈