Skip to content

Bug Fix: TypeScript migration for helpers.ts #6781

@deepakbhagatiitr

Description

@deepakbhagatiitr

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions