Open maichongju opened 1 year ago
@maichongju Thanks for reporting! It seems using rollup
for generated type declarations was causing some trouble. I opened a PR which uses good old tsc
to do this and the results have seemed to improve. Most importantly, it fixes the issue you have. Once this has been reviewed and merged we will cut a release.
Using realm 12.3.1 and @realm/react 0.6.2 (the version when this should have been fixed) the error still persists when I use Realm.User as a type for function parameter and the value from useUser().
Argument of type 'User<DefaultFunctionsFactory, Record<string, unknown>, DefaultUserProfileData>' is not assignable to parameter of type 'UserType<UserFunctionsType, UserCustomDataType, UserProfileDataType>'. Type 'DefaultFunctionsFactory' is not assignable to type 'UserFunctionsType'. 'DefaultFunctionsFactory' is assignable to the constraint of type 'UserFunctionsType', but 'UserFunctionsType' could be instantiated with a different subtype of constraint 'DefaultFunctionsFactory'.ts(2345)
@takameyer Okay, it seems that this happens when I use the following import
import { User } from 'realm'
but it works when I use the following type
import Realm from 'realm
const user: Realm.User = ...
I'll be taking over this issue and try to reproduce it 👍
How frequently does the bug occur?
Always
Description
As the documentation suggested, we can pass the
user
to a function.However, when passing the
user
fromuseUser()
. following error display.Stacktrace & log output
No response
Can you reproduce the bug?
Always
Reproduction Steps
file1.ts
file2.ts
Version
"realm": "^12.2.1",, "@realm/react": "^0.6.0",
What services are you using?
Atlas App Services: Functions or GraphQL or DataAPI etc
Are you using encryption?
No
Platform OS and version(s)
Win11 23H2
Build environment
Which debugger for React Native: ..
Cocoapods version
No response