Skip to content

Conversation

@ivyolamit
Copy link
Contributor

@ivyolamit ivyolamit commented Nov 20, 2025

Summary:

Use WB View instead of fake-react-native-web View

This refactor is on top of the base PR WB Tabs change in #2952

Issue: LEMS-3361

Test plan:

Co-Authored by Claude Code

@ivyolamit ivyolamit self-assigned this Nov 20, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 20, 2025

🗄️ Schema Change: No Changes ✅

@github-actions
Copy link
Contributor

github-actions bot commented Nov 20, 2025

🛠️ Item Splitting: No Changes ✅

@github-actions
Copy link
Contributor

github-actions bot commented Nov 20, 2025

Size Change: -379 B (-0.08%)

Total Size: 498 kB

Filename Size Change
packages/math-input/dist/es/index.js 98.3 kB -379 B (-0.38%)
ℹ️ View Unchanged
Filename Size
packages/kas/dist/es/index.js 20.8 kB
packages/keypad-context/dist/es/index.js 1 kB
packages/kmath/dist/es/index.js 5.98 kB
packages/math-input/dist/es/strings.js 1.61 kB
packages/perseus-core/dist/es/index.item-splitting.js 13.1 kB
packages/perseus-core/dist/es/index.js 22.6 kB
packages/perseus-editor/dist/es/index.js 98.2 kB
packages/perseus-linter/dist/es/index.js 8.64 kB
packages/perseus-score/dist/es/index.js 9.2 kB
packages/perseus-utils/dist/es/index.js 403 B
packages/perseus/dist/es/index.js 202 kB
packages/perseus/dist/es/strings.js 7.73 kB
packages/pure-markdown/dist/es/index.js 1.39 kB
packages/simple-markdown/dist/es/index.js 6.72 kB

compressed-size-action

@ivyolamit ivyolamit force-pushed the LEMS-3361/refactor-fake-react-native-web branch 2 times, most recently from 0b3c9bb to 928a055 Compare November 20, 2025 21:42
@github-actions
Copy link
Contributor

github-actions bot commented Nov 20, 2025

npm Snapshot: Published

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

Example:

pnpm add @khanacademy/perseus@PR3055

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

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

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

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

@ivyolamit ivyolamit added the project agnostic PRs reviewable by any Perseus team member label Nov 20, 2025
@ivyolamit ivyolamit marked this pull request as ready for review November 20, 2025 22:49
Copy link
Collaborator

@jeremywiebe jeremywiebe left a comment

Choose a reason for hiding this comment

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

Thanks for cleaning this super-old code up!!

@@ -1,13 +1,13 @@
/* eslint-disable max-lines */
/* eslint-disable @khanacademy/ts-no-error-suppressions */
Copy link
Collaborator

Choose a reason for hiding this comment

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

Question: can we remove this line now or are there still some @ts-expect-error's in here? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

there are still a number of ts-expect-error here. Let me see if I can clean up some of them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok i'm able to remove it, asked help from claude:

Summary of Fixes

  1. Class Property Definite Assignment (lines 64-73)
  • Added ! (definite assignment assertion) to properties that are assigned in componentDidMount:
    • recordTouchStartOutside!
    • blurOnTouchEndOutside!
    • blurOnClickOutside!
    • _container!
    • _containerBounds!
  1. tabIndex Type Fix (line 999)
  • Changed tabIndex={"0"} to tabIndex={0} (string → number)
  1. Tuple Type for Spread Operator (line 443)
  • Added explicit tuple type: const points: [number, number][] = [...]
  • This allows the spread operator ...point to work correctly with document.elementFromPoint()
  1. Element Type Fixes (lines 471-523)
  • Changed ReadonlyArray<null | HTMLElement> to Array<Element | null> for leafElements and nonLeafElements
  • Added proper type for hitNode: Element | null = null
  • Used optional chaining element?.getAttribute() to handle potential null values

Result

  • ✅ 0 TypeScript errors in the math-input package
  • ✅ All ts-expect-error suppressions removed from the file
  • ✅ Code is now fully type-safe and cleaner!

y += dy;

const points = [
const points: [number, number][] = [
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

blurOnTouchEndOutside: (arg1: any) => void;
// @ts-expect-error - TS2564 - Property 'blurOnClickOutside' has no initializer and is not definitely assigned in the constructor.
blurOnClickOutside: (arg1: any) => void;
recordTouchStartOutside!: (arg1: any) => void;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is an old pattern that could be changed. Generally, I'm pretty hesitant to use ! as a solution. It creates risk for us in the future if we refactor when/where we initialize these fields because it suppresses some of TypeScript's type checking.

These functions are assigned in componentDidMount. Could we just make them arrow functions on the class and move the initialization out of componentDidMount? We could pair tomorrow or next week if that's not clear. :)

@ivyolamit ivyolamit force-pushed the LEMS-3361/use-wb-tab-in-expression branch from 6ea88ca to bfa3a3b Compare December 5, 2025 21:44
@ivyolamit ivyolamit force-pushed the LEMS-3361/refactor-fake-react-native-web branch from 5a7da89 to 927b1c7 Compare December 5, 2025 21:45
@ivyolamit ivyolamit force-pushed the LEMS-3361/refactor-fake-react-native-web branch from 927b1c7 to fdd906c Compare December 5, 2025 23:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

olc-5.0.d5056 project agnostic PRs reviewable by any Perseus team member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants