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

[@realm/react] Broken useQuery types in combination with realm v11.0.0-rc.1 #4905

Closed
haikov opened this issue Sep 13, 2022 · 3 comments · Fixed by #4907
Closed

[@realm/react] Broken useQuery types in combination with realm v11.0.0-rc.1 #4905

haikov opened this issue Sep 13, 2022 · 3 comments · Fixed by #4907
Assignees
Labels
Needs-Attention Reporter has responded. Review comment. O-Community T-Bug

Comments

@haikov
Copy link

haikov commented Sep 13, 2022

How frequently does the bug occur?

All the time

Description

The easiest way to reproduce the issue is to use expo realm template and upgrade realm packages to the latest versions:

"@realm/react": "^0.3.2",
"realm": "^11.0.0-rc.1",

After doing that useQuery hook types used on this line break with the following error:

Argument of type 'typeof Task' is not assignable to parameter of type 'string | ((new () => Task) & ObjectClass<any>)'.
  Type 'typeof Task' is not assignable to type '(new () => Task) & ObjectClass<any>'.
    Type 'typeof Task' is not assignable to type 'new () => Task'.
      Types of construct signatures are incompatible.
        Type 'new (realm: Realm, values: Unmanaged<unknown>) => Task' is not assignable to type 'new () => Task'.

For reference, previous useQuery type was:

<Task>(type: string | ((new () => Task) & Realm.ObjectClass)) => Realm.Results<Task & Realm.Object>

After reading changelog for v11.0.0 it feels like the change to Class-based models might have caused the typing change in useQuery as well (which is not intended?).

Stacktrace & log output

No response

Can you reproduce the bug?

Yes, always

Reproduction Steps

No response

Version

@realm/react: 0.3.2; realm: 11.0.0-rc.1

What SDK flavour are you using?

Local Database only

Are you using encryption?

No, not using encryption

Platform OS and version(s)

React Native (Expo)

Build environment

Which debugger for React Native: ..

Cocoapods version

No response

@takameyer
Copy link
Contributor

@haikov Thanks for reporting this. The fix is now released in 0.4.0-rc.0. You can install this using the next tag:

npm install @realm/react@next

@sync-by-unito sync-by-unito bot added the Waiting-For-Reporter Waiting for more information from the reporter before we can proceed label Sep 14, 2022
@haikov
Copy link
Author

haikov commented Sep 14, 2022

Thank you! I can confirm that it works with 0.4.0-rc.0 version of @realm/react, please feel free to close the issue when it's best, now or after the 0.4.0 release.

@github-actions github-actions bot added Needs-Attention Reporter has responded. Review comment. and removed Waiting-For-Reporter Waiting for more information from the reporter before we can proceed labels Sep 14, 2022
@takameyer
Copy link
Contributor

We will be keeping 0.4.0-rc.0 as a release candidate until v11 is officially released. 0.4.0 will have a hard dependency on realm >= 11.0.0.

Thanks for testing this out!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Needs-Attention Reporter has responded. Review comment. O-Community T-Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants