interface ObjINF1 {
[key: string]: string | number | undefined;
}
interface ObjINF2 {
id: number;
title: string;
}
function a1(objArr: ObjINF1[]) {
}
function a2(objArr: ObjINF2[]) {
// Argument of type 'ObjINF2[]' is not assignable to parameter of type 'ObjINF1[]'.Type 'ObjINF2' is not assignable to type 'ObjINF1'. Index signature is missing in type 'ObjINF2'.
a1(objArr)
}
function a3(objArr: {
id: number;
title: string;
}[]) {
a1(objArr)
}
为什么a2报错了 a3 反而正确