diff --git a/package.json b/package.json index b6167b9..8b511c3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "jsonata-ui-core", - "version": "1.7.2", + "name": "@samsquatch/jsonata-ui-core", + "version": "1.7.5", "description": "Core AST and serializers for jsonata-ui", "source": "src/index.ts", "main": "dist/index.js", diff --git a/src/serializer.ts b/src/serializer.ts index 546bdd9..8791eed 100644 --- a/src/serializer.ts +++ b/src/serializer.ts @@ -78,12 +78,12 @@ export default function serializer(node: AST): string { "}" ); } else if (node.type === "condition") { - return ( - serializer(node.condition) + - " ? " + - serializer(node.then) + - " : " + - serializer(node.else) + return (`${serializer(node.condition)} ? ${ + serializer(node.then)} + ${node.else ? + `: ${serializer(node.else)}` + : '' + }` ); } else if (node.type === "value") { if (node.value === null) return "null"; diff --git a/src/types.ts b/src/types.ts index 242cead..4af25d4 100644 --- a/src/types.ts +++ b/src/types.ts @@ -131,7 +131,7 @@ export interface ConditionNode extends Node { type: "condition"; condition: JsonataASTNode; then: JsonataASTNode; - else: JsonataASTNode; + else?: JsonataASTNode; } export interface LambdaNode extends Node {