Presented here is an object:
{
"type": "fill",
"id": "asdf",
"paint": {
"fill-color": "#440d0d"
}
}
I am aiming to retrieve the fill-color property. My attempted method is as follows:
if (mapStyle["paint"]){
const fillColor = mapStyle['paint']["fill-color"]
}
However, I encounter this error:
Element implicitly has an 'any' type because expression of type '"fill-color"' can't be used to index type '{ "fill-antialias"?: PropertyValueSpecification<boolean> | undefined; "fill-opacity"?: DataDrivenPropertyValueSpecification<number> | undefined; ... 4 more ...; "fill-pattern"?: DataDrivenPropertyValueSpecification<...> | undefined; } | ... 7 more ... | { ...; }'.
Property 'fill-color' does not exist on type '{ "fill-antialias"?: PropertyValueSpecification<boolean> | undefined; "fill-opacity"?: DataDrivenPropertyValueSpecification<number> | undefined; ... 4 more ...; "fill-pattern"?: DataDrivenPropertyValueSpecification<...> | undefined; } | ... 7 more ... | { ...; }'.ts(7053)
(property) "paint"?: {
"fill-antialias"?: PropertyValueSpecification<boolean> | undefined;
"fill-opacity"?: DataDrivenPropertyValueSpecification<number> | undefined;
... 4 more ...;
"fill-pattern"?: DataDrivenPropertyValueSpecification<...> | undefined;
} | ... 8 more ... | undefined
What could be causing this issue? I find the error message rather confusing. Thank you for your assistance!