4 ms·
I would avoid doing state management in Typescript. It's still too early in my opinion. Use as many hooks and context as possible and keep your redux store as
by nisten 6y ago
I would avoid doing state management in Typescript. It's still too early in my opinion.
Use as many hooks and context as possible and keep your redux store as simple as you possibly can because if you end up with a deprecated state management library (redux-thunk, sagas, easy-peasy) replacing that is like pulling gum out of hair.
If you add up the time spent working around typescript errors when dealing with state, it's possible for it to be more time than you need to rewrite the entire app.
For backend work then yes, I'd say doing a singleton or an abstract class in typescript makes more sense in hardening your API code and even making it more readable too.
- acemarke 6y agoI'm a Redux maintainer, and I'm _strongly_ in favor of using TypeScript for any meaningful app development [0] [1]. Also, I don't know why you're referring to thunks and sagas as "deprecated". Thunks are the recommended default approach for async logic in Redux [2], and we include them out of the box in our Redux Toolkit package [3]. While most apps don't need sagas, they're a great power tool to have in your toolbox. Neither of those is in any way "deprecated". [0] https://blog.isquaredsoftware.com/2019/11/blogged-answers-learning-and-using-typescript/ https://blog.isquaredsoftware.com/2019/11/blogged-answers-le... [1] https://redux.js.org/style-guide/style-guide#use-static-typing https://redux.js.org/style-guide/style-guide#use-static-typi... [2] https://redux.js.org/style-guide/style-guide#use-thunks-for-async-logic https://redux.js.org/style-guide/style-guide#use-thunks-for-... [3] https://blog.isquaredsoftware.com/2020/02/blogged-answers-why-redux-toolkit-uses-thunks-for-async-logic/ https://blog.isquaredsoftware.com/2020/02/blogged-answers-wh...
- nisten 6y agoSorry I meant as in an older version of a library that an app has been built on and hasn't been updated or maintained for a few months. I should have put that better, the libraries themselves are not deprecated, their dependencies can be. While this negligence problem would be on the fault of the dev team and management for not doing regular package updates it is an all too common issue in many companies. What I am saying is that bad typescript is harder to fix than bad javascript because type errors compound the problems of convoluted code.