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

290
Visualizações
Why is this code causing a parsing error when using the coalesce operator

I am not sure what I updated in my React project, but I started getting a parsing error trying to build my project. I am certain (honestly) that this worked fine some time in the recent past. (source file is a .tsx file) Thoughts?

const titles = new Map<number, string>();
resources.forEach((e: any) => {
    // titles.set(
    //     e.StoreHierarchyValueId ?? e.SkuHierarchyValueId, e.Value
    // )
    if (e.StoreHierarchyValueId)
        titles.set(e.StoreHierarchyValueId, e.Value);
    else
        titles.set(e.SkuHierarchyValueId, e.Value);

    });

When I had the commented out code in place, "npm run build" would error out with the following less than helpful (to me) message:

Module parse failed: Unexpected token (51:822) You may need an appropriate loader to handle this file type. | // [] | // ); function retrieveCustomerResources(){console.log('"',env,'", "',customer,'"');if(env!==''&&env!==undefined&&customer!==''&&customer!==undefined){setLoadingResources(true);axios.get("/"+props.urlPart+"Hierarchy/"+env+"/"+customer).then(function(response){setResources(response.data);}).catch(function(error){console.log(error);}).then(function(){setLoadingResources(false);});}}if(env==="")return/#PURE/React.createElement("div",null,"No HT environment seleted");if(loadingResources){return/#PURE/React.createElement("div",null,"Loading "+props.urlPart+" Data for..."+customer);}if(resources===null||resources.length===0){return/#PURE/React.createElement("div",null,"No "+props.urlPart+" Data for..."+customer);}var titles=new Map();resources.forEach(function(e){return titles.set(e.StoreHierarchyValueId??e.SkuHierarchyValueId,e.Value);});var parentMap=new Map();resources.forEach(function(f){f.subRows=[];parentMap.set(f.StoreHierarchyValueId??f.SkuHierarchyValueId,f.subRows);});resources.forEach(function(f,_i){var v=parentMap.get(f.ParentId);if(!v){parentMap.set(f.ParentId,[f]);}else{v.push(f);}});var data=resources.filter(function(e){return e.ParentId===0;});// function Table({ columns, data, renderRowSubComponent } | // : { columns: any, data: any, renderRowSubComponent: any } | // ): any {

The problematic code was no where near line 51. The only way I figured this out was by commenting out sections of code until it compiled successfully.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Thanks to @Mike'Pomax'Kamermans and @epascarello. It was definitely my tooling options.

I was using eslint and typescript. My .tsconfig file had a target of "es5" (not sure how that got set, but anyways...) Once I changed it to ES6, the problem naturally went away.

about 4 years ago · Juan Pablo Isaza Relatório
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