Skip to content

Add TypeScript strict null checks to tsconfig.json and fix resulting type errors #554

Description

@Jagadeeshftw

📌 Description

tsconfig.json may not have "strictNullChecks": true explicitly set (or it may be off under a loose strict mode). Enabling strict null checks across the codebase will surface places where string | null values from the wallet context, stream records, or config are used without null guards, preventing runtime errors from reaching users.

💡 Why it matters: Null-pointer-style errors are the most common runtime crash category; strict null checks move them to compile time.

🧩 Requirements and context

  • Confirm current tsconfig.json settings; if strict: true already implies strictNullChecks, investigate and resolve all existing tsc --noEmit type errors instead.
  • Fix null-guard issues in src/pages/Recipient.tsx (wallet address can be null), src/lib/stellar/tx.ts (config rpcUrl can be null), and src/lib/api/streamsService.ts.
  • Add "noUncheckedIndexedAccess": true to catch unchecked array access in filter/sort chains in src/pages/Streams.tsx.
  • Run tsc --noEmit in CI and fail if there are errors.

Non-functional requirements

  • Must be secure, tested, and documented.
  • Should be efficient and easy to review.

🛠️ Suggested execution

1. Fork the repo and create a branch

git checkout -b refactor/strict-null-checks

2. Implement changes

  • Write/modify the relevant source: tsconfig.json, src/pages/Recipient.tsx, src/lib/stellar/tx.ts, src/lib/api/streamsService.ts
  • Write comprehensive tests: npm run build (tsc) is the test
  • Add documentation: comment in tsconfig.json explaining each enabled flag
  • Validate security assumptions: null dereferences in wallet address paths could silently use empty strings; guards must reject empty strings too

3. Test and commit

  • Run tests:
npx tsc --noEmit
  • Cover edge cases: wallet.address used in template literals when null, array index access after filter()
  • Include test output and security notes in the PR description.

Example commit message

refactor(types): enable strictNullChecks and noUncheckedIndexedAccess, fix resulting errors

✅ Acceptance criteria

  • tsc --noEmit passes with zero errors after changes
  • strictNullChecks: true is explicitly set in tsconfig.json
  • Wallet address null guards are present in Recipient.tsx and Walletcontext.tsx
  • config.rpcUrl null check is present before RPC calls in tx.ts
  • CI build step runs tsc --noEmit and fails on errors

🔒 Security notes

Empty string walletAddress passed to Stellar SDK functions returns unhelpful errors; strict null checks will surface and force explicit guards.

📋 Guidelines

  • Minimum 95% test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Labels

GrantFox OSSGrantFox open-source programMaybe RewardedGrantFox: potentially rewarded contributionOfficial CampaignGrantFox official campaign issuefrontendrefactorCode refactor / cleanupsecuritySecurity hardening / audit

Type

Fields

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions