-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
1 - XS (<= 1 day)
-
4477
How frequently does the bug occur?
All the time
Description
When trying to add a subscription to a collection result, I get a type error if the collection query was based on class based models.
For example:
Unable to find source-code formatter for language: typescript. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
//works realm.subscriptions.update(mutableSubs => { mutableSubs.add(realm.objects("Task")); }); //doesn't work realm.subscriptions.update(mutableSubs => { mutableSubs.add(realm.objects(Task)); });
My class:
Unable to find source-code formatter for language: typescript. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
export class Task extends Realm.Object { _id!: Realm.BSON.ObjectId; description!: string; isComplete!: boolean; createdAt!: Date; userId!: string; // To use a class as a Realm object type, define the object schema on the static property "schema". static schema = { name: 'Task', primaryKey: '_id', properties: { _id: 'objectId', description: 'string', isComplete: {type: 'bool', default: false}, createdAt: 'date', userId: 'string', }, }; }
Stacktrace & log output
Unable to find source-code formatter for language: shell. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
Type error: Argument of type 'Results<Task>' is not assignable to parameter of type 'Results<Task & Object>'. Type 'Task' is not assignable to type 'Task & Object'. Type 'Task' is not assignable to type 'Object'. Types of property 'addListener' are incompatible. Type '(callback: ObjectChangeCallback<Task>) => void' is not assignable to type '(callback: ObjectChangeCallback<Object>) => void'. Types of parameters 'callback' and 'callback' are incompatible. Types of parameters 'object' and 'object' are incompatible. Type 'Task' is not assignable to type 'Object'. Types of property 'addListener' are incompatible. Type '(callback: ObjectChangeCallback<Task>) => void' is not assignable to type '(callback: ObjectChangeCallback<Object>) => void'. Types of parameters 'callback' and 'callback' are incompatible. Types of parameters 'changes' and 'changes' are incompatible. Type 'ObjectChangeSet<Task>' is not assignable to type 'ObjectChangeSet<Object>'. Type 'Object' is missing the following properties from type 'Task': _id, description, isComplete, createdAt, userIdts(2345)
Can you reproduce the bug?
Yes, always
Reproduction Steps
☝
Version
10.12.0
What SDK flavour are you using?
MongoDB Realm (i.e. Sync, auth, functions)
Are you using encryption?
No, not using encryption
Platform OS and version(s)
macOS
Build environment
Which debugger for React Native: ..
Cocoapods version
No response