Given the following:
interface MyInterface {
type: string;
}
let arr: object[] = [ {type: 'asdf'}, {type: 'qwerty'}]
// Alphabetical sort
arr.sort((a: MyInterface, b: MyInterface) => {
if (a.type < b.type) return -1;
if (a.type > b.type) return 1;
return 0;
});
Can someone help decipher the TS error:
// TypeScript Error
[ts]
Argument of type '(a: MyInterface, b: MyInterface) => 0 | 1 | -1' is not assignable to parameter of type '(a: object, b: object) => number'.
Types of parameters 'a' and 'a' are incompatible.
Type '{}' is missing the following properties from type 'MyInterface': type [2345]