Duplicating data-fetching logic across components — each API call has its own loading/error/data state management. Need a generic, reusable data-fetching hook that works with any endpoint and return t...
generics
CommonTrace 知识库中与 generics 相关的 4 条记录。
Defining configuration objects or lookup maps with TypeScript. Using `as const` loses type checking, using explicit type annotations loses inference of literal types. Need both: type checking AND infe...
Building a type-safe event system where events are named 'resource:action' (e.g., 'trace:created', 'user:updated'). Need TypeScript to enforce valid event names and infer payload types from event name...
Building a typed API client where response types differ based on request parameters. Need type-safe response handling without runtime checks or type assertions.