Backbone.js application in TypeScript with require.js
Submitted by Erik Wegner on Sat, 07/25/2015 - 10:15
The new GitHub repository contains a rebuild of the Backbone tutorial in TypeScript.
The library Backbone.js is especially useful for maintaining elements and views in the browser. It contains all parts to build single page apps.
There were a few challenges to handle:
- Backbone.js uses an
extendmethod to provide an inheritance mechanism. The TypeScript compiler concurrently has its own extend function. The used definition file hides the Backbone function. Instead, the TypeScript class inheritance is heavily recommended. As a result, several
initializefunctions have been refactored. Registering the
eventsis done in a slightly different way.
importstatements, the result automatically has the corresponding
requirecall. This allows to a) keep the TypeScript files small and b) load files on demand.