Avatar ·

How to remove an element from an array in TypeScript? Detailed guide

Hello everyone! I'm new to TypeScript and I've encountered a problem with removing elements from an array. I've searched through tons of forums but still haven't figured out how to do it correctly in TypeScript with type safety. I have a simple interface for a task list: ```typescript interface Task { id: number; title: string; completed: boolean; } ``` And an array of tasks: ```typescript const tasks: Task[] = [ { id: 1, title: 'Buy milk', completed: false }, { id: 2, title: 'Do homework', completed: true }, { id: 3, title: 'Call a friend', completed: false } ]; ``` I want to remove a task by its id. In JavaScript I usually used `splice()` or `filter()`, but in TypeScript I get type errors. For example, when I write: ```typescript const index = tasks.findIndex(t