Skip to content

Comments

chore(js-ts): migrate foundational JS files to TypeScript#323

Open
devin-ai-integration[bot] wants to merge 2 commits intomainfrom
devin/1771498934-js-to-ts-foundational-files
Open

chore(js-ts): migrate foundational JS files to TypeScript#323
devin-ai-integration[bot] wants to merge 2 commits intomainfrom
devin/1771498934-js-to-ts-foundational-files

Conversation

@devin-ai-integration
Copy link

@devin-ai-integration devin-ai-integration bot commented Feb 19, 2026

chore(js-ts): migrate foundational JS files to TypeScript

Summary

Converts 10 foundational .js files (constants, mocks, image-icons) to .ts as part of the ongoing JS-to-TS migration. Type annotations added to all exports.

Constants (3 files):

  • app/constants/navigation.js.ts
  • app/constants/network.js.ts
  • app/constants/onboarding.js.ts

Mocks (6 files):

  • app/__mocks__/pngMock.js.ts
  • app/__mocks__/react-native-device-info.js.ts
  • app/__mocks__/react-native-splash-screen.js.ts
  • app/__mocks__/react-native-view-shot.js.ts
  • app/__mocks__/rn-fetch-blob.js.ts
  • app/__mocks__/svgMock.js.ts

Images (1 file):

  • app/images/image-icons.js.ts

Also updates jest.config.js moduleNameMapper paths from .js to .ts for svgMock and pngMock to match the renamed files.

No new dependencies added. yarn lint passes with 0 errors locally. yarn lint:tsc shows only pre-existing errors in unrelated files (first-party-contracts.ts, ppom-util.test.ts, etc.).

Updates since last revision

  • Fixed Jest mock resolution: Renaming svgMock.js.ts and pngMock.js.ts broke Jest's moduleNameMapper in jest.config.js, which had hardcoded .js paths. Updated both entries to .ts. All 10 unit test shards now pass in CI.
  • CI note: The scripts (lint) and scripts (lint:tsc) checks were cancelled in CI (not failed) due to the pre-existing audit:ci failure in the same workflow group. Both pass locally with 0 new errors.

Review & Testing Checklist for Human

  • Verify type widening on constants is acceptable. All string constants (e.g., PREVIOUS_SCREEN: string, MAINNET: string) and objects (NETWORKS_CHAIN_ID: Record<string, string>) use widened types instead of narrow literal inference. If any downstream code relies on literal types (e.g., typeof MAINNET being 'mainnet' rather than string, or specific key names on NETWORKS_CHAIN_ID), this could cause type errors not caught by lint:tsc. Consider whether as const + derived types would be safer.
  • Run the full test suite (yarn test) to confirm Jest mock resolution. The jest.config.js fix was verified locally and unit tests pass in CI, but confirm that mock files like react-native-splash-screen.ts and rn-fetch-blob.ts are still picked up correctly in all test contexts.
  • Spot-check image-icons.ts export change. The export pattern changed from inline export default { ... } to a named const (imageIcons: Record<string, ImageSourcePropType>) + export default imageIcons. This is functionally equivalent but worth a quick sanity check that image imports work at runtime.
  • Confirm lint and lint:tsc pass in CI. These checks were cancelled (not failed) in the current CI run due to an unrelated audit:ci failure. Re-running CI or merging to trigger a fresh run would confirm they pass.

Notes

  • The explicit : string annotations on string literal constants widen what TypeScript would otherwise infer as narrow literal types. This is a stylistic choice — it's consistent across the PR but trades type precision for explicitness.
  • Pre-existing lint:tsc errors in first-party-contracts.ts are related to 0x${string} template literal mismatches with Record<string, string> — the same pattern used in this PR's network.ts. Worth keeping in mind if tightening types later.
  • The 4 failed CI checks (CLABot, check-diff, check-pr-labels, audit:ci) are all pre-existing repo config/infrastructure issues unrelated to this PR.

Link to Devin run: https://app.devin.ai/sessions/bab011b6f02f48faa4215079668ee9e5
Requested by: @joao-cognition

Migrate constants, mocks, and image-icons files from .js to .ts with proper type annotations:

Constants:
- app/constants/navigation.js -> .ts
- app/constants/network.js -> .ts
- app/constants/onboarding.js -> .ts

Mocks:
- app/__mocks__/pngMock.js -> .ts
- app/__mocks__/react-native-device-info.js -> .ts
- app/__mocks__/react-native-splash-screen.js -> .ts
- app/__mocks__/react-native-view-shot.js -> .ts
- app/__mocks__/rn-fetch-blob.js -> .ts
- app/__mocks__/svgMock.js -> .ts

Images:
- app/images/image-icons.js -> .ts

Co-Authored-By: Joao Esteves <joao.esteves@cognition.ai>
@devin-ai-integration
Copy link
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 and CI monitoring

Co-Authored-By: Joao Esteves <joao.esteves@cognition.ai>
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