TypeStrong / atom-typescript

The only TypeScript package you will ever need
https://atom.io/packages/atom-typescript
MIT License
1.13k stars 205 forks source link

resolveJsonModule option dosen't take effect to the tslint #1497

Closed brandonccx closed 5 years ago

brandonccx commented 5 years ago

According to the docs: https://www.typescriptlang.org/docs/handbook/compiler-options.html

I set resolveJsonModule and esModuleInterop to true in my tsconfig.json

{
  "compilerOptions": {
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "allowSyntheticDefaultImports": true,
    "target": "ES5",
    "resolveJsonModule": true,
    "esModuleInterop": true
  }
}

But atom still shows the type error: Can't find module './xxxx.json'.

The ts complier can compile correctly and without error in cmd, if I remove the two options above, ts complier will also throw the error. It seems like the atom plugin doesn't support the "resolveJsonModule" option ?

I don't want to add a module declaration for JSON file since I use the typescript 3.0+, JSON imports has been supported via compilerOptions config.

Any one can help me? Thank you very much :)

lierdakil commented 5 years ago

Can't reproduce, works well enough for me, with a caveat that changing resolveJsonModule option apparently requires a restart of tsserver (hint: use typescript:restart-all-servers command)

If restart doesn't help, then triple-check that the tsconfig.json you're editing is indeed related to the project where you want to import JSON modules, and the TypeScript version that Atom is using. All of that information is accessible via Atom's status panel: Active typescript version box Tsconfig file path box

brandonccx commented 5 years ago

typescript:restart-all-servers command makes it work properly, thank you so much, @lierdakil