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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong behavior of Curry generic #298

Open
valerii15298 opened this issue Mar 31, 2022 · 0 comments
Open

Wrong behavior of Curry generic #298

valerii15298 opened this issue Mar 31, 2022 · 0 comments

Comments

@valerii15298
Copy link

馃悶 Bug Report

Thank you between for such a great Curry generic, I had read your post on medium(published about 2 years ago), and it is one of the most interesting, complex and beutiful typescript generics I had ever seen. Though I did not understand it fully yet.

I am trying to use Curry generic to type ramda's propOr function.

type propOrType = <D, O extends object, P extends string>(
    defaultValue: D,
    propName: P,
    obj: O,
) => D | (P extends keyof O ? O[P] : never);

declare const propOr: _.F.Curry<propOrType>;

const alice = {
    name: 'ALICE',
    age: 101,
};
let age = propOr('Default value', 'age', alice); // => '101'
// type of age is `unknown` but must be at least `string | number`

I expect type of 'age' to be 101 | 'Default value' or at least number | string but I am getting unknown type.

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

1 participant