Lets say I've got the following json file (root of angular application):
{
"propertyName": "ABC"
}
I know that TypeScript cannot handle JSON imports directly so I delcared the following module according to TypeScript module documentation using wildcard (typings.d.ts):
declare module "*.json" {
const value: any;
export default value;
}
Now I am able to import a local json file (structure above) like this:
import * as config from './config.json';
After that I am able to use any property of the import like this:
let propertyA: string = (<any>config).propertyName;
Everything is fine, but when I try to use
let propertyA: string = config.propertyName;
I get the following error message:
ERROR in src/main.ts(9,26): error TS2339: Property 'propertyName' does not exist on type 'typeof "*.json"'.
Any suggestions how to avoid this error during build process? The process finished successfully (including this error message) and I'm able to use the web application and also the needed property. It just generates an error message