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

168
Views
Corrección de problemas de incompatibilidad de tipos (TypeScript React)

Recibo este error de compilación:

 Type '{ executionTime: number; schema: { \[k: string\]: { name: string; index: number; type: string; }; }; values: Document\[\]\[\]; }' is not assignable to type 'DataGridData'. Types of property 'schema' are incompatible. Type '{ \[k: string\]: { name: string; index: number; type: string; }; }' is not assignable to type 'Schema'. 'string' index signatures are incompatible. Type '{ name: string; index: number; type: string; }' is not assignable to type '{ name: string; index: number; type: SchemaDataType; }'. Types of property 'type' are incompatible. Type 'string' is not assignable to type 'SchemaDataType'.

Se reduce a que el tipo 'cadena' no es compatible con el tipo SchemaDataType definido explícitamente. Aquí está ese tipo definido:

 export type SchemaDataType = | 'DateTime' | 'Decimal' | 'Guid' | 'Int32' | 'String';

'cadena' no se reconoce como 'Cadena'.

 function mapKeys() { const docKeys = Object.keys(items); const result = Object.fromEntries( docKeys.map((el, index) => { return [el, { name: el, index, type: el.constructor.name }]; }), ); return result; }

Esta función que creé transforma la respuesta json en la base de datos en una estructura tangible para un DataGrid personalizado que estoy tratando de implementar. Intenté una solución poniendo en mayúscula la primera letra de 'tipo' así, pero esto no solucionó el problema:

 function mapKeys() { const docKeys = Object.keys(items); const result = Object.fromEntries( docKeys.map((el, index) => { return [ el, { name: el, index, type: el.constructor.name.charAt(0).toUpperCase() + el.constructor.name.slice(1), }, ]; }), ); return result; }
about 4 years ago · Juan Pablo Isaza
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!