Skip to content

$push and ReadonlyArray<T> does not play nice #154

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

Closed
m-rutter opened this issue Mar 30, 2020 · 3 comments
Closed

$push and ReadonlyArray<T> does not play nice #154

m-rutter opened this issue Mar 30, 2020 · 3 comments

Comments

@m-rutter
Copy link

I am having issues with $push and ReadonlyArray types, which is very common in graphql codegen generated interfaces.

Minimal Example

interface Thing {
  bar: {
    foo: ReadonlyArray<{ baz: number }>;
  };
}

declare const a: Thing;
declare const b: Thing;

update(a, { bar: { foo: { $push: b.bar.foo } } });

returns this type error:

Type 'readonly { baz: number; }[]' is not assignable to type 'Spec<{ baz: number; }, never>'.
  Type 'readonly { baz: number; }[]' is not assignable to type '(v: { baz: number; }) => { baz: number; }'.
    Type 'readonly { baz: number; }[]' provides no match for the signature '(v: { baz: number; }): { baz: number; }'.ts(2322)

Workaround

Use $set instead

@m-rutter m-rutter changed the title $push and ReadonlyArray does not play nice $push and ReadonlyArray<T> does not play nice Mar 30, 2020
@kolodny
Copy link
Owner

kolodny commented Mar 30, 2020

Good catch, opened #155 to address this

@kolodny
Copy link
Owner

kolodny commented Mar 30, 2020

Published to 3.0.2

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

3 participants
@kolodny @m-rutter and others