I am dealing with an issue where my TypeScript does not flag errors when I break an object in an array. The column object is being used for a Knex query.
type Test = {
id: string;
startDate: string;
percentDebitCard: number,
}
const column = {
id: 'bct.id',
startDate: 'bct.startDate',
percentDebitCard: 'bct.percentDebitCard',
};
const allCashBackByType:any=[{
id: "bla",
startDate: "bla",
endDate: "bla",
someKey:"bla",
someKey1:"bla",
someKey2:"bla",
someKey3:"bla"
}]
const test:Test[]=allCashBackByType.map((item: typeof column):Test => ({
id: item.id,
startDate: item.startDate,
percentDebitCard: item.percentDebitCard as number,
}));
What could be causing this issue and how can I resolve it?
Interestingly, if I remove the map method that iterates over the array, error messages are shown.
const test:Test[]=[{
id: '11',
startDate: "22",
extraKey:"33"
}];
However, I do require the use of map.