Throw error by default when context is unavailable
pi0 opened this issue · comments
(breaking change)
Reference: nuxt/framework#4059
Using context without checking it's existence, is usually unsafe since the code is unguarded. We could improve this by always throwing an error when use()
cannot access context and introduce new tryUse
that might return null
. as well
Maybe with a strict
option to toggle the throwing behavior?
Maybe with a strict option to toggle the throwing behavior?
I'm up to also introduce an option to disable strictness but this have to be default behavior and with fixed API, we can adjust types to return T
instead of T | null
for tryUse
Sounds good! Do you want me to work on it?