DEV Community

Discussion on: Working with React context providers in Typescript

mitchkarajohn profile image
Dimitris Karagiannis Author

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)