Skip to content

fix: remove unsafe type casting in errorMappingFn#77

Closed
michaelbe812 wants to merge 1 commit into
mainfrom
fix/error-mapping-type-mismatch
Closed

fix: remove unsafe type casting in errorMappingFn#77
michaelbe812 wants to merge 1 commit into
mainfrom
fix/error-mapping-type-mismatch

Conversation

@michaelbe812

Copy link
Copy Markdown
Owner

Summary

  • Fixed type mismatch in errorMappingFn that required unsafe type casting
  • Improved type safety throughout error handling pipeline

Changes

  • Changed errorMappingFn return type from unknown to E for type consistency
  • Removed unsafe as any cast in handleError function
  • Maintains type safety without breaking existing functionality

Problem

The errorMappingFn was typed to return unknown, but the error field in RxStatefulWithError expects type E. This mismatch forced the use of unsafe as any casting in the handleError function.

Solution

Updated the type signature to maintain consistency:

  • errorMappingFn?: (error: E) => E

This ensures the error type remains consistent throughout the pipeline while removing the need for unsafe casting.

Testing

  • ✅ All existing tests pass
  • ✅ Type checking passes
  • ✅ Linting passes
  • ✅ Build succeeds

Fixes #46

- Changed errorMappingFn return type from unknown to E for type consistency
- Removed unsafe 'as any' cast in handleError function
- Maintains type safety throughout error handling pipeline

Fixes #46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix error mapping type mismatch in errorMappingFn

1 participant