RocketChat / RocketChat/Rocket.Chat

GenericMenu: Improve type safety by removing unsafe casts

Open
#38,748 0 comments 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

The GenericMenu component currently uses an unsafe as any cast when cloning the button prop, and the button prop itself lacks a specific React type.

Proposed Improvement:

Add explicit ReactElement type to the button prop in GenericMenuCommonProps.

Remove the as any assertion in cloneElement.

Motivation:
This improves the overall type safety of the ui-client package and provides a better developer experience without changing runtime behavior.

Related PR:
#38594

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 locating GenericMenu and GenericMenuCommonProps in the ui-client package, then inspect the button prop and the cloneElement call; review related PR #38594 for context. Done means the button prop has an explicit ReactElement type, the unsafe as any assertion is removed, and the package's type checks pass without runtime changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Refactor
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.