Skip to content

chore(js-ts): Convert Base/Keypad to TypeScript#972

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
chore/js-ts-keypad-307
Open

chore(js-ts): Convert Base/Keypad to TypeScript#972
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
chore/js-ts-keypad-307

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Jun 23, 2026

Copy link
Copy Markdown

Summary

Part of Workstream 2 (Base & UI component JS→TS migration). Converts the entire app/components/Base/Keypad/ component folder (5 source files) from JS to TS. Type-only change — snapshot and all 282 unit tests are identical/passing.

  • createKeypadRule.js.ts
  • constants.js.ts
  • useCurrency.js.ts
  • components.js.tsx
  • index.js.tsx

The two test files (Keypad.test.js, createKeypadRule.test.js) are intentionally left as .js: Keypad.test.js uses enzyme whose types aren't installed, and per the migration rules we don't add new @types packages. They import the renamed .ts/.tsx source unchanged.

Worth knowing (rest is mechanical PropTypes→interface):

  • createKeypadRule now returns a typed KeypadHandler = (currentAmount: string, inputKey: string) => string. Its options are { decimalSeparator?: string | null; decimals?: number | false | null }. The decimals === false branch is keptcreateKeypadRule.test.js exercises decimals: false (separator suppressed), so false is a real runtime value, not dead code.
  • hasDecimals(decimalSeparator, decimals) is called as hasDecimals(String(decimalSeparator), String(decimals)). hasDecimals already string-interpolates both args, so this reproduces the previous coercion exactly (e.g. null"null"), keeping the generated regex byte-identical.
  • CURRENCIES typed as Record<string, Currency> where Currency = { decimalSeparator: string | null; handler: KeypadHandler; symbol: string | null }; KEYS is as const.
  • components.tsx: compound Keypad statics attached via Object.assign(KeypadContainer, { Row, Button, DeleteButton }) (behavior-identical to the previous Keypad.Row = ... mutations). Sub-components typed from ViewProps/TouchableOpacityProps with textStyle?: StyleProp<TextStyle>.
  • index.tsx: onChange?: (data: KeypadChangeData) => void (PropTypes had it optional) called via onChange?.(...); value ?? '' passed to the handler (handler maps both '' and undefined to '0', so identical).

Validation (local)

  • yarn lint:tsc: passes, 0 errors.
  • eslint on all 5 files: clean (no any).
  • yarn jest app/components/Base/Keypad: 282 tests pass, 1 snapshot identical.

CI note

The install-gated CI jobs on this fork fail before reaching any TS/test step due to a preexisting broken dependency (react-native-tcp pins a GitHub commit that now 404s on yarn install); check-diff/CLABot/label checks also fail on all fork PRs for preexisting infra/governance reasons (ruby/setup-ruby detects the macOS runner as self-hosted). None are caused by this diff, which contains only file renames + type annotations and no lockfile change.

Link to Devin session: https://app.devin.ai/sessions/a0f7f796d1fb45e88b2feabe5829a4ac
Requested by: @WesternConcrete


Devin Review

Status Commit
⚪ Not started

Run Devin Review

Open in Devin Review (Staging)

feature: migrate the Keypad component folder (index, components, constants,
createKeypadRule, useCurrency) from JS to TS. Replaces PropTypes with TypeScript
interfaces and types the keypad rule handler/currency map. No behavioral changes;
snapshot and all 282 unit tests identical/passing.

Co-Authored-By: Wes Convery <2wconvery@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

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.

0 participants