You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Argument of type '{ <U extends O[keyof O], UK extends keyof U, O extends Record<string, any>>(obj: "value" extends UK ? O : never): { [OK in keyof O]: O[OK]["value"]; }; <U extends readonly unknown[] | Record<"value", any>>(list: readonly U[]): U extends readonly (infer T)[] ? T[] : U extends Record<...> ? T[] : never; }' is not assignable to parameter of type '(...args: Data[][]) => (number | null)[]'.
Type '{ [x: string]: any; }' is missing the following properties from type '(number | null)[]': length, pop, push, concat, and 25 more.
Your R.pipe<> typings is off by a bit: R.pipe<[Data[]], (number | null)[], number[]>(), but that's not the core problem
The problem here is due a combination of two things. First is the fact that typescript always picks the last overload when you pass a function as a prop. And R.reject has this:
exportfunctionreject<A,PextendsA>(pred: (val: A)=>val is P,): {<BextendsA>(list: readonlyB[]): Array<Exclude<B,P>>;<BextendsA>(dict: Record<string,B>): Record<string,Exclude<B,P>>;};
R.reject(R.isNil) falls into this and so in your R.pipe, The R.reject is expecting a Record<string, B> and not a B[]. But R.pluck() is now, correctly, returning B[] (#71 fixed that, before it was returning an obj, not an array of objects like it should have, this is why you didn't have the problem before)
Since most use-cases for R.filter and R.reject is to pass a list and not an object, the list overload should come last. That's how it is on map as well. I actually have an open MR for this: #106. I'm going to add to that MR an update for R.reject as well
The second is how the new R.pluck is what I have been calling "the collapsing generics problem". You can read about it all here: #54
The tl;dr is because R.Pluck supports both and object and an array, the generic collapses to unknown, This is specifically due to the fact that there is more than one overload. If you use only one overload, the generic transfers. You can see this in action here: https://tsplay.dev/m3qojw
A short-term fix for you is to not use the curried varieties of those functions, and wrap them with arrow functions in your pipe
Activity
Harris-Miller commentedon Mar 5, 2024
Your
R.pipe<>typings is off by a bit:R.pipe<[Data[]], (number | null)[], number[]>(), but that's not the core problemThe problem here is due a combination of two things. First is the fact that typescript always picks the last overload when you pass a function as a prop. And
R.rejecthas this:R.reject(R.isNil)falls into this and so in yourR.pipe, TheR.rejectis expecting aRecord<string, B>and not aB[]. ButR.pluck()is now, correctly, returningB[](#71 fixed that, before it was returning an obj, not an array of objects like it should have, this is why you didn't have the problem before)Since most use-cases for
R.filterandR.rejectis to pass a list and not an object, the list overload should come last. That's how it is onmapas well. I actually have an open MR for this: #106. I'm going to add to that MR an update forR.rejectas wellThe second is how the new
R.pluckis what I have been calling "the collapsing generics problem". You can read about it all here: #54The tl;dr is because
R.Plucksupports both and object and an array, the generic collapses tounknown, This is specifically due to the fact that there is more than one overload. If you use only one overload, the generic transfers. You can see this in action here: https://tsplay.dev/m3qojwA short-term fix for you is to not use the curried varieties of those functions, and wrap them with arrow functions in your
pipeThis is far from ideal, but will get around the typing problem until we can release a fix
nathan1530 commentedon Mar 6, 2024
Thank you for responding so quickly. I will use the workaround for now.