First things first, lets define TypeScript:
TypeScript is an open source project, so you can have a look at the source code if you are interested: https://github.com/microsoft/TypeScript
Typescript is a really great technology, but you shouldn’t choose a technology because it is cool or trendy. You should choose a technology because of the advantages that it can provide for your team and your project. For this reason, in this section I will try not to be too technical and I will focus on which are the benefits why I chose to use Typescript in my current React project, so the same advantages might apply for you too.
Those who are fullstack developers, like me, know very well the advantages of both worlds: frontend and backend. While frontend has been evolving a lot in the latest years, backend development was already robust and based on best practices well known and accepted by the community.
With the introduction of typescript, we can design and implement our frontend software with object oriented programming in a similar way as we have been done for many years in backend. The first consequence of this fact is that we can use design patterns, which will help us to build high maintainable software. As an example of this, here you have a repository where you can find all the most relevant design patterns implemented in typescript: https://github.com/totaldesigner/typescript-design-patterns.
If you are technical, I’m pretty sure you will find this point redundant. However, this is a point I would like to highlight too, since business people sometimes tend to think technology update is not really a necessity for the business. But building highly maintainable and scalable applications will lead to saving a large amount of time, or in other words, budget.
In addition, more robust code will involve less bugfixing, so again it will mean saving time and also improving the reputation with your clients. Last, this will keep your developers happier, as it is really frustrating wasting your time fixing bugs that could have been avoided and maintaining an application which is really tedious to maintain or refactor.
Type definitions help you when you are consuming an Api, it doesn’t matter if it is an Api library or a web Api. In addition, having types will help you to make your code functional programming oriented, so consumers of your api will easily know what they should provide to call a method and what result they should expect.
Having types definition is crucial when you want to share your code with others. In fact, (spoiler alert), I will write an article about this to demonstrate how easy-to-use can be our Api by using typescript.
In this article we have seen the benefits of using typescirpt in your project. I talked more about React in this article because I recently added TypeScript in a React project, but I strongly recommend it also for other technologies like Vue.js, Node.js, etc, since the benefits are identical.
Finally, I would like to recommend two courses to learn typescript:
- (Beginner) Getting Started with TypeScript; https://app.pluralsight.com/library/courses/typescript-getting-started/table-of-contents
- (Beginner) TypeScript Fundamentals: https://app.pluralsight.com/library/courses/typescript/table-of-contents
- (Advanced) Advanced TypeScript https://app.pluralsight.com/library/courses/typescript-advanced/table-of-contents
If you don’t have PluralSight subscription don’t worry, remember that the best source of information is always the official documentation: https://www.typescriptlang.org/docs/home.html