RocketChat / RocketChat/Rocket.Chat
chore: fix unsafe type assertions in Custom Sounds components
Nobody has claimed this yet.
- 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:soundFileparameter is typed asanyclient/views/admin/customSounds/EditSound.tsx:soundparameter is typed asanyclient/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
AddCustomSoundstate and handlers asFile - Use union type
EditSoundProps['data'] | FileinEditSoundwith proper type narrowing (instanceof File) - Ensure
validateandcreateSoundDatautility functions accept the correct types
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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