In a nodej project open in VsCode with checkJs
enabled, when a json file is required like
const myFile = require('./my-file.json')
This makes an error [ts] Cannot find module
.
How is it possible to remove the error warning?
I tried to:
add
"resolveJsonModule": true
to thecompilerOptions
injsconfig.json
, but it does not work.create a
typing.d.ts
file with this content:declare module '*.json' { const value: any; export default value; }
But now, there is an error[ts] Type 'typeof import("*.json")' must have a '[Symbol.iterator]()' method that returns an iterator. [2488]