-
Type: Bug
-
Resolution: Works as Designed
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: Node.js, React Native
How frequently does the bug occur?
Always
Description
Imagine i have the following code:
import Realm from 'realm'; public createQuery<T>(schema: string): Realm.Results<T> { return this._realm.objects(schema); }
This growls (typescript 4.8.4) saying:
Type 'Results<RealmObject<T, never> & T>' is not assignable to type 'ResultsType<T>'. Types of property 'update' are incompatible. Type '(propertyName: ExtractPropertyNamesOfType<RealmObject<T, never> & T, AnyDictionary> | Exclude<"keys", keyof AnyRealmObject | ExtractPropertyNamesOfType<...> | ExtractPropertyNamesOfType<...> | ExtractPropertyNamesOfType<...>> | ... 13 more ... | ExtractPropertyNamesOfType<...>, value: Unmanaged<...>[ExtractPropertyN...' is not assignable to type '(propertyName: ExtractPropertyNamesOfType<T, AnyDictionary> | Exclude<keyof T, keyof AnyRealmObject | ExtractPropertyNamesOfType<T, AnyDictionary> | ExtractPropertyNamesOfType<...> | ExtractPropertyNamesOfType<...>> | ExtractPropertyNamesOfType<...>, value: Unmanaged<...>[ExtractPropertyNamesOfType<...> | ... 1 more...'. Types of parameters 'propertyName' and 'propertyName' are incompatible. Type 'ExtractPropertyNamesOfType<T, AnyDictionary> | Exclude<keyof T, keyof AnyRealmObject | ExtractPropertyNamesOfType<T, AnyDictionary> | ExtractPropertyNamesOfType<...> | ExtractPropertyNamesOfType<...>> | ExtractPropertyNamesOfType<...>' is not assignable to type 'ExtractPropertyNamesOfType<RealmObject<T, never> & T, AnyDictionary> | Exclude<"keys", keyof AnyRealmObject | ExtractPropertyNamesOfType<...> | ExtractPropertyNamesOfType<...> | ExtractPropertyNamesOfType<...>> | ... 13 more ... | ExtractPropertyNamesOfType<...>'. Type 'ExtractPropertyNamesOfType<T, AnyDictionary>' is not assignable to type 'ExtractPropertyNamesOfType<RealmObject<T, never> & T, AnyDictionary> | Exclude<"keys", keyof AnyRealmObject | ExtractPropertyNamesOfType<...> | ExtractPropertyNamesOfType<...> | ExtractPropertyNamesOfType<...>> | ... 13 more ... | ExtractPropertyNamesOfType<...>'. Type 'keyof T' is not assignable to type 'ExtractPropertyNamesOfType<RealmObject<T, never> & T, AnyDictionary> | Exclude<"keys", keyof AnyRealmObject | ExtractPropertyNamesOfType<...> | ExtractPropertyNamesOfType<...> | ExtractPropertyNamesOfType<...>> | ... 13 more ... | ExtractPropertyNamesOfType<...>'. Type 'string | number | symbol' is not assignable to type 'ExtractPropertyNamesOfType<RealmObject<T, never> & T, AnyDictionary> | Exclude<"keys", keyof AnyRealmObject | ExtractPropertyNamesOfType<...> | ExtractPropertyNamesOfType<...> | ExtractPropertyNamesOfType<...>> | ... 13 more ... | ExtractPropertyNamesOfType<...>'. Type 'string' is not assignable to type 'ExtractPropertyNamesOfType<RealmObject<T, never> & T, AnyDictionary> | Exclude<"keys", keyof AnyRealmObject | ExtractPropertyNamesOfType<...> | ExtractPropertyNamesOfType<...> | ExtractPropertyNamesOfType<...>> | ... 13 more ... | ExtractPropertyNamesOfType<...>'.ts(2322)
If i do:
import Realm, {Results} from 'realm'; public createQuery<T>(schema: string): Results<T> { return this._realm.objects(schema); }
I get ts error:
Type 'Results' is not generic. ts(2315)
According to the docs, it should be valid the Realm.Results type
Stacktrace & log output
No response
Can you reproduce the bug?
Always
Reproduction Steps
No response
Version
12.2.0
What services are you using?
Local Database only
Are you using encryption?
No
Platform OS and version(s)
android, iOS
Build environment
RN Version 0.72.5
Cocoapods version
No response