mirror of
https://github.com/status-im/realm-js.git
synced 2025-02-05 11:13:48 +00:00
Fix type definitions - generics return <T & Object> (#2110)
* Be explicit that the return type of generic methods will be an intersection with Object
This commit is contained in:
parent
f0fc556f6e
commit
0b14436dc4
@ -6,6 +6,7 @@ x.x.x Release notes (yyyy-MM-dd)
|
|||||||
### Fixed
|
### Fixed
|
||||||
* <How to hit and notice issue? what was the impact?> ([#????](https://github.com/realm/realm-js/issues/????), since v?.?.?)
|
* <How to hit and notice issue? what was the impact?> ([#????](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)
|
* 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<T>`, `Realm.objectForPrimaryKey<T>`, etc. is an intersection of `T & Realm.Object`. ([#1838](https://github.com/realm/realm-js/issues/1838))
|
||||||
|
|
||||||
### Compatibility
|
### Compatibility
|
||||||
* Realm Object Server: 3.11.0 or later.
|
* Realm Object Server: 3.11.0 or later.
|
||||||
|
8
lib/index.d.ts
vendored
8
lib/index.d.ts
vendored
@ -118,7 +118,7 @@ declare namespace Realm {
|
|||||||
/**
|
/**
|
||||||
* @returns Results<T>
|
* @returns Results<T>
|
||||||
*/
|
*/
|
||||||
linkingObjects<T>(objectType: string, property: string): Results<T>;
|
linkingObjects<T>(objectType: string, property: string): Results<T & Realm.Object>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns number
|
* @returns number
|
||||||
@ -701,7 +701,7 @@ declare class Realm {
|
|||||||
* @param {Realm.ObjectSchema} object schema describing the object that should be created.
|
* @param {Realm.ObjectSchema} object schema describing the object that should be created.
|
||||||
* @returns {T}
|
* @returns {T}
|
||||||
*/
|
*/
|
||||||
static createTemplateObject<T>(objectSchema: Realm.ObjectSchema): T;
|
static createTemplateObject<T>(objectSchema: Realm.ObjectSchema): T & Realm.Object;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete the Realm file for the given configuration.
|
* Delete the Realm file for the given configuration.
|
||||||
@ -753,13 +753,13 @@ declare class Realm {
|
|||||||
* @param {number|string} key
|
* @param {number|string} key
|
||||||
* @returns {T | undefined}
|
* @returns {T | undefined}
|
||||||
*/
|
*/
|
||||||
objectForPrimaryKey<T>(type: string | Realm.ObjectType | Function, key: number | string): T | undefined;
|
objectForPrimaryKey<T>(type: string | Realm.ObjectType | Function, key: number | string): T & Realm.Object | undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string|Realm.ObjectType|Function} type
|
* @param {string|Realm.ObjectType|Function} type
|
||||||
* @returns Realm
|
* @returns Realm
|
||||||
*/
|
*/
|
||||||
objects<T>(type: string | Realm.ObjectType | Function): Realm.Results<T>;
|
objects<T>(type: string | Realm.ObjectType | Function): Realm.Results<T & Realm.Object>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} name
|
* @param {string} name
|
||||||
|
Loading…
x
Reference in New Issue
Block a user