Closed lmacedotzt closed 1 year ago
Like here you can use function in filter
function(token) {
// omit empty or zero tokens
if (token.value !=0) {
return token
}
I have reproduced this bug. There have been some fixes to outputReferences in v3.9.0
and planning to forward port those to v4.0.0-prerelease.1
which solve the following:
{
"Offset": {
"value": "0",
"type": "other"
},
"Spacing": {
"value": "2 + {Offset}",
"type": "spacing"
}
}
But when you mentioned the truthy check, I realized there is another bug indeed that is not fixed, which can be reproduced by making the "0" in your JSON a number rather than string:
{
"Offset": {
"value": 0,
"type": "other"
},
"Spacing": {
"value": "2 + {Offset}",
"type": "spacing"
}
}
When using
outputReference
, if the referenced alias has a value of zero it being ignored and the reference is not being replaced.Input to recreate the issue:
Actual result
Expected result
After a quick look, it seems the issue is here, the condition is checking for a truthy value and zero is falsy: https://github.com/amzn/style-dictionary/blob/2cf72f3f89996503608c238d7f3bcbab5b53e719/lib/common/formatHelpers/createPropertyFormatter.js#LL114C21-L114C21
And I think this issue is related #886