fix(@types/backbone-relational): Add toJSON options

The Backbone-relational library allows passing in `options` to
`RelationalModel.toJSON` [1], similar to the `Backbone.Model.toJSON`
typing [2]. This applies the same signature from the Backbone.Model
typing [2].

[1] https://github.com/PaulUithol/Backbone-relational/blob/6ce19db76bf4cf45048c8859982ebc3228379a54/backbone-relational.js#L1580
[2] https://github.com/DefinitelyTyped/DefinitelyTyped/blob/68c38a850c846788505bc8fd34398e19136983e0//types/backbone/index.d.ts#L127
This commit is contained in:
Sagie Maoz
2019-01-17 17:07:21 -05:00
parent 272bcf47b2
commit 8015333ea3
2 changed files with 2 additions and 1 deletions
@@ -74,6 +74,7 @@ paul.get('livesIn'); // === ourHouse
// You can control which relations get serialized to JSON, using the 'includeInJSON'
// property on a Relation. Also, each object will only get serialized once to prevent loops.
alert(JSON.stringify(paul.get('user').toJSON(), null, '\t'));
alert(JSON.stringify(paul.get('user').toJSON({ option1: 'value1' }), null, '\t'));
// Load occupants 'person-2' and 'person-5', which don't exist yet, from the server
ourHouse.fetchRelated('occupants');
+1 -1
View File
@@ -34,7 +34,7 @@ declare module 'backbone' {
fetchRelated(key:string, options?:any, update?:boolean):any;
toJSON():any;
toJSON(options?: any):any;
static setup();