Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

295
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda