Skip to content

Commit

Permalink
Inline version in expression widget parser (#1921)
Browse files Browse the repository at this point in the history
The Expression widget imports the KAS parser, which contains generated code
with some syntax that `@swc-node/register` (which we use to run TypeScript from
the command line) can't parse. The parse error was preventing the exhaustive
tests for the parsers (packages/perseus/src/util/parse-perseus-json/exhaustive-test-tool/index.ts)
from running.

Since we can't change the generated code, the solution is to avoid importing
the version number from the Expression widget, and hardcode it instead. I think
this is okay, because the migration function that used the version number is
called `migrateV0ToV1`, so we actually want to hardcode version 1 rather than
taking the current version from the widget.


Issue: none

## Test plan:

Run the exhaustive test tool according to the instructions in the file.

Author: benchristel

Reviewers: jeremywiebe

Required Reviewers:

Approved By: jeremywiebe

Checks: ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x), ✅ gerald

Pull Request URL: #1921
  • Loading branch information
benchristel authored Nov 27, 2024
1 parent 3e98b7c commit 8ec06f4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/seven-owls-explain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@khanacademy/perseus": patch
---

Internal: Inline widget version into Expression widget parser.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import ExpressionWidgetModule from "../../../widgets/expression/expression";
import {
array,
boolean,
Expand Down Expand Up @@ -93,7 +92,7 @@ function migrateV0ToV1(
const {options} = widget;
return ctx.success({
...widget,
version: ExpressionWidgetModule.version,
version: {major: 1, minor: 0},
options: {
times: options.times,
buttonSets: options.buttonSets,
Expand Down

0 comments on commit 8ec06f4

Please sign in to comment.