error TS5071: Option '--resolveJsonModule' can only be specified when module code generation is 'commonjs', 'amd', 'es2015' or 'esNext'
TypeScript Version: 3.4.3
Search Terms: TS5071
Expected behavior:
Should compile for module: 'system'. I use a json-loader plugin within systemJS to load these json files. Earlier we used the .d.ts for json but with the latest upgrade it fails with the above error.
Related Issues: https://github.com/Microsoft/TypeScript/issues/26224
If I see correctly, I also faced this one, and wondered why, any recomendations on how to make node16 tsconfig work with resolveJsonModule, module amd seems the only fit.
I know this is not a full reprex but represents the gist of it, see below
tsc --version
Version 5.0.4
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": ["@tsconfig/node16/tsconfig.json"],
"compilerOptions": {
"outFile": "dist/bundle.js",
"incremental": true,
// amd compiles ok
// "module": "AMD",
// system throws an error
"module": "System",
"resolveJsonModule": true
},
"include": ["src"]
}
tsconfig.json:11:5 - error TS5071: Option '--resolveJsonModule' can only be specified when module code generation is 'commonjs', 'amd', 'es2015' or 'esNext'.
11 "module": "System",
~~~~~~~~
tsconfig.json:12:5 - error TS5071: Option '--resolveJsonModule' can only be specified when module code generation is 'commonjs', 'amd', 'es2015' or 'esNext'.
12 "resolveJsonModule": true
~~~~~~~~~~~~~~~~~~~
If one decides to use "module": "commonjs", you will get.
tsconfig.json:6:5 - error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile.
In short trying to use resolveJsonModule with outFile with node16's tsconfig seems to be quite complicated, any help appreciated, thanks in advance.