Skip to content

Commit

Permalink
Do not stringify null literals as object values (#417)
Browse files Browse the repository at this point in the history
Extract null literals as-is in object values

Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>

---------

Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
  • Loading branch information
farskid and Andarist authored Dec 20, 2023
1 parent 9f095ed commit ade217f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/smooth-pumas-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@xstate/machine-extractor': minor
---

Do not stringify null literals in object values
7 changes: 4 additions & 3 deletions packages/machine-extractor/src/extractAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,11 @@ export function extractObjectRecursively(
object.properties.forEach((prop) => {
if (t.isObjectProperty(prop)) {
if (t.isLiteral(prop.value)) {
if (
if (t.isNullLiteral(prop.value)) {
extracted[getObjectPropertyKey(prop)] = null;
} else if (
t.isRegExpLiteral(prop.value) ||
isTemplateLiteralWithExpressions(prop.value) ||
t.isNullLiteral(prop.value)
isTemplateLiteralWithExpressions(prop.value)
) {
extracted[getObjectPropertyKey(prop)] = fileContent.slice(
prop.value.start!,
Expand Down

0 comments on commit ade217f

Please sign in to comment.