Implement a simple task management application that allows users to create, retrieve, update, and delete tasks. The application should maintain an in-memory list of tasks with the following specific requirements:
Task Structure: Each task should be represented as an object with the following properties:
id (a unique identifier, which is an integer)
title (a string representing the title of the task)
completed (a boolean indicating whether the task is completed)
Functionality Requirements:
Create Task: Implement a function createTask(title: string) -> Task that creates a new task with the given title, assigns a unique ID, and sets the completed status to false. It should return the newly created task.
Get Task: Implement a function getTask(id: int) -> Task that retrieves a task by its ID. If the task is not found, it should return null.
Update Task: Implement a function updateTask(id: int, title: string | null, completed: boolean | null) -> Task that updates the task with the specified ID. The title and completed parameters should be optional; if they are null, they should not be updated. It should return the updated task.
Delete Task: Implement a function deleteTask(id: int) -> boolean that deletes the task with the specified ID and returns true if the task was successfully deleted, or false if the task was not found.
List Tasks: Implement a function listTasks() -> Task[] that returns an array of all tasks.
Use Cases:
Ensure that creating a task returns a task with a unique ID and the correct initial properties.
Ensure that retrieving a task by ID returns the correct task object.
Ensure that updating a task modifies only the specified fields and preserves the rest.
Ensure that deleting a task removes it from the task list and returns the appropriate boolean value.
Ensure that listing tasks returns the correct array of task objects.
All implementations should be placed in the /app/ directory, within a file named taskManager.js.
Make sure to provide appropriate error handling for both the retrieval and deletion functions to manage cases where a non-existent task ID is accessed.