DEV Community

Discussion on: Working with React context providers in Typescript

Collapse
 
mitchkarajohn profile image
Dimitris Karagiannis

Thank you, glad you found the article useful!
To be honest, if you do end up defining the Provider's default value with a proxy that follows the schema/type of a valid value, the type assertion when you use the hook is probably not necessary.
The types between default and valid values should match, and if it's a default value it would simply throw on runtime (due to the proxy default value)