File tree Expand file tree Collapse file tree 1 file changed +14
-8
lines changed
current/en-us/2. tutorials Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Original file line number Diff line number Diff 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
8282export 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 }
You can’t perform that action at this time.
0 commit comments