TechTalk - 2o22 - JS/ TS/ React mistakes and how to avoid them
There are a lot of things that can go wrong with the way we use JS/TS. Here, we will talk about some applicable best practices along the way and some widespread mistakes
| reactweek.dev Marko Arsić Founder and CEO @ HypeTech Founder of HypeTech Education Lecturer @ ReactWeek.dev Independent Tech Consultant Helping companies set up teams and standardize the development process github.com/marsicdev
typing can be too lax, and that will make our codebase less type-safe. It will give the wrong impression, as some think that by adding TypeScript all typing issues are automatically fixed.
need to have some different interfaces variants of the same type. Those can vary in one or two parameters. A common mistake is to manually redefine those variations. That will lead to: • unnecessary boilerplate. • multiple changes are needed if one property changes in one place, that change needs to be propagated to many files.
the most powerful tools of this programming language. It does all the work for us. We only have to make sure that all the pieces add together with as little intervention as possible. A crucial operator to achieving this is the typeof.
great as it can improve the readability of our contracts. However, it is different from other typed overloading languages. There are scenarios where it might make our code more complex and verbose.
It is like using the any keyword but for functions only. Enabling strict mode won’t prevent us from using it. Function type: • accepts any number and type of parameters. • the return type is always any