I am working on a Vue project where I have imported a JSON file into my TypeScript script using
import jsonData from '@/assets/data1.json';
Although the data is accessible and functions correctly, I am encountering numerous warnings during the build process, such as this one:
WARNING in /path/src/assets/data1.json
1:1 unused expression, expected an assignment or function call
> 1 | {
| ^
2 | "x123": {
3 | "name": "John Doe",
4 | "confirmed": true
How can I inform the compiler that this file is indeed a JSON file and not JavaScript/TypeScript?
To resolve this issue, I have already included
"resolveJsonModule": true,
"esModuleInterop": true
in my tsconfig.json
file, following the guidance provided here: