0

A really nice feature of angular 7 is the support for typescript 3.1:

https://alligator.io/angular/angular-7/

I've Added the following 3 lines to the tsconfig.json file - under the 'compilerOptions' section:

"resolveJsonModule": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true

Everything looks good - i can iterate over my json file without a problem.

But for some reason i'm getting a "TS2307: Cannot find module " error in my IDE:

enter image description here

I've tried changing the import syntax to the suggestions in here: Importing json file in TypeScript

But without success.

Any ideas?

Edit: I use Webstorm as an IDE.

Rot-man
  • 18,045
  • 12
  • 118
  • 124

2 Answers2

2

So you didn't mention the IDE you were using but I use VSCode and what helped me was adding:

"angularCompilerOptions": {
"annotateForClosureCompiler": false  
}

To src/tsconfig.app.json

And I no longer have importing issues, with my IDE with .json files. Pro tip, try:

import { default as awsData } from `....`

This will get rid of the import being added as a default property in the returned JSON object.

Faraji Anderson
  • 653
  • 6
  • 18
-2

Restarting the IDE after setting "resolveJsonModule": true should work.