fix: remove redundant type assertion (S4325)#3628
Conversation
Summary by CodeRabbit
WalkthroughReplaced runtime type assertion of Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@frontend/src/app/my/mentorship/programs/`[programKey]/edit/page.tsx:
- Around line 56-59: The access to session?.user?.login in the isAdmin check is
unsafe because the base next-auth Session type doesn't include login; either
reintroduce the cast (session as ExtendedSession)?.user?.login in the isAdmin
expression or add a module augmentation to extend next-auth's Session type to
include user.login so TypeScript recognizes it; update the isAdmin line
(referencing isAdmin, session, ExtendedSession, and data.getProgram.admins)
accordingly to restore type safety.
|
Thanks for the review! I’ve updated the code to safely narrow the session.user type before accessing |
|
kasya
left a comment
There was a problem hiding this comment.
@anukalp2804 thanks for working on this!
I updated your PR - you did not run make check-test locally and it is required. Please make sure to run it next time.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3628 +/- ##
==========================================
+ Coverage 85.55% 87.67% +2.12%
==========================================
Files 463 462 -1
Lines 14303 14324 +21
Branches 1904 1915 +11
==========================================
+ Hits 12237 12559 +322
+ Misses 1687 1346 -341
- Partials 379 419 +40
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 23 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|



Proposed change
Resolves #3554
This PR fixes a Sonar-reported code smell (typescript:S4325).
The type assertion
(session as ExtendedSession)was redundant and did not change the effective type of the expression when optional chaining was already used. The assertion has been removed to improve readability and align with TypeScript and Sonar best practices.No functional changes.
Checklist
make check-testlocally