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

195
Views
Typescript no verifica las claves en el objeto de matriz

Tengo una matriz que debería contener un objeto explícito. Por alguna razón, mecanografiado no me muestra errores si rompo este objeto. Uso el objeto de columna para la consulta knex.

 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, }));

¿Por qué sucede esto y cómo se puede solucionar?

Pero si elimino el mapa de métodos que hacen iteraciones, muestra errores

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

Pero necesito un mapa.

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

0

Puedes probar esto

 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!