just
just copied to clipboard
[feat] more accurate type for just-curry-it
Package
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.
https://github.com/microsoft/TypeScript/issues/50991#issuecomment-1262574411
Thank you. Not great at TS so I will leave this out there if anyone wants to take it.