Avatar ·

Error: 'this' implicitly has type 'any' because it does not have a type annotation in TypeScript

Hello! I started learning TypeScript and encountered an error that I can't fix. I have a simple class that manages a task list: ```typescript class TaskList { tasks: string[] = []; addTask(task: string) { this.tasks.push(task); console.log(`Added: ${task}`); } printTasks() { this.tasks.forEach(function(task) { console.log(`${task} - added by ${this.name}`); }); } } const myList = new TaskList(); myList.addTask("Learn TypeScript"); myList.printTasks(); ``` When I compile this code, I get the error: ``` 'this' implicitly has type 'any' because it does not have a type annotation ``` The error points to the line `console.log(`${task} - added by ${this.name}`);` inside the `forEach` method. I understand that `t