just icon indicating copy to clipboard operation
just copied to clipboard

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

Open loynoir opened this issue 2 years ago • 1 comments

Package

[email protected]

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

loynoir avatar Sep 29 '22 18:09 loynoir

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

angus-c avatar Nov 19 '22 21:11 angus-c