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

180
Views
¿Cómo compilar Typescript a JS que usa módulos ES6?

Mi archivo tsconfig.json contiene

 { "compilerOptions": { "module": "esnext", "target": "esnext", } }

Pero los archivos JS compilados todavía usan exports / require sintaxis.

¿Cómo puedo solucionar esto?

EDITAR:

La estructura de mi directorio es la siguiente

 - APIs/ - emails/ - sendEmail.ts - oldFiles/ - file1.js - file2.js - index.js - tsconfig.json - package.json

Estoy ejecutando tsc usando el comando tsc APIs/emails/sendEmail.ts desde el directorio raíz.

about 4 years ago · Santiago Gelvez
2 answers
Answer question

0

Esas configuraciones son correctas, por lo que lo más probable es que no esté usando ese archivo tsconfig.json . Por ejemplo, si hace tsc someFile.ts , tsc no usa tsconfig.json (sorprendentemente). Su mejor apuesta es probablemente agregar un includes a su configuración (para que tsc sepa lo que está compilando) y luego compilar simplemente invocando tsc , que buscará un tsconfig.json local.

 { "compilerOptions": { "module": "esnext", "target": "esnext" }, "include": ["**/*.ts"] }

Luego en package.json (por ejemplo):

 // ... "scripts": { "build": "tsc" } // ...
about 4 years ago · Santiago Gelvez Report

0

Esta configuración debería funcionar. Pero es tsconfig.json no tsconfig.js .

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