refactor: Clean up imports and type annotations#559
Conversation
All 3,016 TypeScript errors were caused by missing node_modules (dependencies not installed). After npm install, fixed remaining lint warnings: duplicate react-native import, Array<T> syntax, and suppressed intentional useEffect dep. https://claude.ai/code/session_017rsjCBTqJkzoTRcL7YXthq
There was a problem hiding this comment.
Pull request overview
This PR contains minor code quality improvements focused on cleaning up imports, updating type annotation syntax, and adding an ESLint directive. The changes are purely stylistic with no functional impact.
Changes:
- Consolidated duplicate
TextInputimport in AnimatedNumber component - Updated array type annotation syntax in wallet-setup from
Array<T>toT[] - Added ESLint directive to suppress exhaustive-deps warning in receive screen
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| components/AnimatedNumber.tsx | Consolidated TextInput import with other react-native imports, removing duplicate import statement |
| app/wallet-setup.tsx | Changed type annotation from Array<keyof WalletService> to (keyof WalletService)[] for consistency |
| app/(tabs)/receive.tsx | Added eslint-disable-next-line react-hooks/exhaustive-deps directive to useEffect hook |
|
|
||
| // Verify all required functions are available | ||
| const requiredFunctions: Array<keyof WalletService> = ['generateMnemonic', 'validateMnemonic', 'createWallet', 'importWallet']; | ||
| const requiredFunctions: (keyof WalletService)[] = ['generateMnemonic', 'validateMnemonic', 'createWallet', 'importWallet']; |
There was a problem hiding this comment.
The codebase uses both Array<T> and T[] syntax inconsistently. While modern TypeScript conventions generally prefer T[] for simple types, this file (wallet-service.ts) already uses Array<T> extensively for complex types (e.g., lines 109, 110, 153, 172, 1083, 1101, 1210, 1229). Changing this single instance creates further inconsistency. Consider either:
- Keeping
Array<keyof WalletService>to match the existing pattern in this file - Standardizing all type annotations across the codebase in a separate refactoring PR
| const requiredFunctions: (keyof WalletService)[] = ['generateMnemonic', 'validateMnemonic', 'createWallet', 'importWallet']; | |
| const requiredFunctions: Array<keyof WalletService> = ['generateMnemonic', 'validateMnemonic', 'createWallet', 'importWallet']; |
| @@ -124,6 +124,7 @@ function ReceiveScreenContent({ walletContext }: { walletContext: ReturnType<typ | |||
| setIsLoadingAddress(false); | |||
| }); | |||
| } | |||
There was a problem hiding this comment.
This ESLint directive suppresses warnings for walletService, setCurrentAddress, and setIsLoadingAddress which are not in the dependency array. However, the comment in the PR description says this is a "false positive," but the real issue is that these are stable references (module-level constant and setState functions). Consider adding an explanatory comment here describing why these dependencies are intentionally omitted, similar to the pattern in app/(tabs)/send.tsx line 254 which explains "feeRate is intentionally not included to prevent infinite loop". This would make the intent clearer for future maintainers.
| } | |
| } | |
| // NOTE: walletService, setCurrentAddress and setIsLoadingAddress are intentionally | |
| // omitted from the dependency array. walletService is a module-level singleton and | |
| // the setter functions are stable references from the store, so including them would | |
| // not change the behavior of this effect and would only satisfy the linter. | |
| // This mirrors the pattern in app/(tabs)/send.tsx where certain stable values are | |
| // intentionally excluded (e.g., "feeRate is intentionally not included to prevent infinite loop"). |
Description
This PR includes minor code quality improvements across three files: consolidating imports, updating type annotation syntax for consistency, and adding an ESLint directive to suppress a false positive warning.
Type of Change
Changes Made
TextInputimport fromreact-nativewith other imports on the same line, removing the duplicate import statementrequiredFunctionstype annotation fromArray<keyof WalletService>to(keyof WalletService)[]for consistency with modern TypeScript conventionseslint-disable-next-line react-hooks/exhaustive-depscomment to suppress a false positive warning on the dependency array, as the dependencies are intentionally limited to prevent unnecessary re-rendersTesting Performed
Automated Testing
Checklist
Additional Notes
These are purely stylistic and maintainability improvements with no impact on runtime behavior or functionality.
https://claude.ai/code/session_017rsjCBTqJkzoTRcL7YXthq