RocketChat / RocketChat/Rocket.Chat.ReactNative

Bug Fix: TypeScript migration for helpers.ts

Open
#6,781 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

🐛 bug
Dominant language
TypeScript
Stars
2.4k
Forks
1.5k
Avg merge
1d 18h
Merged PRs (30d)
90

Description

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
  1. Open app/lib/methods/helpers/helpers.ts
  2. Observe @ts-nocheck - TEMP comment at line 1
  3. Notice all function parameters lack type annotations (e.g., room, sender, item are untyped)
  4. Run yarn lint or TypeScript compiler - no type errors are reported for this file despite missing types
Expected Behavior
  • Remove @ts-nocheck directive
  • 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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with app/lib/methods/helpers/helpers.ts and inspect the listed helper functions, then read their usages in app/lib/hooks/useUserData.ts and app/containers/MessageComposer/components/ComposerInput.tsx to determine the required types. Run yarn lint and the TypeScript compiler while removing @ts-nocheck and adding parameter and return annotations; done means the file is fully checked without new type errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
developer-experience, mobile-dev
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.