1

enter image description herestrong text

Consider using '--resolveJsonModule' to import module with '.json' extension

1
  • Consider using '--resolveJsonModule' to import module with '.json' extension Commented Sep 14, 2019 at 10:30

4 Answers 4

5

open File tsconfig.json and change resolveJsonModule : to true.

{
    resolveJsonModule:true,
}
Sign up to request clarification or add additional context in comments.

Comments

3

Try to solve it this way. Its work for me.
Create file called json-typings.d.ts in src/app folder. and typing file as follows:

declare module "*.json" {
  const value: any;
  export default value;
}

Then you can import Json files just like TypeScript 2.9+.

import * as info from "info.json";

Comments

1

Please add in your tslint.json file

{
   "linterOptions": {
       "exclude": [
          "*.json",
          "**/*.json"
       ]  
   }
}

**/*.json to be recursive

2 Comments

bro how to find tslint.json file??
just hit ctrl + p if windows or if MAC cmd + p and type "tslint.json" if you are using vscode or else just find tslint.json file. this file is created by default when an angular project is created with cli
0

Copy this in your tsconfig.json file , inside compilerOptions:

"resolveJsonModule": true,
"esModuleInterop": true

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.