You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes we hit errors that aren't very specific about where/how to solve. See error below:
(repo & layer id redacted for privacy reasons)
[nodemon] starting `scripts/build-styles.sh && yarn clean-styles`
Building styles
Error: Couldn't build layer <layerID>.
Details: Cannot read properties of undefined (reading 'low') in
<repo>/templates/layers/<layerID>.js
30: context.colors.landuse.desert.low,
In this case, the error is a JS error as opposed to being build system specific. As we can't catch all JS related errors, it would be helpful to be aware of what style is processing when this happens.
Additional context
While not necessarily relevant for this issue in providing style names at the right time during build, for those curious the issue above is explained here:
The erroring styles don't have the variable for landuse.desert.low, but there's a JS tolerance issue here. Basically, it just returns undefined if the final key isn't present on an object, but if it's trying to find a key on something that isn't an object but is instead undefined, it errors because that syntax doesn't make sense for it.
In this case, the landuse object doesn't contain desert or desert.low. If we only used landuse.desert it would return undefined and move on, but since it's trying to find a key on undefined it fails.
To handle that and still return undefined, we'd need to use optional chaining like context.colors.landuse?.desert?.low so it would cut itself short on the first undefined.
The text was updated successfully, but these errors were encountered:
Sometimes we hit errors that aren't very specific about where/how to solve. See error below:
(repo & layer id redacted for privacy reasons)
In this case, the error is a JS error as opposed to being build system specific. As we can't catch all JS related errors, it would be helpful to be aware of what style is processing when this happens.
Additional context
While not necessarily relevant for this issue in providing style names at the right time during build, for those curious the issue above is explained here:
The erroring styles don't have the variable for
landuse.desert.low
, but there's a JS tolerance issue here. Basically, it just returnsundefined
if the final key isn't present on an object, but if it's trying to find a key on something that isn't an object but is insteadundefined
, it errors because that syntax doesn't make sense for it.In this case, the
landuse
object doesn't containdesert
ordesert.low
. If we only usedlanduse.desert
it would returnundefined
and move on, but since it's trying to find a key onundefined
it fails.To handle that and still return
undefined
, we'd need to use optional chaining likecontext.colors.landuse?.desert?.low
so it would cut itself short on the firstundefined
.The text was updated successfully, but these errors were encountered: