Skip to content

fix: eliminate unsafe any casts in useAuth, socket, axios, and App (#804 #805 #806 #807) - #889

Merged
RUKAYAT-CODER merged 4 commits into
rinafcode:mainfrom
Tyler7x:fix/tyler7x-typescript-fixes-804-805-806-807
Jul 27, 2026
Merged

fix: eliminate unsafe any casts in useAuth, socket, axios, and App (#804 #805 #806 #807)#889
RUKAYAT-CODER merged 4 commits into
rinafcode:mainfrom
Tyler7x:fix/tyler7x-typescript-fixes-804-805-806-807

Conversation

@Tyler7x

@Tyler7x Tyler7x commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Closes #804
Closes #805
Closes #806
Closes #807

Summary

Four TypeScript correctness fixes removing any assertions and unsafe casts that hid real type errors.

#804 — null-safe authErrorCode in useAuth.tsx
getAuthErrorMessage() was called with authErrorCode which could be undefined (when the server error response doesn't include an error field). This produced a broken or misleading error message. Added a conditional: if authErrorCode is falsy, a safe generic fallback ('Authentication failed. Please try again.') is thrown instead.

#805 — Typed socket event callbacks
SocketService.on() and the internal registerLoggedHandler() previously typed their callback parameters as any, meaning event consumers had no type inference for handler data. Changed both to on<T = unknown>(event, callback: (data: T) => void) so callers can pass an explicit generic (e.g. socketService.on<CourseUpdatedPayload>('course_updated', handler)) and get full type safety on the received data.

#806 — Runtime validation of 409 ConflictData response
axios.config.ts cast error.response.data to a ConflictData-compatible shape purely at the TypeScript level. If the server changes its 409 response format, the cast silently yields undefined field accesses. Added isConflictResponseShape() — a lightweight runtime type guard — that validates the object shape before any field access, and reports malformed responses to Sentry instead of propagating corrupt data to the conflict store.

#807 — FeatureType guard replaces feature as any in App.tsx
Object.entries(capabilities) returns string keys, but setFeatureStatus expects a FeatureType enum value. The feature as any bypass suppressed this mismatch. Replaced with an isFeatureType(key) predicate that validates membership in Object.values(FeatureType) at runtime, so only valid enum values reach setFeatureStatus and the cast is provably correct.

Files changed

@drips-wave

drips-wave Bot commented Jul 27, 2026

Copy link
Copy Markdown

@Tyler7x Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

Thank you for contributing to the project.

@RUKAYAT-CODER
RUKAYAT-CODER merged commit 308c146 into rinafcode:main Jul 27, 2026
1 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment