mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 14:57:10 +00:00
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:
@@ -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');
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -34,7 +34,7 @@ declare module 'backbone' {
|
||||
|
||||
fetchRelated(key:string, options?:any, update?:boolean):any;
|
||||
|
||||
toJSON():any;
|
||||
toJSON(options?: any):any;
|
||||
|
||||
static setup();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user