diff --git a/packages/perseus/src/util/parse-perseus-json/perseus-parsers/expression-widget.ts b/packages/perseus/src/util/parse-perseus-json/perseus-parsers/expression-widget.ts index 0c41ea2ed4..7d8eb86144 100644 --- a/packages/perseus/src/util/parse-perseus-json/perseus-parsers/expression-widget.ts +++ b/packages/perseus/src/util/parse-perseus-json/perseus-parsers/expression-widget.ts @@ -36,17 +36,14 @@ const parseAnswerForm: Parser = object({ ).parser, }); -const parseExpressionWidgetV0 = parseWidgetWithVersion( - optional(object({major: constant(0), minor: number})), +const parseExpressionWidgetLatest: Parser = parseWidget( constant("expression"), object({ + answerForms: array(parseAnswerForm), functions: array(string), times: boolean, visibleLabel: optional(string), ariaLabel: optional(string), - form: boolean, - simplify: boolean, - value: string, buttonSets: array( enumeration( "basic", @@ -59,17 +56,20 @@ const parseExpressionWidgetV0 = parseWidgetWithVersion( ), ), buttonsVisible: optional(enumeration("always", "never", "focused")), - }) + }), ); -const parseExpressionWidgetLatest: Parser = parseWidget( +const parseExpressionWidgetV0 = parseWidgetWithVersion( + optional(object({major: constant(0), minor: number})), constant("expression"), object({ - answerForms: array(parseAnswerForm), functions: array(string), times: boolean, visibleLabel: optional(string), ariaLabel: optional(string), + form: boolean, + simplify: boolean, + value: string, buttonSets: array( enumeration( "basic", @@ -82,8 +82,8 @@ const parseExpressionWidgetLatest: Parser = parseWidget( ), ), buttonsVisible: optional(enumeration("always", "never", "focused")), - }) -) + }), +); function migrateV0ToLatest(widget: ParsedValue, ctx: ParseContext): ParseResult { const {options} = widget;