How to properly import a JSON file in TypeScript? Import error
Hello everyone! I'm new to TypeScript and encountered a problem when trying to import a JSON file into my project.
I have a `config.json` file located in the project root:
```json
{
"apiUrl": "https://api.example.com",
"port": 3000,
"debug": true
}
```
I'm trying to import it in a TypeScript file `app.ts`:
```typescript
import config from './config.json';
console.log(config.apiUrl);
```
But I get an error from the TypeScript compiler:
`Cannot find module './config.json'. Consider using '--resolveJsonModule' to import module with '.json' extension.`
I've already tried:
1. Adding `"resolveJsonModule": true` to tsconfig.json — didn't help.
2. Using `import * as config from './config.json'` — same error.
3. Moving the JSON file to another folder — no