refactor: remove unnecessary ReactElement type annotations from components#40815
Conversation
|
WalkthroughReact components across GameCenter, provider utilities, and Storybook mocks have their explicit ChangesReact component return type simplification
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (2)
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. Comment |
|
Looks like this PR is ready to merge! 🎉 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #40815 +/- ##
===========================================
- Coverage 70.21% 70.14% -0.08%
===========================================
Files 3340 3340
Lines 123638 123638
Branches 22067 22048 -19
===========================================
- Hits 86816 86721 -95
- Misses 33476 33574 +98
+ Partials 3346 3343 -3
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
cb144ef to
4af3085
Compare
4af3085 to
e014b1b
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/meteor/client/providers/UserProvider/hooks/useReloadAfterLogin.ts`:
- Line 9: The ref usernameRef in the hook useReloadAfterLogin is typed as
useRef<string> but initialized to undefined, causing a type mismatch; update the
ref's type to allow undefined (e.g., useRef<string | undefined>) or initialize
it with a string value so the declared type matches its initial value, and
ensure any usages of usernameRef.current still handle possible undefined values.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 4a42f879-b968-45bb-b870-30626d2d2173
📒 Files selected for processing (16)
apps/meteor/client/apps/gameCenter/GameCenter.tsxapps/meteor/client/apps/gameCenter/GameCenterContainer.tsxapps/meteor/client/apps/gameCenter/GameCenterInvitePlayersModal.tsxapps/meteor/client/apps/gameCenter/GameCenterList.tsxapps/meteor/client/providers/ActionManagerProvider.tsxapps/meteor/client/providers/AuthenticationProvider/AuthenticationProvider.tsxapps/meteor/client/providers/DeviceProvider/DeviceProvider.tsxapps/meteor/client/providers/EmojiPickerProvider/EmojiPickerProvider.tsxapps/meteor/client/providers/TranslationProvider.tsxapps/meteor/client/providers/UserProvider/UserProvider.tsxapps/meteor/client/providers/UserProvider/hooks/useReloadAfterLogin.tsapps/meteor/client/providers/VideoConfProvider.tsxapps/meteor/client/stories/contexts/ModalContextMock.tsxapps/meteor/client/stories/contexts/RouterContextMock.tsxapps/meteor/client/stories/contexts/ServerContextMock.tsxapps/meteor/client/stories/contexts/TranslationContextMock.tsx
📜 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). (4)
- 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/client/apps/gameCenter/GameCenter.tsxapps/meteor/client/providers/UserProvider/hooks/useReloadAfterLogin.tsapps/meteor/client/stories/contexts/RouterContextMock.tsxapps/meteor/client/stories/contexts/ModalContextMock.tsxapps/meteor/client/providers/AuthenticationProvider/AuthenticationProvider.tsxapps/meteor/client/providers/ActionManagerProvider.tsxapps/meteor/client/apps/gameCenter/GameCenterContainer.tsxapps/meteor/client/stories/contexts/TranslationContextMock.tsxapps/meteor/client/providers/UserProvider/UserProvider.tsxapps/meteor/client/apps/gameCenter/GameCenterList.tsxapps/meteor/client/stories/contexts/ServerContextMock.tsxapps/meteor/client/providers/DeviceProvider/DeviceProvider.tsxapps/meteor/client/providers/VideoConfProvider.tsxapps/meteor/client/providers/TranslationProvider.tsxapps/meteor/client/apps/gameCenter/GameCenterInvitePlayersModal.tsxapps/meteor/client/providers/EmojiPickerProvider/EmojiPickerProvider.tsx
🧠 Learnings (6)
📚 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/client/apps/gameCenter/GameCenter.tsxapps/meteor/client/stories/contexts/RouterContextMock.tsxapps/meteor/client/stories/contexts/ModalContextMock.tsxapps/meteor/client/providers/AuthenticationProvider/AuthenticationProvider.tsxapps/meteor/client/providers/ActionManagerProvider.tsxapps/meteor/client/apps/gameCenter/GameCenterContainer.tsxapps/meteor/client/stories/contexts/TranslationContextMock.tsxapps/meteor/client/providers/UserProvider/UserProvider.tsxapps/meteor/client/apps/gameCenter/GameCenterList.tsxapps/meteor/client/stories/contexts/ServerContextMock.tsxapps/meteor/client/providers/DeviceProvider/DeviceProvider.tsxapps/meteor/client/providers/VideoConfProvider.tsxapps/meteor/client/providers/TranslationProvider.tsxapps/meteor/client/apps/gameCenter/GameCenterInvitePlayersModal.tsxapps/meteor/client/providers/EmojiPickerProvider/EmojiPickerProvider.tsx
📚 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/client/apps/gameCenter/GameCenter.tsxapps/meteor/client/providers/UserProvider/hooks/useReloadAfterLogin.tsapps/meteor/client/stories/contexts/RouterContextMock.tsxapps/meteor/client/stories/contexts/ModalContextMock.tsxapps/meteor/client/providers/AuthenticationProvider/AuthenticationProvider.tsxapps/meteor/client/providers/ActionManagerProvider.tsxapps/meteor/client/apps/gameCenter/GameCenterContainer.tsxapps/meteor/client/stories/contexts/TranslationContextMock.tsxapps/meteor/client/providers/UserProvider/UserProvider.tsxapps/meteor/client/apps/gameCenter/GameCenterList.tsxapps/meteor/client/stories/contexts/ServerContextMock.tsxapps/meteor/client/providers/DeviceProvider/DeviceProvider.tsxapps/meteor/client/providers/VideoConfProvider.tsxapps/meteor/client/providers/TranslationProvider.tsxapps/meteor/client/apps/gameCenter/GameCenterInvitePlayersModal.tsxapps/meteor/client/providers/EmojiPickerProvider/EmojiPickerProvider.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/providers/UserProvider/hooks/useReloadAfterLogin.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/providers/UserProvider/hooks/useReloadAfterLogin.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 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/client/providers/UserProvider/hooks/useReloadAfterLogin.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/client/providers/UserProvider/hooks/useReloadAfterLogin.ts
🔇 Additional comments (15)
apps/meteor/client/apps/gameCenter/GameCenter.tsx (1)
5-5: LGTM!Also applies to: 14-14
apps/meteor/client/apps/gameCenter/GameCenterContainer.tsx (1)
20-20: LGTM!apps/meteor/client/apps/gameCenter/GameCenterInvitePlayersModal.tsx (1)
22-22: LGTM!apps/meteor/client/apps/gameCenter/GameCenterList.tsx (1)
24-24: LGTM!apps/meteor/client/stories/contexts/ModalContextMock.tsx (1)
3-3: LGTM!Also applies to: 12-12
apps/meteor/client/stories/contexts/RouterContextMock.tsx (1)
3-3: LGTM!Also applies to: 18-18
apps/meteor/client/stories/contexts/ServerContextMock.tsx (1)
7-7: LGTM!Also applies to: 69-69
apps/meteor/client/stories/contexts/TranslationContextMock.tsx (1)
4-4: LGTM!Also applies to: 11-11
apps/meteor/client/providers/ActionManagerProvider.tsx (1)
2-2: LGTM!Also applies to: 15-15
apps/meteor/client/providers/AuthenticationProvider/AuthenticationProvider.tsx (1)
6-6: LGTM!Also applies to: 60-60
apps/meteor/client/providers/DeviceProvider/DeviceProvider.tsx (1)
5-5: LGTM!Also applies to: 31-31
apps/meteor/client/providers/EmojiPickerProvider/EmojiPickerProvider.tsx (1)
2-2: LGTM!Also applies to: 15-16
apps/meteor/client/providers/TranslationProvider.tsx (1)
18-18: LGTM!Also applies to: 191-191, 255-255
apps/meteor/client/providers/UserProvider/UserProvider.tsx (1)
10-10: LGTM!Also applies to: 64-64
apps/meteor/client/providers/VideoConfProvider.tsx (1)
4-4: LGTM!Also applies to: 12-12
|
|
||
| export const useReloadAfterLogin = (user: IUser | null) => { | ||
| const usernameRef = useRef<string>(); | ||
| const usernameRef = useRef<string>(undefined); |
There was a problem hiding this comment.
Type annotation mismatch: useRef<string> initialized with undefined.
The ref is typed as useRef<string> but initialized with undefined, which creates a type mismatch. Lines 13-14 correctly treat usernameRef.current as possibly falsy, but the type annotation doesn't reflect this.
🔧 Correct the type annotation
- const usernameRef = useRef<string>(undefined);
+ const usernameRef = useRef<string | undefined>(undefined);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const usernameRef = useRef<string>(undefined); | |
| const usernameRef = useRef<string | undefined>(undefined); |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@apps/meteor/client/providers/UserProvider/hooks/useReloadAfterLogin.ts` at
line 9, The ref usernameRef in the hook useReloadAfterLogin is typed as
useRef<string> but initialized to undefined, causing a type mismatch; update the
ref's type to allow undefined (e.g., useRef<string | undefined>) or initialize
it with a string value so the declared type matches its initial value, and
ensure any usages of usernameRef.current still handle possible undefined values.
Proposed changes (including videos or screenshots)
As a first step towards upgrading to React 19, it handles types from
@types/reactlooking 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