I want to export a typed object, of a json, to avoid using any
as a type. But Im not sure how to create the d.ts file and use it in my project. My json uses platform, brand, locale, environment. This is what i have tried so far.
myjson.json
"desktop": {
"brandname": {
"eu": {
"a": "www.url.com",
"b": "www.otherurl.com",
}
}
}
myjson.d.ts
export class EnvUrlMap {
environment: string;
}
export class LocaleEnvMap {
locale: EnvUrlMap;
}
export class BrandLocaleMap {
brand: LocaleEnvMap;
}
export class PlatformBrandMap {
"desktop": BrandLocaleMap;
"mobile": BrandLocaleMap;
}
export {PlatformBrandMap as map};
index.ts
import map = require('my.json');
export {map};
PROJECT
main.ts
import { map } from 'my-project';
const config = (map as Map); `- ?? what is the type here ? Error cannot find Map`