Frontend engineer, working with the Javascripts and the HTMLs and the CSSs. Hardware tinkerer and music enthusiast. Co-founder and former front end engineer at Sourcelair.
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)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Great article.
Wasn't comfortable with the developer time solution as it goes against typescript principles.
First time I'm hearing about Proxy. Thanks for sharing.
I think defining default values for the context type might work
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)