Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

167
Visualizações
Fixing Type incompatibility issues (TypeScript React)

I am receiving this build error:

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'.

It boils down to type 'string' not being compatible with explicitly defined type SchemaDataType. Here is that defined type:

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

'string' is not being recognized as 'String'.

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

This function I created transforms the json response in the DB to a palitable structure for a custom DataGrid that I am trying to implement. I attemted a fix by capitalizing the first letter of 'type' like so but this did not fix the issue:

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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda