Skip to content

refactor: remove unnecessary ReactElement type annotations from components#40814

Merged
tassoevan merged 1 commit into
developfrom
refactor/prepare-types-for-react-19-12
Jun 9, 2026
Merged

refactor: remove unnecessary ReactElement type annotations from components#40814
tassoevan merged 1 commit into
developfrom
refactor/prepare-types-for-react-19-12

Conversation

@tassoevan

@tassoevan tassoevan commented Jun 4, 2026

Copy link
Copy Markdown
Member

⚠️ This is part 12/23 of #40796. PR for refactor/prepare-types-for-react-19-11 must be merged first.


Proposed changes (including videos or screenshots)

As a first step towards upgrading to React 19, it handles types from @types/react looking forward the next major.

Issue(s)

Task: ARCH-2170

Steps to test or reproduce

Further comments

No runtime change is expected from it.

Summary by CodeRabbit

  • Refactor
    • Improved type safety by allowing null reference values in composer initialization.
    • Simplified test infrastructure by removing redundant type annotations and streamlining component signatures.

@changeset-bot

changeset-bot Bot commented Jun 4, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 9b4a3bf

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 06d12ed9-5314-4065-a5d5-0aeb424602df

📥 Commits

Reviewing files that changed from the base of the PR and between 918abe1 and 9b4a3bf.

📒 Files selected for processing (6)
  • apps/meteor/app/ui-message/client/messageBox/createComposerAPI.ts
  • apps/meteor/client/lib/chats/ChatAPI.ts
  • apps/meteor/tests/mocks/client/FakeChatProvider.tsx
  • apps/meteor/tests/mocks/client/FakeRoomProvider.tsx
  • apps/meteor/tests/mocks/client/ModalContextMock.tsx
  • apps/meteor/tests/mocks/client/RouterContextMock.tsx
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: Hacktron Security Check
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • apps/meteor/app/ui-message/client/messageBox/createComposerAPI.ts
  • apps/meteor/tests/mocks/client/FakeChatProvider.tsx
  • apps/meteor/tests/mocks/client/ModalContextMock.tsx
  • apps/meteor/tests/mocks/client/RouterContextMock.tsx
  • apps/meteor/client/lib/chats/ChatAPI.ts
  • apps/meteor/tests/mocks/client/FakeRoomProvider.tsx
🧠 Learnings (6)
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.

Applied to files:

  • apps/meteor/app/ui-message/client/messageBox/createComposerAPI.ts
  • apps/meteor/client/lib/chats/ChatAPI.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.

Applied to files:

  • apps/meteor/app/ui-message/client/messageBox/createComposerAPI.ts
  • apps/meteor/client/lib/chats/ChatAPI.ts
📚 Learning: 2026-05-06T12:21:44.083Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 40256
File: apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx:121-149
Timestamp: 2026-05-06T12:21:44.083Z
Learning: Field wrappers in rocket.chat/fuselage-forms (Field, FieldLabel, FieldRow, FieldError, FieldHint) auto-create htmlFor/id associations, aria-describedby, and role="alert" for errors. Do not manually set htmlFor, id, aria-describedby, or role attributes when using these wrappers. This automatic wiring does not apply to plain rocket.chat/fuselage components, which require explicit ID wiring per the accessibility docs. In code reviews, prefer using fuselage-forms wrappers for form fields and verify there is no unnecessary manual ID/aria wiring in files that use these wrappers. If a component uses plain fuselage components, ensure proper id wiring as per docs.

Applied to files:

  • apps/meteor/app/ui-message/client/messageBox/createComposerAPI.ts
  • apps/meteor/tests/mocks/client/FakeChatProvider.tsx
  • apps/meteor/tests/mocks/client/ModalContextMock.tsx
  • apps/meteor/tests/mocks/client/RouterContextMock.tsx
  • apps/meteor/client/lib/chats/ChatAPI.ts
  • apps/meteor/tests/mocks/client/FakeRoomProvider.tsx
📚 Learning: 2026-03-27T14:52:56.865Z
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 39892
File: apps/meteor/client/views/room/contextualBar/Threads/Thread.tsx:150-155
Timestamp: 2026-03-27T14:52:56.865Z
Learning: In Rocket.Chat, there are two different `ModalBackdrop` components with different prop APIs. During review, confirm the import source: (1) `rocket.chat/fuselage` `ModalBackdrop` uses `ModalBackdropProps` based on `BoxProps` (so it supports `onClick` and other Box/DOM props) and does not have an `onDismiss` prop; (2) `rocket.chat/ui-client` `ModalBackdrop` uses a narrower props interface like `{ children?: ReactNode; onDismiss?: () => void }` and handles Escape keypress and outside mouse-up, and it does not forward arbitrary DOM props such as `onClick`. Flag mismatched props (e.g., `onDismiss` passed to the fuselage component or `onClick` passed to the ui-client component) and ensure the usage matches the correct component being imported.

Applied to files:

  • apps/meteor/tests/mocks/client/FakeChatProvider.tsx
  • apps/meteor/tests/mocks/client/ModalContextMock.tsx
  • apps/meteor/tests/mocks/client/RouterContextMock.tsx
  • apps/meteor/tests/mocks/client/FakeRoomProvider.tsx
📚 Learning: 2026-02-10T16:32:42.586Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 38528
File: apps/meteor/client/startup/roles.ts:14-14
Timestamp: 2026-02-10T16:32:42.586Z
Learning: In Rocket.Chat's Meteor client code, DDP streams use EJSON and Date fields arrive as Date objects; do not manually construct new Date() in stream handlers (for example, in sdk.stream()). Only REST API responses return plain JSON where dates are strings, so implement explicit conversion there if needed. Apply this guidance to all TypeScript files under apps/meteor/client to ensure consistent date handling in DDP streams and REST responses.

Applied to files:

  • apps/meteor/client/lib/chats/ChatAPI.ts
📚 Learning: 2026-05-11T20:30:35.265Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 40480
File: apps/meteor/client/meteor/startup/accounts.ts:59-61
Timestamp: 2026-05-11T20:30:35.265Z
Learning: In Rocket.Chat’s Meteor client code, when calling `dispatchToastMessage` with `{ type: 'error' }`, pass the raw caught error object as `message` without manual normalization. `dispatchToastMessage` is designed to accept `message: unknown` for error toasts, so avoid converting errors to strings (e.g., `String(error)`) or extracting `error.message` before passing them.

Applied to files:

  • apps/meteor/client/lib/chats/ChatAPI.ts
🔇 Additional comments (6)
apps/meteor/client/lib/chats/ChatAPI.ts (1)

71-71: LGTM!

apps/meteor/app/ui-message/client/messageBox/createComposerAPI.ts (1)

18-18: LGTM!

apps/meteor/tests/mocks/client/FakeChatProvider.tsx (1)

1-1: LGTM!

Also applies to: 10-10

apps/meteor/tests/mocks/client/FakeRoomProvider.tsx (1)

3-3: LGTM!

Also applies to: 15-15

apps/meteor/tests/mocks/client/ModalContextMock.tsx (1)

2-2: LGTM!

Also applies to: 9-9

apps/meteor/tests/mocks/client/RouterContextMock.tsx (1)

5-5: LGTM!

Also applies to: 66-66


Walkthrough

This PR refactors TypeScript type signatures across the codebase. The ComposerAPI type definition is updated to allow nullable HTMLElement references, and the createComposerAPI function parameter is adjusted accordingly. Test mock providers are simplified by removing explicit ReactElement return type annotations and narrowing React type imports to only what is needed.

Changes

Type signature updates and mock provider cleanup

Layer / File(s) Summary
ComposerAPI nullable composerRef type
apps/meteor/client/lib/chats/ChatAPI.ts, apps/meteor/app/ui-message/client/messageBox/createComposerAPI.ts
ComposerAPI.composerRef is widened from RefObject<HTMLElement> to `RefObject<HTMLElement
Mock providers type simplification
apps/meteor/tests/mocks/client/FakeChatProvider.tsx, apps/meteor/tests/mocks/client/FakeRoomProvider.tsx, apps/meteor/tests/mocks/client/ModalContextMock.tsx, apps/meteor/tests/mocks/client/RouterContextMock.tsx
Explicit ReactElement return type annotations are removed from all test mock provider components, and type imports are narrowed to only required utilities (ReactNode, ContextType, MutableRefObject). No runtime behavior is changed.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • RocketChat/Rocket.Chat#40804: TypeScript-only React typings cleanup removing explicit ReactElement annotations from exported components across avatar components.
  • RocketChat/Rocket.Chat#40812: Matching TypeScript refactor removing explicit ReactElement return type annotations from React components in PDF worker modules.
  • RocketChat/Rocket.Chat#40807: Related React 19 type-refactor effort that removes explicit ReactElement return annotations and widens ref types to allow null.

Suggested labels

type: chore

Suggested reviewers

  • ggazzo
  • dougfabris
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: removing unnecessary ReactElement type annotations from components across multiple files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (2)
  • REACT-19: Request failed with status code 401
  • ARCH-2170: Request failed with status code 401

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dionisio-bot

dionisio-bot Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

@codecov

codecov Bot commented Jun 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.16%. Comparing base (918abe1) to head (9b4a3bf).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #40814      +/-   ##
===========================================
- Coverage    70.17%   70.16%   -0.01%     
===========================================
  Files         3340     3340              
  Lines       123638   123638              
  Branches     22061    22053       -8     
===========================================
- Hits         86759    86747      -12     
- Misses       33539    33542       +3     
- Partials      3340     3349       +9     
Flag Coverage Δ
e2e 59.34% <ø> (-0.11%) ⬇️
e2e-api 46.99% <ø> (+0.63%) ⬆️
unit 70.97% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tassoevan tassoevan force-pushed the refactor/prepare-types-for-react-19-12 branch from 69a3550 to 9b4a3bf Compare June 9, 2026 03:09
@tassoevan tassoevan requested a review from a team June 9, 2026 03:09
@tassoevan tassoevan added this to the 8.6.0 milestone Jun 9, 2026
@tassoevan tassoevan marked this pull request as ready for review June 9, 2026 03:09
@tassoevan tassoevan added the stat: QA assured Means it has been tested and approved by a company insider label Jun 9, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label Jun 9, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 6 files

Re-trigger cubic

@tassoevan tassoevan enabled auto-merge June 9, 2026 03:29
@tassoevan tassoevan added this pull request to the merge queue Jun 9, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 9, 2026
@tassoevan tassoevan added this pull request to the merge queue Jun 9, 2026
Merged via the queue into develop with commit d03acfc Jun 9, 2026
48 checks passed
@tassoevan tassoevan deleted the refactor/prepare-types-for-react-19-12 branch June 9, 2026 05:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge type: chore

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants