Skip to content

Remove null type from answerArea#3414

Merged
benchristel merged 2 commits intomainfrom
benc/restrict-answerArea-type
Mar 26, 2026
Merged

Remove null type from answerArea#3414
benchristel merged 2 commits intomainfrom
benc/restrict-answerArea-type

Conversation

@benchristel
Copy link
Copy Markdown
Member

Summary:

In production, answerArea is never null or undefined. However, in test
data, we sometimes want to leave it undefined for brevity.

This change simplifies the type of answerArea, removing null. Currently, no
code in the frontend repo sets answerArea to null.

This also fixes an inconsistency between the PerseusItem type and the
EditorPage component's props. The type PropsFor<EditorPage>["answerArea"]
is equivalent to PerseusAnswerArea | undefined (because answerArea has a
default prop), but the prop doesn't accept null. This means we currently
can't pass a PerseusItem directly to EditorPage without converting null
to undefined or suppressing typechecking.

Issue: none

Test plan:

pnpm tsc

Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review.

Tip: disable this comment in your organization's Code Review settings.

@github-actions github-actions bot added the schema-change Attached to PRs when we detect Perseus Schema changes in it label Mar 25, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 25, 2026

🗄️ Schema Change: Changes Detected ⚠️

Usually this means you need to update the Go parser
that Content Platform maintains!!!

See this list of post-mortems for more information.

This PR contains critical changes to Perseus. Please review
the changes and note that you may need to coordinate
deployment of these changes with other teams at Khan Academy.

diff --unified /home/runner/work/_temp/branch-compare/base/schema.d.ts /home/runner/work/_temp/branch-compare/pr/schema.d.ts
--- /home/runner/work/_temp/branch-compare/base/schema.d.ts	2026-03-26 16:01:31.362895576 +0000
+++ /home/runner/work/_temp/branch-compare/pr/schema.d.ts	2026-03-26 16:01:17.517483877 +0000
@@ -184,7 +184,7 @@
   export type PerseusItem = {
     question: PerseusRenderer;
     hints: Hint[];
-    answerArea: PerseusAnswerArea | null | undefined;
+    answerArea?: PerseusAnswerArea | undefined;
   };
   export type PerseusArticle = PerseusRenderer | PerseusRenderer[];
   export type Version = {

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 25, 2026

🛠️ Item Splitting: No Changes ✅

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 25, 2026

Size Change: 0 B

Total Size: 494 kB

ℹ️ View Unchanged
Filename Size
packages/kas/dist/es/index.js 20.5 kB
packages/keypad-context/dist/es/index.js 1 kB
packages/kmath/dist/es/index.js 6.21 kB
packages/math-input/dist/es/index.js 98.5 kB
packages/math-input/dist/es/strings.js 1.61 kB
packages/perseus-core/dist/es/index.item-splitting.js 11.9 kB
packages/perseus-core/dist/es/index.js 25.1 kB
packages/perseus-editor/dist/es/index.js 101 kB
packages/perseus-linter/dist/es/index.js 9.3 kB
packages/perseus-score/dist/es/index.js 9.66 kB
packages/perseus-utils/dist/es/index.js 403 B
packages/perseus/dist/es/index.js 193 kB
packages/perseus/dist/es/strings.js 8.09 kB
packages/pure-markdown/dist/es/index.js 1.39 kB
packages/simple-markdown/dist/es/index.js 6.71 kB

compressed-size-action

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 25, 2026

npm Snapshot: Published

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

Example:

pnpm add @khanacademy/perseus@PR3414

If you are working in Khan Academy's frontend, you can run the below command.

./dev/tools/bump_perseus_version.ts -t PR3414

If you are working in Khan Academy's webapp, you can run the below command.

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

@benchristel benchristel merged commit 669ed4e into main Mar 26, 2026
11 checks passed
@benchristel benchristel deleted the benc/restrict-answerArea-type branch March 26, 2026 16:49
anakaren-rojas pushed a commit that referenced this pull request Mar 26, 2026
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated


# Releases
## @khanacademy/[email protected]

### Major Changes

-   [#3416](#3416) [`3e1e498bf5`](3e1e498) Thanks [@jeremywiebe](https://github.com/jeremywiebe)! - Remove trivial function `getWidgetsMapFromItemData` - access widgets via `.question.widgets` instead.

### Patch Changes

-   [#3388](#3388) [`3f091b70cb`](3f091b7) Thanks [@nishasy](https://github.com/nishasy)! - [Image] | (UX) | Upscale Graphies within image zoom view

-   Updated dependencies \[[`6267d162b4`](6267d16), [`669ed4e6b1`](669ed4e), [`2d8df47440`](2d8df47)]:
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]

## @khanacademy/[email protected]

### Major Changes

-   [#3414](#3414) [`669ed4e6b1`](669ed4e) Thanks [@benchristel](https://github.com/benchristel)! - Remove `null` from the type of `PerseusItem.answerArea`.

### Minor Changes

-   [#3406](#3406) [`6267d162b4`](6267d16) Thanks [@ivyolamit](https://github.com/ivyolamit)! - Use kmath canonicalTangentCoefficients for both Grapher and Interactive Graph widgets and then remove the duplicate code in grapher-util

## @khanacademy/[email protected]

### Minor Changes

-   [#3406](#3406) [`6267d162b4`](6267d16) Thanks [@ivyolamit](https://github.com/ivyolamit)! - Use kmath canonicalTangentCoefficients for both Grapher and Interactive Graph widgets and then remove the duplicate code in grapher-util

### Patch Changes

-   Updated dependencies \[[`6267d162b4`](6267d16), [`669ed4e6b1`](669ed4e)]:
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]

## @khanacademy/[email protected]

### Patch Changes

-   Updated dependencies \[[`6267d162b4`](6267d16), [`669ed4e6b1`](669ed4e)]:
    -   @khanacademy/[email protected]

## @khanacademy/[email protected]

### Patch Changes

-   Updated dependencies \[[`6267d162b4`](6267d16), [`669ed4e6b1`](669ed4e)]:
    -   @khanacademy/[email protected]

## @khanacademy/[email protected]

### Patch Changes

-   Updated dependencies \[[`6267d162b4`](6267d16), [`669ed4e6b1`](669ed4e)]:
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]

## @khanacademy/[email protected]

### Patch Changes

-   Updated dependencies \[[`6267d162b4`](6267d16), [`669ed4e6b1`](669ed4e), [`2d8df47440`](2d8df47), [`3f091b70cb`](3f091b7), [`3e1e498bf5`](3e1e498)]:
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]

## @khanacademy/[email protected]

### Patch Changes

-   [#3419](#3419) [`2d8df47440`](2d8df47) Thanks [@anakaren-rojas](https://github.com/anakaren-rojas)! - changes return types of linter functions to not be readonly array; exports linterwarningitem

-   Updated dependencies \[[`6267d162b4`](6267d16), [`669ed4e6b1`](669ed4e)]:
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]

Author: khan-actions-bot

Reviewers: claude[bot], anakaren-rojas

Required Reviewers:

Approved By: anakaren-rojas

Checks: ⏭️  2 checks have been skipped, ✅ 6 checks were successful

Pull Request URL: #3412
catandthemachines pushed a commit that referenced this pull request Apr 1, 2026
## Summary:
In production, `answerArea` is never `null` or `undefined`. However, in test
data, we sometimes want to leave it undefined for brevity.

This change simplifies the type of `answerArea`, removing `null`. Currently, no
code in the frontend repo sets `answerArea` to `null`.

This also fixes an inconsistency between the `PerseusItem` type and the
`EditorPage` component's props.  The type `PropsFor<EditorPage>["answerArea"]`
is equivalent to `PerseusAnswerArea | undefined` (because `answerArea` has a
default prop), but the prop doesn't accept `null`. This means we currently
can't pass a `PerseusItem` directly to `EditorPage` without converting `null`
to `undefined` or suppressing typechecking.

Issue: none

## Test plan:

`pnpm tsc`

Author: benchristel

Reviewers: claude[bot], jeremywiebe, anakaren-rojas

Required Reviewers:

Approved By: jeremywiebe

Checks: ⏭️  1 check has been skipped, ✅ 10 checks were successful

Pull Request URL: #3414
catandthemachines pushed a commit that referenced this pull request Apr 1, 2026
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated


# Releases
## @khanacademy/[email protected]

### Major Changes

-   [#3416](#3416) [`3e1e498bf5`](3e1e498) Thanks [@jeremywiebe](https://github.com/jeremywiebe)! - Remove trivial function `getWidgetsMapFromItemData` - access widgets via `.question.widgets` instead.

### Patch Changes

-   [#3388](#3388) [`3f091b70cb`](3f091b7) Thanks [@nishasy](https://github.com/nishasy)! - [Image] | (UX) | Upscale Graphies within image zoom view

-   Updated dependencies \[[`6267d162b4`](6267d16), [`669ed4e6b1`](669ed4e), [`2d8df47440`](2d8df47)]:
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]

## @khanacademy/[email protected]

### Major Changes

-   [#3414](#3414) [`669ed4e6b1`](669ed4e) Thanks [@benchristel](https://github.com/benchristel)! - Remove `null` from the type of `PerseusItem.answerArea`.

### Minor Changes

-   [#3406](#3406) [`6267d162b4`](6267d16) Thanks [@ivyolamit](https://github.com/ivyolamit)! - Use kmath canonicalTangentCoefficients for both Grapher and Interactive Graph widgets and then remove the duplicate code in grapher-util

## @khanacademy/[email protected]

### Minor Changes

-   [#3406](#3406) [`6267d162b4`](6267d16) Thanks [@ivyolamit](https://github.com/ivyolamit)! - Use kmath canonicalTangentCoefficients for both Grapher and Interactive Graph widgets and then remove the duplicate code in grapher-util

### Patch Changes

-   Updated dependencies \[[`6267d162b4`](6267d16), [`669ed4e6b1`](669ed4e)]:
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]

## @khanacademy/[email protected]

### Patch Changes

-   Updated dependencies \[[`6267d162b4`](6267d16), [`669ed4e6b1`](669ed4e)]:
    -   @khanacademy/[email protected]

## @khanacademy/[email protected]

### Patch Changes

-   Updated dependencies \[[`6267d162b4`](6267d16), [`669ed4e6b1`](669ed4e)]:
    -   @khanacademy/[email protected]

## @khanacademy/[email protected]

### Patch Changes

-   Updated dependencies \[[`6267d162b4`](6267d16), [`669ed4e6b1`](669ed4e)]:
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]

## @khanacademy/[email protected]

### Patch Changes

-   Updated dependencies \[[`6267d162b4`](6267d16), [`669ed4e6b1`](669ed4e), [`2d8df47440`](2d8df47), [`3f091b70cb`](3f091b7), [`3e1e498bf5`](3e1e498)]:
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]

## @khanacademy/[email protected]

### Patch Changes

-   [#3419](#3419) [`2d8df47440`](2d8df47) Thanks [@anakaren-rojas](https://github.com/anakaren-rojas)! - changes return types of linter functions to not be readonly array; exports linterwarningitem

-   Updated dependencies \[[`6267d162b4`](6267d16), [`669ed4e6b1`](669ed4e)]:
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]

Author: khan-actions-bot

Reviewers: claude[bot], anakaren-rojas

Required Reviewers:

Approved By: anakaren-rojas

Checks: ⏭️  2 checks have been skipped, ✅ 6 checks were successful

Pull Request URL: #3412
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

olc-5.0.c4fcb schema-change Attached to PRs when we detect Perseus Schema changes in it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants