You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would expect that to be able to use context without doing any null/undefined checks, since I've written the "guarantee" that I indeed have this context in my app.
exportasyncfunctionloader({context}: LoaderArgs){getSomeData(context.userId);// I would like to be able to do this}
Actual Behavior
Because the type for context is AppLoadContext | undefined in the loader and action args, theres' no way that I know of to tell typescript that it will never be undefined. This means that whenever you wish to use context, you must either assert its existence with ! , or you must actually check that it exists to make typescript happy.
exportasyncfunctionloader({context}: LoaderArgs){getSomeData(context!.userId);// but instead I have to do this}
exportasyncfunctionloader({context}: LoaderArgs){invariant(context);// or thisgetSomeData(context.userId);}
The text was updated successfully, but these errors were encountered:
What version of Remix are you using?
1.6.8
Steps to Reproduce
Augment the server-runtime module and declare properties on the AppLoadContext interface
Expected Behavior
I would expect that to be able to use
context
without doing any null/undefined checks, since I've written the "guarantee" that I indeed have this context in my app.Actual Behavior
Because the type for context is
AppLoadContext | undefined
in the loader and action args, theres' no way that I know of to tell typescript that it will never be undefined. This means that whenever you wish to use context, you must either assert its existence with!
, or you must actually check that it exists to make typescript happy.The text was updated successfully, but these errors were encountered: