Skip to content

Add mutual assignability tests for parsed types <-> data-schema types #2402

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Apr 22, 2025

Conversation

benchristel
Copy link
Member

@benchristel benchristel commented Apr 16, 2025

These typetests ensure that our parsers stay in sync with the data-schema types.

  • If you add a new property (even an optional one) to any type used in widget options,
    but don't update the parser, you will get a type error.
  • If you add a variant to a union type used in widget options without updating the parser,
    you will get a type error.

While adding these typetests, I found some discrepancies in our existing types, which are
fixed in this PR.

Test plan:

pnpm tsc

Copy link
Contributor

github-actions bot commented Apr 16, 2025

Size Change: +57 B (+0.01%)

Total Size: 466 kB

Filename Size Change
packages/perseus-core/dist/es/index.js 18.5 kB +56 B (+0.3%)
packages/perseus-editor/dist/es/index.js 88.5 kB +1 B (0%)
ℹ️ View Unchanged
Filename Size
packages/kas/dist/es/index.js 20.7 kB
packages/keypad-context/dist/es/index.js 1 kB
packages/kmath/dist/es/index.js 5.98 kB
packages/math-input/dist/es/index.js 98.6 kB
packages/math-input/dist/es/strings.js 1.61 kB
packages/perseus-linter/dist/es/index.js 7.05 kB
packages/perseus-score/dist/es/index.js 9.04 kB
packages/perseus-utils/dist/es/index.js 403 B
packages/perseus/dist/es/index.js 199 kB
packages/perseus/dist/es/strings.js 7.49 kB
packages/pure-markdown/dist/es/index.js 1.22 kB
packages/simple-markdown/dist/es/index.js 6.71 kB

compressed-size-action

Copy link
Contributor

github-actions bot commented Apr 16, 2025

npm Snapshot: Published

Good news!! We've packaged up the latest commit from this PR (c48f89b) and published it to npm. You
can install it using the tag PR2402.

Example:

pnpm add @khanacademy/perseus@PR2402

If you are working in Khan Academy's webapp, you can run:

./dev/tools/bump_perseus_version.js -t PR2402

@benchristel benchristel marked this pull request as ready for review April 17, 2025 16:46
@benchristel benchristel changed the base branch from benc/no-readonly to main April 17, 2025 20:30
@@ -53,7 +47,7 @@ function deprecatedSimplifyValuesToRequired(
| null
| undefined
| boolean,
): PerseusNumericInputSimplify {
): "enforced" | "required" | "optional" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you change this because the type tests will now verify the return value matches PerseusNumericInputSimplify?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right!

@benchristel benchristel merged commit 558cc1c into main Apr 22, 2025
8 checks passed
@benchristel benchristel deleted the benc/mutual-assignability branch April 22, 2025 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants