diff --git a/CHANGELOG.md b/CHANGELOG.md index 89a66dcf..cb5fee60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ x.x.x Release notes (yyyy-MM-dd) ### Fixed * ([#????](https://github.com/realm/realm-js/issues/????), since v?.?.?) * Removed calls to `new Buffer()` as this is deprecated with Node 10. ([#2107](https://github.com/realm/realm-js/issues/2107), since 2.19.0) +* Updated the type definitions to be explicit that the return type of the generics `Realm.objects`, `Realm.objectForPrimaryKey`, etc. is an intersection of `T & Realm.Object`. ([#1838](https://github.com/realm/realm-js/issues/1838)) ### Compatibility * Realm Object Server: 3.11.0 or later. diff --git a/lib/index.d.ts b/lib/index.d.ts index 1582d2d6..c808be80 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -118,7 +118,7 @@ declare namespace Realm { /** * @returns Results */ - linkingObjects(objectType: string, property: string): Results; + linkingObjects(objectType: string, property: string): Results; /** * @returns number @@ -701,7 +701,7 @@ declare class Realm { * @param {Realm.ObjectSchema} object schema describing the object that should be created. * @returns {T} */ - static createTemplateObject(objectSchema: Realm.ObjectSchema): T; + static createTemplateObject(objectSchema: Realm.ObjectSchema): T & Realm.Object; /** * Delete the Realm file for the given configuration. @@ -753,13 +753,13 @@ declare class Realm { * @param {number|string} key * @returns {T | undefined} */ - objectForPrimaryKey(type: string | Realm.ObjectType | Function, key: number | string): T | undefined; + objectForPrimaryKey(type: string | Realm.ObjectType | Function, key: number | string): T & Realm.Object | undefined; /** * @param {string|Realm.ObjectType|Function} type * @returns Realm */ - objects(type: string | Realm.ObjectType | Function): Realm.Results; + objects(type: string | Realm.ObjectType | Function): Realm.Results; /** * @param {string} name