Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infering an F.Curry type as it's "full" signature results in unexpected behavior #242

Open
regevbr opened this issue Jun 1, 2021 · 3 comments

Comments

@regevbr
Copy link
Contributor

regevbr commented Jun 1, 2021

🐞 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 DefinitelyTyped/DefinitelyTyped#53478

@regevbr regevbr changed the title Infering an F.Curry type as it's "full" signature results in unexpected behaviour Infering an F.Curry type as it's "full" signature results in unexpected behavior Jun 1, 2021
regevbr added a commit to regevbr/ts-toolbelt that referenced this issue Jun 1, 2021
regevbr added a commit to regevbr/ts-toolbelt that referenced this issue Jun 1, 2021
@stale
Copy link

stale bot commented Aug 3, 2021

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.

@stale stale bot added the wontfix This will not be worked on label Aug 3, 2021
@stale stale bot closed this as completed Aug 18, 2021
@regevbr
Copy link
Contributor Author

regevbr commented Aug 18, 2021

@millsp can you please address this?

@millsp millsp reopened this Sep 3, 2021
@stale stale bot removed the wontfix This will not be worked on label Sep 3, 2021
@sant123
Copy link

sant123 commented Oct 15, 2021

Any updates on this? 🙈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants