Add new options, generics, and unit tests for BaseCollection.
Review Request #12913 — Created March 23, 2023 and submitted — Latest diff uploaded
Backbone.Collection) lacked some of the
capabilities available to models and views. It wasn't possible to
provide typed custom options, for example. There were also some mistakes
made with recent changes to specify model types.
This change introduces new generics when subclassing
allowing an interface to be provided for custom options. This mixes into
an interface (now provided in our version of the Backbone typings) of
standard options for the class. The combined results are passed to
constructor. This follows the same
patterns used in
Typings for the model on the collection are now fixed. The attempt at
defining and using a
Subclass<T>didn't work in practice. We only
urlstatic attribute can now be a function, which will be called
properly with the instance as
The default model type for collections is also now
BaseModel, to provide better backwards-compatibility.
Unit tests have been added to test all static attribute/function
behavior. Since our testing uses TypeScript, the type-related issues
were also caught by tests.
Unit tests pass.