I have a sample object array structured like this:
tasks: todo = [
{
title: string,
status: number,
description: string,
date: Date,
priority: number
}
]
To handle this, I created an Interface as follows:
interface todo {
[index: number]:{
title: string;
status: number;
description: string;
date: Date;
priority: number;
}
}
However, when I assign this interface to a variable with the object array, I encounter these errors: Property 'filter' does not exist on type 'todo' and Property 'sort' does not exist on type 'todo'. How can I avoid these errors?
EDIT : Problem Solved:
export interface todo extends Array <{
title: string;
status: number;
description: string;
date: Date;
priority: number;
}> {}
Another useful approach is mentioned here:
interface Todo {
title: string;
status: number;
description: string;
date: Date;
priority: number;
}
// tasks is an array of Todo
tasks: Todo[] = [...];