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

311
Vistas
How to enable type checking of mjs files in VS Code

I have a project with js files, where I enabled type checking across multiple modules (highlighting wrong parameters etc of function imported from different module) in VS Code by creating this jsconfig.json:

{
  "compilerOptions": {
    "checkJs": true
  }
}

Now, I read that typescript 4.5 supports mjs files https://github.com/microsoft/TypeScript/issues/27957

So I installed typescript 4.5 beta, node 17, and modified jsconfig.json to this:

{
  "compilerOptions": {
    "module": "node12",
    "moduleResolution": "node",
    "checkJs": true
  }
}

but it still doesn't work for mjs files, and I also get this error in jsconfig.json:

Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'esnext'

Any idea how to enable type checking for mjs files across multiple modules?

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

0

Consider using these tsconfig.json options:

{
  "compilerOptions": {
    "module": "NodeNext",
    "target": "ESNext",
    "moduleResolution": "NodeNext"
  },
  "include": ["**/*.mjs"]
}

=======

Here's ALL the changes I did along with adding .mjs support. I don't think they are all strictly necessary, but I want to share for completeness:

Modified my package.json type-check script:

"type-check": "tsc --pretty --noEmit && tsc --pretty --noEmit --project tsconfig.mjs.json",

Here's my tsconfig.mjs.json file:

{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "module": "NodeNext",
    "target": "ESNext",
    "moduleResolution": "NodeNext"
  },
  "include": ["**/*.mjs"]
}

Run:

yarn add @typescript-eslint/eslint-plugin @typescript-eslint/parser --dev
yarn remove typescript
yarn add typescript # use latest

Likely, you will get an error that you need to use typescript nightly build to actually type-check mjs files. Run:

yarn remove typescript
yarn add typescript@next --dev
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