Bug Fix: TypeScript migration for helpers.ts
Describe the Bug
The file app/lib/methods/helpers/helpers.ts has @ts-nocheck at the top, which disables TypeScript checking for the entire file. All 8 exported functions lack proper TypeScript type annotations, reducing type safety and developer experience.
Steps to Reproduce
- Open
app/lib/methods/helpers/helpers.ts - Observe
@ts-nocheck - TEMPcomment at line 1 - Notice all function parameters lack type annotations (e.g.,
room,sender,itemare untyped) - Run
yarn lintor TypeScript compiler - no type errors are reported for this file despite missing types
Expected Behavior
- Remove
@ts-nocheckdirective - Add proper TypeScript types to all function parameters and return types
- All functions should have complete type annotations
- TypeScript compiler should properly check this file
Actual Behavior
- TypeScript checking is disabled for the entire file
- No type safety for 8 exported functions
- Potential runtime errors that could be caught at compile time
- Poor IDE autocomplete and IntelliSense support
Rocket.Chat Server Version
N/A (Code quality issue, not server-dependent)
Rocket.Chat App Version
4.67.0
Device Name
N/A (Code quality issue, not device-specific)
OS Version
N/A (Code quality issue, not OS-specific)
Additional Context
File: app/lib/methods/helpers/helpers.ts
Functions to migrate:
-
isGroupChat(room) -
getRoomAvatar(room) -
getUidDirectMessage(room) -
getRoomTitle(room) -
getSenderName(sender) -
canAutoTranslate() -
isRead(item) -
hasRole(role) -
hasPermission(permissions, rid?)
Impact: This file is used in multiple places:
-
app/lib/hooks/useUserData.ts -
app/containers/MessageComposer/components/ComposerInput.tsx - And potentially other files
Related: Part of TypeScript migration effort to improve code quality and maintainability.
@deepakbhagatiitr could you please assign this to me?
@deepakbhagatiitr could you please assign this to me?
No one gets assigned to any specific issue. It you think you can create a fix for this, feel free to open pull request anytime :)
@Rohit3523 Thanks :)
Hi, I've completed the TypeScript migration for helpers.ts and opened PR #6796 to address this issue.
Summary of changes:
- ✅ Removed
@ts-nocheckdirective fromapp/lib/methods/helpers/helpers.ts - ✅ Added proper TypeScript types and JSDoc comments to all 8 helper functions
- ✅ Created
TRoomLiketype to handle bothIRoomandISubscriptionobjects - ✅ Added null checks in calling code to ensure type safety
- ✅ All TypeScript compilation passes (0 errors in app code)
- ✅ ESLint passes with no warnings
- ✅ Metro bundler successfully builds the app
Files modified: 4 files (85 insertions, 40 deletions)
The migration is complete and ready for review. All existing functionality is preserved while improving type safety across the codebase.