Why does TypeScript allow the code below, despite it containing a type error that I would expect?
export interface Structure {
aaa: string;
}
export function f1(): Structure[] { // TypeScript is fine with this, but not me
const result = [].map(certState => {
return {
aaa: 'aaa',
ADDITIONAL_FIELD: 'asdf'
}
});
return result;
}
export function f2(): Structure[] { // TypeScript catches the error (unlike me)
return [
{
aaa: 'sdf',
ADDITIONAL_FIELD: 'asdf'
}
]
}
Appreciate your help!