-
Notifications
You must be signed in to change notification settings - Fork 350
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Type the
correct
prop passed to InteractiveGraphEditor (#1599)
Previously, `correct` was typed as `any` to suppress an error. TypeScript complained that the InteractiveGraph component might pass the wrong subtype of `PerseusGraphType` to its `onChange` callback, causing us to create a nonsensical chimera graph when we do stuff like `correct = {...correct, ...newGraph};` This PR adds runtime checks (mostly using `tiny-invariant`) to ensure that graphs have the type we expect. In doing this refactoring, I discovered a second problem: the InteractiveGraphEditor sometimes sets the `coords` of the graph to `null`, which wasn't allowed by `PerseusGraphType` - only `undefined` was allowed. This PR fixes that by updating `PerseusGraphType` to allow null coords. The interactive graph code can (thankfully) already handle null values just fine. Issue: none ## Test plan: Edit an interactive graph in the exercise editor. Author: benchristel Reviewers: nishasy, jeremywiebe, benchristel, mark-fitzgerald Required Reviewers: Approved By: nishasy, jeremywiebe Checks: ✅ codecov/project, ✅ codecov/patch, ✅ Upload Coverage (ubuntu-latest, 20.x), ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Jest Coverage (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: #1599
- Loading branch information
1 parent
9718fcc
commit 71715af
Showing
5 changed files
with
158 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@khanacademy/perseus": patch | ||
"@khanacademy/perseus-editor": patch | ||
--- | ||
|
||
Internal: improve type safety of interactive graph editor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.