Skip to content

Commit

Permalink
Eliminates most of the TypeScript compiler errors.
Browse files Browse the repository at this point in the history
Consolidates external references into `_references.d.ts`. This avoids
some repetition of the same references in every single `.ts` file. This
seems to be a common convention, although it seems it's not without its
drawbacks; see this thread:

https://typescript.codeplex.com/discussions/507413

Note that I made it a definitions file instead of a typescript file so
it doesn't generate an unnecessary JavaScript file.

Many of the `tsc` errors were simply due to insufficient specification
of types. Others, like events in views, were more about where they were
declared (at the level of class properties versus inside the
constructor).

The project still does not compile, due to a mismatch between the type
returned by a jQuery selector and the expected type of HTMLInputElement.
I haven't yet figured out how to resolve this. I wonder if we shouldn't
be using `document.getElementsByClassName` instead.

This commit also adds a tsconfig.js file, which is used when `tsc` is
invoked with no arguments. This avoids having to always invoke `tsc`
with `--module amd`.
  • Loading branch information
gotgenes committed May 31, 2015
1 parent fd267d1 commit f2592f0
Show file tree
Hide file tree
Showing 8 changed files with 431 additions and 59 deletions.
4 changes: 4 additions & 0 deletions js/_references.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/// <reference path="lib/require/require.d.ts" />
/// <reference path="lib/jquery/jquery.d.ts" />
/// <reference path="lib/lodash/lodash.d.ts" />
/// <reference path="lib/backbone/backbone.d.ts" />
24 changes: 12 additions & 12 deletions js/app.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
/* Globals - jQuery, $, Backbone, _ */
/// <reference path="lib/jquery/jquery.d.ts"/>
/// <reference path="lib/lodash/lodash.d.ts"/>
/// <reference path="lib/backbone/backbone.d.ts"/>

/// <reference path="_references.d.ts" />

require.config({
baseUrl: "js",
paths: {
"jquery": 'lib/jquery/jquery-2.1.4.min',
"underscore": 'lib/lodash/lodash-min',
"lodash": 'lib/lodash/lodash-min',
"backbone": 'lib/backbone/backbone-min',
"text": 'lib/require/text'
},
shim: {
underscore: {
jquery: {
exports: '$'
},
lodash: {
exports: '_'
},
backbone: {
Expand All @@ -23,10 +22,11 @@ require.config({
}
});


import $ = require('jquery');
import AppView = require('views/app-view');
//import AppView = require('views/app-view');

// Load the application once the DOM is ready
$(() => {
new AppView.AppView();
});
//// Load the application once the DOM is ready
//$(() => {
//new AppView.AppView();
//});
12 changes: 5 additions & 7 deletions js/collections/nest-collection.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import Nest = require('../models/nest-model');

import Nest = require('models/nest-model');

export class NestCollection extends Backbone.Collection<Nest.Nest> {

// Reference to this collection's model.
model = Nest.Nest;
class NestCollection extends Backbone.Collection<Nest> {

// Filter down the list of all nests that are hatched
hatched() {
Expand All @@ -15,4 +11,6 @@ export class NestCollection extends Backbone.Collection<Nest.Nest> {
remaining() {
return this.without.apply(this, this.hatched());
}
}
}

export = NestCollection;
Loading

0 comments on commit f2592f0

Please sign in to comment.