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
{{ message }}
This repository was archived by the owner on Dec 6, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Dec 6, 2023. It is now read-only.
Reactotron.log + typescript - cannot invoke an object which is possibly 'undefined' #239
Bonus: Here's a way to add type safety with linting
Reacted by Patrick Narciso, Krestian Weken, Simon Garnier, Alex Hafner, Leonardo Oliveira, Felix Gliesche, iji, Tainan Fidelis, David Bishop, Sergei and 6 more
Reacted by Patrick Narciso, Simon Garnier, Leonardo Oliveira, Tainan Fidelis, Wesley Feitosa and Alejandro Tunaroza
Activity
DavidNeiOs commentedon Apr 19, 2020
I found a temporary solution in this thread #168 (comment)
@doronnac
leotm commentedon Jul 13, 2020
Since in our
ReactotronCoreinterfacelog?: (...args: any[]) => voidis an optional function, we just need to assert it's not null when calling it:Same goes for any other optional functions you're calling like
warn,error, etc.Use newer optional chaining (TS 3.7+) if preferred.
Bonus: Here's a way to add type safety with linting
patrick-narciso commentedon Jul 16, 2020
The @leotm solution is correct, it even works for other cases such as when using
Reactotron.createEnhancer!()AndreCosta101 commentedon Feb 25, 2021
Hey Patrick... you mean in the store configuration? How did you do it ? thanks
dbishopdev commentedon May 24, 2021
@AndreCosta101 Something like this:
GermaVinsmoke commentedon Dec 16, 2021
But this solution gives this warning - "Forbidden non-null assertion."
Is it okay to have this warning?
leotm commentedon Feb 10, 2022
@GermaVinsmoke
Since TypeScript 3.7