Alex Eagle 643c71740e 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
2015-08-06 16:57:52 -07:00

47 lines
1.3 KiB
TypeScript

import {bootstrap, NgFor, Component, View} from 'angular2/bootstrap';
import {Store, Todo, TodoFactory} from './services/TodoStore';
@Component({selector: 'todo-app', viewBindings: [Store, TodoFactory]})
@View({templateUrl: 'todo.html', directives: [NgFor]})
class TodoApp {
todoEdit: Todo = null;
constructor(public todoStore: Store, public factory: TodoFactory) {}
enterTodo(inputElement): void {
this.addTodo(inputElement.value);
inputElement.value = '';
}
editTodo(todo: Todo): void { this.todoEdit = todo; }
doneEditing($event, todo: Todo): void {
var which = $event.which;
var target = $event.target;
if (which === 13) {
todo.title = target.value;
this.todoEdit = null;
} else if (which === 27) {
this.todoEdit = null;
target.value = todo.title;
}
}
addTodo(newTitle: string): void { this.todoStore.add(this.factory.create(newTitle, false)); }
completeMe(todo: Todo): void { todo.completed = !todo.completed; }
deleteMe(todo: Todo): void { this.todoStore.remove(todo); }
toggleAll($event): void {
var isComplete = $event.target.checked;
this.todoStore.list.forEach((todo: Todo) => { todo.completed = isComplete; });
}
clearCompleted(): void { this.todoStore.removeBy((todo: Todo) => todo.completed); }
}
export function main() {
bootstrap(TodoApp);
}