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

partition typing broken with interface and object #132

Open
davetapley opened this issue Nov 21, 2024 · 2 comments
Open

partition typing broken with interface and object #132

davetapley opened this issue Nov 21, 2024 · 2 comments

Comments

@davetapley
Copy link

Not sure if regression.
Works at runtime, but last partition doesn't type check:

import { filter, partition, test, where } from "ramda";

export interface IFoo {
    bar: string;
}
const check = where({ bar: test(/fo/) })

const dataList: IFoo[] = [{ bar: "foo" }, { bar: "baz" }]
const dataObj: { [id: string]: IFoo } = { one: { bar: "foo" }, two: { bar: "baz" } }


describe("whereUnit", () => {
    it("works with filter", () => {
        expect(filter(check, dataList)).toEqual([{ bar: "foo" }])
        expect(filter(check, dataObj)).toEqual({ one: { bar: "foo" } })
    });
    ;
    it("doesn't with partition", () => {
        expect(partition(check, dataList)).toEqual([[{ bar: "foo" }], [{ bar: "baz" }]])
        expect(partition(check, dataObj)).toEqual([{ one: { bar: "foo" } }, { two: { bar: "baz" } }]) // see below
    });
})
No overload matches this call.
  Overload 1 of 4, '(fn: (a: IFoo) => a is IFoo, list: readonly IFoo[]): [IFoo[], never[]]', gave the following error.
    Argument of type '<U>(testObj: U) => boolean' is not assignable to parameter of type '(a: IFoo) => a is IFoo'.
      Signature '(testObj: IFoo): boolean' must be a type predicate.
  Overload 2 of 4, '(fn: (a: IFoo) => boolean, list: readonly IFoo[]): [IFoo[], IFoo[]]', gave the following error.
    Argument of type '{ [id: string]: IFoo; }' is not assignable to parameter of type 'readonly IFoo[]'.
      Type '{ [id: string]: IFoo; }' is missing the following properties from type 'readonly IFoo[]': length, concat, join, slice, and 26 more.ts(2769)

See also:

@davetapley davetapley changed the title partition typing broken work with interface partition typing broken with interface Nov 21, 2024
@davetapley davetapley changed the title partition typing broken with interface partition typing broken with interface and object Nov 21, 2024
@Harris-Miller
Copy link
Collaborator

partition isn't currently typed for support of objects. We'll need to add it

@Harris-Miller
Copy link
Collaborator

@davetapley MRs welcome if you want to give that try yourself

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

2 participants