the paramaters a
and b
are both typed any
because you haven't annotated them with a type.
orderFunction (a: { value: string; name: string; }, b: { value: string; name: string; }) {
if (a.wrong > b.wrong) {
return 1;
} else {
return -1;
}
}
or in a generic way
orderFunction<T> (a: T, b: T) {
if (a.wrong > b.wrong) {
return 1;
} else {
return -1;
}
}
will give you the desired error because the type { value: string; name: string; }
does not have a wrong
property.
If you don't want implicit any
to be a thing you can set noImplicitAny: true
in your tsconfig.json
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…