خطأ "this" له ضمنيًا نوع "any" بسبب عدم وجود تعليق توضيحي للنوع في TypeScript
مرحبًا! بدأت في تعلم TypeScript وواجهت خطأً لا أستطيع إصلاحه. لدي class بسيط يدير قائمة المهام:\n\n```typescript\nclass TaskList {\n tasks: string[] = [];\n\n addTask(task: string) {\n this.tasks.push(task);\n console.log(`Added: ${task}`);\n }\n\n printTasks() {\n this.tasks.forEach(function(task) {\n console.log(`${task} - added by ${this.name}`);\n });\n }\n}\n\nconst myList = new TaskList();\nmyList.addTask("Learn TypeScript");\nmyList.printTasks();\n```\n\nعندما أقوم بتجميع هذا الكود، أحصل على الخطأ:\n\n```\n'this' implicitly has type 'any' because it does not have a type annotation\n```\n\nيشير الخطأ إلى السطر `console.log(`${task} - added by ${this.name}`);` داخل method `forEach`. أفهم أن `t