February 2019
Beginner
694 pages
18h 4m
English
The declaration file for Backbone has also added generic syntax to some class definitions. This brings with it further strong typing benefits when writing TypeScript code for Backbone. Backbone collections (surprise, surprise) house a collection of Backbone models, allowing us to define collections in TypeScript as follows:
class NoteCollection extends Backbone.Collection<NoteModel> { model = NoteModel;}
Here, we have a NoteCollection that derives from or extends a Backbone.Collection, but also uses generic syntax to constrain the collection to handle only objects of type NoteModel. This means that any of the standard collection functions, such as at() or pluck(), will be strongly typed to return NoteModel models, further ...
Read now
Unlock full access