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

[feat] more accurate type for just-curry-it #504

Open
loynoir opened this issue Sep 29, 2022 · 1 comment
Open

[feat] more accurate type for just-curry-it #504

loynoir opened this issue Sep 29, 2022 · 1 comment

Comments

@loynoir
Copy link

loynoir commented Sep 29, 2022

Package

just-curry-it@5.2.1

Example

type MP2 = {
  a1: "a2";
  b1: "b2";
};
type MP3 = {
  a1: "a3";
  b1: "b3";
};
type MR = {
  a1: "ar";
  b1: "br";
};
function foo<K extends keyof MP2>(p1: K, p2: MP2[K], p3: MP3[K]): MR[K] {
  return { p1, p2, p3 } as any;
}

Actual

// no errror
curry(foo)('a1')('b2')

// "ar" | "br"
const r = curry(foo)('a1')('a2')('a3')
void r

Expected

// @ts-expect-error
curry(foo)('a1')('b2')

// "ar"
const r = curry(foo)('a1')('a2')('a3')
void r

Related

RyanCavanaugh said it is possible.

microsoft/TypeScript#50991 (comment)

@angus-c
Copy link
Owner

angus-c commented Nov 19, 2022

Thank you. Not great at TS so I will leave this out there if anyone wants to take it.

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

No branches or pull requests

2 participants