I was trying to type useContext hook and found this blog post https://blog.logrocket.com/how-to-use-react-context-with-typescript/as author wrote
- The type.d.ts file that contains the TypeScript Types. The extension .d.ts allows using the types in other files without importing them
and the example shows usage like so:
const { saveTodo } = React.useContext(TodoContext) as ContextTypeso I have created contexts.d.ts and inside I declared a type like so
import type { UserMetrics } from "../components";type UserMetricsContextType = { userMetrics: UserMetrics; setUserMetrics: React.Dispatch<React.SetStateAction<UserMetrics>>;};and when I try to use it in the application, I get:
type UserMetricsContextType = /*unresolved*/ anyCould you please explain what am I doing wrong?
Thanks