Skip to content

Commit 5d69de8

Browse files
committed
Fixed ts typings in todo tutorial
1 parent efe353c commit 5d69de8

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

current/en-us/2. tutorials/1. creating-a-todo-app.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,25 +66,31 @@ export class App {
6666
}
6767

6868
removeTodo(todo) {
69-
let index = this.todos.indexOf(todo);
69+
const index = this.todos.indexOf(todo);
7070
if (index !== -1) {
7171
this.todos.splice(index, 1);
7272
}
7373
}
7474
}
7575
```
7676
```TypeScript src/app.ts [variant]
77-
interface Todo {
77+
interface ITodo {
7878
description: string;
7979
done: boolean;
8080
}
8181

8282
export class App {
83-
heading = "Todos";
84-
todos: Todo[] = [];
85-
todoDescription = '';
83+
heading: string;
84+
todos: ITodo[];
85+
todoDescription: string;
8686

87-
addTodo() {
87+
constructor() {
88+
this.heading = 'Todos';
89+
this.todos = [];
90+
this.todoDescription = '';
91+
}
92+
93+
addTodo(): void {
8894
if (this.todoDescription) {
8995
this.todos.push({
9096
description: this.todoDescription,
@@ -94,8 +100,8 @@ export class App {
94100
}
95101
}
96102

97-
removeTodo(todo) {
98-
let index = this.todos.indexOf(todo);
103+
removeTodo(todo: ITodo): void {
104+
const index = this.todos.indexOf(todo);
99105
if (index !== -1) {
100106
this.todos.splice(index, 1);
101107
}

0 commit comments

Comments
 (0)