typestack / routing-controllers

Create structured, declarative and beautifully organized class-based controllers with heavy decorators usage in Express / Koa using TypeScript and Routing Controllers Framework.
MIT License
4.36k stars 392 forks source link

feature: Introduce Generics to CurrentUserChecker for Enhanced Type Safety #1374

Closed angelxmoreno closed 2 months ago

angelxmoreno commented 2 months ago

Description

Currently, the CurrentUserChecker function in routing-controllers uses a return type of Promise<any> | any, which doesn't utilize TypeScript's capabilities for strong typing. This can lead to potential type mismatches and less predictable code, especially in larger projects where strict type checking is crucial.

Proposed Solution

The CurrentUserChecker should be enhanced to support generic types, allowing developers to specify the expected user type more explicitly. This will improve code reliability and developer experience by leveraging TypeScript's type system more effectively.

Implementation:

Alternative Solutions Considered:

The proposed solution strikes a balance between improving type safety and maintaining backward compatibility, thus providing a seamless upgrade path for current users while offering improved functionality.

angelxmoreno commented 2 months ago

I created a PR #1375

github-actions[bot] commented 1 month ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.