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

139
Vistas
The “module” configuration of TS config does not work?

index.ts

const m = require("./test");
console.log(m.a);

test.ts

module.exports = {
  a: 1,
  b: 2,
};

After compilation

index.js

var m = require("./test");
console.log(m.a);

test.js

module.exports = {
    a: 1,
    b: 2
};

The module specified in tsconfig.json is ES6. It should be compiled into a modular way such as import {a} from 'test'. Why is it still the modular way of commonjs? enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

TypeScript can transpile ES6 (and TypeScript specific) module syntax into an arbitrary module syntax.

It cannot do it the other way round. Write modern code without require and module.exports.

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