Current Issue:
The current implementation of cache.get does not support explicit type definitions, which limits type safety and can lead to potential issues with type inference. Here's how it's currently implemented:
const { cache } = useSWRConfig();
const data = cache.get('key'); // data: any
Proposed Changes:
This pull request modifies cache.get to accept generic type parameters, enhancing type safety by allowing developers to specify the expected return type. The modified implementation is as follows:
This update ensures better type checking and integration with TypeScript projects, aligning with modern development practices in type-safe applications.
Description:
Current Issue: The current implementation of cache.get does not support explicit type definitions, which limits type safety and can lead to potential issues with type inference. Here's how it's currently implemented:
Proposed Changes: This pull request modifies cache.get to accept generic type parameters, enhancing type safety by allowing developers to specify the expected return type. The modified implementation is as follows:
This update ensures better type checking and integration with TypeScript projects, aligning with modern development practices in type-safe applications.