RocketChat / RocketChat/Rocket.Chat

chore: fix unsafe type assertions in Custom Sounds components

Open
#38,739 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: feature
Dominant language
TypeScript
Stars
46.1k
Forks
13.9k
Avg merge
3d 3h
Merged PRs (30d)
130

Description

Issue Description

Description
In the Custom Sounds administration views (AddCustomSound.tsx and EditSound.tsx), there are multiple // FIXME comments marking unsafe type assertions (as any) and any typed parameters. This bypasses TypeScript's safety checks and can lead to potential runtime errors.

Affected Files:

  • client/views/admin/customSounds/AddCustomSound.tsx: soundFile parameter is typed as any
  • client/views/admin/customSounds/EditSound.tsx: sound parameter is typed as any
  • client/views/admin/customSounds/lib.ts: Missing optional property in type definition causing type mismatch

Goal
Refactor the components to use proper TypeScript types (e.g., File and union types) and remove the unsafe assertions.

Proposed Solution

  • Type AddCustomSound state and handlers as File
  • Use union type EditSoundProps['data'] | File in EditSound with proper type narrowing (instanceof File)
  • Ensure validate and createSoundData utility functions accept the correct types

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 by reading the FIXME-marked assertions and parameters in client/views/admin/customSounds/AddCustomSound.tsx and EditSound.tsx, then inspect the related type definition and utilities in client/views/admin/customSounds/lib.ts. Done means the affected state, handlers, validate, and createSoundData usage have proper TypeScript types without unsafe assertions or any parameters.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.