Skip to content

Commit 8ec06f4

Browse files
authored
Inline version in expression widget parser (#1921)
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
1 parent 3e98b7c commit 8ec06f4

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

.changeset/seven-owls-explain.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@khanacademy/perseus": patch
3+
---
4+
5+
Internal: Inline widget version into Expression widget parser.

packages/perseus/src/util/parse-perseus-json/perseus-parsers/expression-widget.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import ExpressionWidgetModule from "../../../widgets/expression/expression";
21
import {
32
array,
43
boolean,
@@ -93,7 +92,7 @@ function migrateV0ToV1(
9392
const {options} = widget;
9493
return ctx.success({
9594
...widget,
96-
version: ExpressionWidgetModule.version,
95+
version: {major: 1, minor: 0},
9796
options: {
9897
times: options.times,
9998
buttonSets: options.buttonSets,

0 commit comments

Comments
 (0)