chore(build): enable type-checking for TypeScript ES6 emit.

This requires delicate handling of type definitions which collide, because
we use TypeScript-provided lib.d.ts for --target=es5 and lib.es6.d.ts for
--target=es6.
We need to include our polyfill typings only in the --target=es5 case,
and the usages have to be consistent with lib.es6.d.ts.
Also starting with this change we now typecheck additional modules,
so this fixes a bunch of wrong typings which were never checked before.

Fixes #3178
This commit is contained in:
Alex Eagle
2015-08-06 09:52:33 -07:00
parent 40a3cd2ab1
commit 643c71740e
35 changed files with 88 additions and 83 deletions

View File

@ -1,5 +1,5 @@
import {Component, View, NgFor} from 'angular2/angular2';
import {Http} from 'angular2/http';
import {Http, Response} from 'angular2/http';
import {ObservableWrapper} from 'angular2/src/facade/async';
@Component({selector: 'http-app'})
@ -17,6 +17,7 @@ import {ObservableWrapper} from 'angular2/src/facade/async';
export class HttpCmp {
people: Object;
constructor(http: Http) {
ObservableWrapper.subscribe(http.get('./people.json'), res => this.people = res.json());
ObservableWrapper.subscribe<Response>(http.get('./people.json'),
res => this.people = res.json());
}
}

View File

@ -1,4 +1,4 @@
/// <reference path="../../../angular2/typings/rx/rx.all.d.ts" />
/// <reference path="../../../angular2/typings/rx/rx.d.ts" />
import {bootstrap} from 'angular2/bootstrap';
import {httpInjectables} from 'angular2/http';

View File

@ -1,4 +1,4 @@
/// <reference path="../../../angular2/typings/rx/rx.all.d.ts" />
/// <reference path="../../../angular2/typings/rx/rx.d.ts" />
import {bootstrap} from 'angular2/bootstrap';
import {jsonpInjectables} from 'angular2/http';

View File

@ -1,5 +1,5 @@
import {Component, View, NgFor} from 'angular2/angular2';
import {Jsonp} from 'angular2/http';
import {Jsonp, Response} from 'angular2/http';
import {ObservableWrapper} from 'angular2/src/facade/async';
@Component({selector: 'jsonp-app'})
@ -17,7 +17,7 @@ import {ObservableWrapper} from 'angular2/src/facade/async';
export class JsonpCmp {
people: Object;
constructor(jsonp: Jsonp) {
ObservableWrapper.subscribe(jsonp.get('./people.json?callback=JSONP_CALLBACK'),
res => this.people = res.json());
ObservableWrapper.subscribe<Response>(jsonp.get('./people.json?callback=JSONP_CALLBACK'),
res => this.people = res.json());
}
}

View File

@ -1,13 +1,4 @@
import {
bootstrap,
onChange,
NgIf,
NgFor,
Component,
Directive,
View,
Host
} from 'angular2/bootstrap';
import {bootstrap, NgIf, NgFor, Component, Directive, View, Host} from 'angular2/bootstrap';
import {formDirectives, NgControl, Validators, NgFormModel, FormBuilder} from 'angular2/forms';
import {RegExpWrapper, print, isPresent} from 'angular2/src/facade/lang';

View File

@ -1,6 +1,5 @@
import {
bootstrap,
onChange,
NgIf,
NgFor,
Component,

View File

@ -1,6 +1,5 @@
import {
bootstrap,
onChange,
NgIf,
NgFor,
Component,

View File

@ -8,7 +8,7 @@ import {
Location,
RouteParams
} from 'angular2/router';
import {Http} from 'angular2/http';
import {Http, Response} from 'angular2/http';
import {ObservableWrapper, PromiseWrapper} from 'angular2/src/facade/async';
import {ListWrapper} from 'angular2/src/facade/collection';
import {isPresent} from 'angular2/src/facade/lang';
@ -63,7 +63,8 @@ class DbService {
getData() {
var p = PromiseWrapper.completer();
ObservableWrapper.subscribe(this.http.get('./db.json'), (resp) => { p.resolve(resp.json()); });
ObservableWrapper.subscribe<Response>(this.http.get('./db.json'),
(resp) => { p.resolve(resp.json()); });
return p.promise;
}

View File

@ -1,6 +1,5 @@
import {
bootstrap,
onChange,
NgIf,
NgFor,
Component,

View File

@ -38,7 +38,7 @@ class TodoApp {
this.todoStore.list.forEach((todo: Todo) => { todo.completed = isComplete; });
}
clearCompleted(): void { this.todoStore.removeBy((todo) => todo.completed); }
clearCompleted(): void { this.todoStore.removeBy((todo: Todo) => todo.completed); }
}
export function main() {

View File

@ -1,5 +1,5 @@
import {Injectable} from 'angular2/angular2';
import {ListWrapper} from 'angular2/src/facade/collection';
import {ListWrapper, Predicate} from 'angular2/src/facade/collection';
// base model for RecordStore
export class KeyModel {
@ -30,7 +30,7 @@ export class Store {
remove(record: KeyModel): void { this._spliceOut(record); }
removeBy(callback: Function): void {
removeBy(callback: Predicate<KeyModel>): void {
var records = ListWrapper.filter(this.list, callback);
ListWrapper.removeAll(this.list, records);
}

View File

@ -56,5 +56,5 @@ export class TodoApp {
this.todoStore.list.forEach((todo: Todo) => { todo.completed = this.isComplete; });
}
clearCompleted(): void { this.todoStore.removeBy((todo) => todo.completed); }
clearCompleted(): void { this.todoStore.removeBy((todo: Todo) => todo.completed); }
}

View File

@ -1,5 +1,5 @@
import {Injectable} from 'angular2/angular2';
import {ListWrapper} from 'angular2/src/facade/collection';
import {ListWrapper, Predicate} from 'angular2/src/facade/collection';
// base model for RecordStore
export class KeyModel {
@ -34,7 +34,7 @@ export class Store {
remove(record: KeyModel): void { this._spliceOut(record); }
removeBy(callback: Function): void {
removeBy(callback: Predicate<KeyModel>): void {
var records = ListWrapper.filter(this.list, callback);
ListWrapper.removeAll(this.list, records);
}