Skip to content

Commit ec29107

Browse files
Fix invalid variable type conversion
1 parent 6a98c46 commit ec29107

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/ast.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,21 @@ function replaceVariable(elem, variables, functionArgs, forceVariableAsString, e
3535
if (associatedValue instanceof Element) {
3636
// Nothing to be done in here.
3737
return associatedValue;
38-
} else if (['number', 'string', 'boolean'].includes(typeof associatedValue)) {
39-
if (typeof associatedValue === 'boolean') {
40-
return new IdentElement(
41-
associatedValue.toString(), startPos, endPos, lineNumber);
42-
} else if (typeof associatedValue === 'number' ||
43-
// eslint-disable-next-line no-extra-parens
44-
(!forceVariableAsString && matchInteger(associatedValue) === true)) {
45-
return new NumberElement(associatedValue, startPos, endPos, lineNumber);
46-
}
38+
} else if (typeof associatedValue === 'boolean') {
39+
return new IdentElement(associatedValue.toString(), startPos, endPos, lineNumber);
40+
} else if (typeof associatedValue === 'string' || forceVariableAsString) {
4741
return new StringElement(
4842
associatedValue,
4943
startPos,
5044
endPos,
5145
`"${cleanString(associatedValue)}"`,
5246
lineNumber,
5347
);
48+
} else if (typeof associatedValue === 'number' ||
49+
// eslint-disable-next-line no-extra-parens
50+
(!forceVariableAsString && matchInteger(associatedValue) === true)
51+
) {
52+
return new NumberElement(associatedValue, startPos, endPos, lineNumber);
5453
}
5554
// this is a JSON dict and it should be parsed.
5655
const p = new Parser(JSON.stringify(associatedValue));

0 commit comments

Comments
 (0)