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

414
Views
Cómo tener el nivel superior en espera en TypeScript (cambiar de commonjs a esnext) sin tener que cambiar todas las importaciones para que terminen .js

Me gustaría tener un nivel superior en espera en mi proyecto TypeScript Nodejs.

Mi tsconfig solía verse así:

 { "compilerOptions": { "target": "es2017", "module": "commonjs", "lib": [ "dom", "es6", "es2017", "esnext.asynciterable" ], "skipLibCheck": true, "sourceMap": true, "outDir": "./dist", "moduleResolution": "node", #### other stuff which I think is not relevant removed ####

Y ahora lo cambié a

 { "compilerOptions": { "target": "esnext", "module": "esnext", "lib": [ "dom", "es6", "es2017", "esnext.asynciterable" ], "skipLibCheck": true, "sourceMap": true, "outDir": "./dist", "moduleResolution": "node", #### other stuff which I think is not relevant removed ####

También agregué "type": "module" a mi paquete.json. De hecho, ahora tengo la capacidad de hacer esperas de alto nivel sin embargo

  1. Necesito cambiar cada importación para agregar la extensión de archivo .js
  2. Para las carpetas donde agregué un index.ts para exportar todos los módulos, anteriormente solo podía importar el nombre de la carpeta. Ahora necesito importar nombre de carpeta/index.js
  3. Cuando agrego automáticamente una importación con vscode, la agrega sin .js

La forma en que es con commonjs es muy elegante: ¿puedo tener el mismo comportamiento con esnext o mantenerlo de otra manera mientras obtengo la espera de nivel superior?

about 4 years ago · Santiago Gelvez
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!