Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

203
Views
Typescript doesn't check keys in array object

I have an array that should content an explicit object. By some reason typescript doesn't show me errors if I break this object. I use column object to 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,
}));

Why is this happening and how can it be fixed?

But if I remove method map that make iterations it shows errors

const test:Test[]=[{
    id: '11',
    startDate: "22",
    extraKey:"33"
}];

But I need map.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can try this

const test:Test[]=allCashBackByType.map((item: any): Test => ({
    id: item.id,
    startDate: item.startDate,
    extraKey: '2222'
}));
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!