Files
DiceCloud/app/imports/parser/toPrimitiveOrString.ts
2024-02-20 23:21:12 +02:00

12 lines
411 B
TypeScript

import ParseNode from '/imports/parser/parseTree/ParseNode';
import { ConstantValueType } from '/imports/parser/parseTree/constant';
import toString from './toString';
export default function toPrimitiveOrString(node: ParseNode): ConstantValueType {
if (!node) return '';
if (node.parseType === 'constant') return node.value;
if (node.parseType === 'error') return undefined;
return toString(node);
}