I'm really going crazy because I canβt find a solution for this. I want to archive in order to import the configuration JSON file into my TypeScript file. I found out that I need a declaration file. So I added the json-loader.d.ts file to my project. I also tried it on several levels (root, typings folder, custom_typings folder) because these are the solutions that I found. The contents of the file are as follows:
declare module "json!*" { let json: any; export = json; } declare module "*.json" { const value: any; export default value; }
But the compiler still tells me that it is not possible to import a JSON file because it is not a module. So how does the compiler know that there is such a declaration file?
I already tried changing my tsconfig.json as follows:
{ "compilerOptions": { "target": "es6", "module": "commonjs", "outDir": "dist", "typeRoots": [ "./node_modules/@types", "./typings" ] }, "include": [ "src/**/*.ts" ], "exclude": [ "node_modules" ] }
But that still doesn't work. Any suggestions?
Thanks!
typescript typescript-typings
Patrick P.
source share