I am working on a service called class imageService
, which mainly consists of key value pairs
export type servicesName = "unsplash" | "pexels" | "pixabay" | 'shutterstock';
export type Service = {
[key in servicesName]?: string;
};
and
class ImageServices {
services: Service;
constructor(services: Service) {
// creating key-value pair, key -> name of service, value api key (easy to access)
this.services = { ...services };
}
// code
However, Shutterstock provides consumer_key and consumer_secret instead of only an api_key. To reflect this in my type, I modified it as follows:
interface shutterstock_init {
consumer_id: string
consumer_secret: string
}
export type Service = {
[key in servicesName]?: string;
shutterstock?: shutterstock_init
};
Unfortunately, I encountered the following errors:
'}' expected.ts(1005)
Cannot find name 'shutterstock'.
'shutterstock_init' only refers to a type but is being used as a value here.
If anyone can assist me in resolving these issues, I would greatly appreciate it.