I'm trying to figure out whether my object is an instance of interface Group
or interface User
. Here is my code
interface Group {
id: string,
name: string
}
interface User {
id: string,
name: string,
age: number,
contact:number
}
Now, when at some place when I try to filter out a list on the basis of instance type as
// rows is an array of mixed objects(Group & User), I want to filter out Group objects
rows=rows.filter((row:any)=> {
return row instanceof Employee; // Here it gives the error...
});
It gives the error as
'Employee' only refers to a type, but is being used as a value here.
Please, guide me how I can filter the list based on object type?