tessl install tessl/npm-types--react@19.1.0TypeScript definitions for React, the popular JavaScript library for building user interfaces
Agent Success
Agent success rate when using this tile
80%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.48x
Baseline
Agent success rate without this tile
54%
Build a higher-order component that adds authentication and role-based access control to React components.
withAuth and user prop { isAuthenticated: false }, it displays "Please log in to access this content" @testwithAuth requiring role "admin", user prop { isAuthenticated: true, role: "user" }, it displays "Access denied: insufficient permissions" @testwithAuth requiring role "admin", user prop { isAuthenticated: true, role: "admin" }, it renders the wrapped component @testwithAuth (no role required), user prop { isAuthenticated: true }, it renders the wrapped component with all original props @test@generates
export interface AuthUser {
isAuthenticated: boolean;
role?: string;
}
export interface WithAuthConfig {
requiredRole?: string;
}
export interface WithAuthProps {
user: AuthUser;
}
export function withAuth<P extends object>(
Component: React.ComponentType<P>,
config?: WithAuthConfig
): React.ComponentType<P & WithAuthProps>;Provides TypeScript type definitions for React including ComponentType, higher-order component patterns, and proper prop typing.
@satisfied-by