check expression type in viewer to mitigate the void bug

This commit is contained in:
Vyacheslav Matyukhin 2022-07-29 23:19:55 +04:00
parent f96f8de92a
commit 482ceb76dc
No known key found for this signature in database
GPG Key ID: 3D2A774C5489F96C

View File

@ -59,6 +59,13 @@ export const ExpressionViewer: React.FC<Props> = ({
expression, expression,
width, width,
}) => { }) => {
if (typeof expression !== "object") {
return (
<VariableList path={path} heading="Error">
{() => `Unknown expression: ${expression}`}
</VariableList>
);
}
switch (expression.tag) { switch (expression.tag) {
case "number": case "number":
return ( return (
@ -281,10 +288,16 @@ export const ExpressionViewer: React.FC<Props> = ({
); );
default: { default: {
return ( return (
<div> <VariableList path={path} heading="Error">
<span>No display for type: </span>{" "} {() => (
<span className="font-semibold text-slate-600">{expression.tag}</span> <div>
</div> <span>No display for type: </span>{" "}
<span className="font-semibold text-slate-600">
{expression.tag}
</span>
</div>
)}
</VariableList>
); );
} }
} }