In this article, I discuss the conclusions we’ve drawn as a company while writing microservices with TypeScript and explain why using it for your next Node application is an excellent idea.
As the title of this article implies, we decided that TypeScript is the ultimate choice for our needs.
Motivation for TypeScript
The three main factors that influenced our decision were smooth refactoring, easy-to-manage codebase in teams, and a vast community.
We have noticed that other languages are not as popular as TypeScript is; there is no broad community and also the chance of finding good developers is not very high.
TypeScript makes refactoring incredibly easier to handle and to work in teams. It also makes it easier for other developers to move in and out of the codebase without unintentionally breaking things, especially when it comes to large-scale projects with many developers involved.
What is TypeScript?
How TypeScript Helped Us To Achieve Our Goals
TypeScript allows for the use of many of the latest ECMAScript features. It translates them to older ECMAScript targets of your choosing; this means that you can safely use new features, like modules, lambda functions, classes, the spread operator, and destructuring.
Advanced Type System
Enhanced IDE Support
The majority of IDEs (Visual Studio Code, WebStorm, Atom, and Sublime) fully support TypeScript assistance tools like syntax highlighting, semantic highlighting, IntelliSense, JSDoc, methods signature help, auto imports, and code formatting. Through code completion, you can get inline help on whatever functions a library might offer — no more need to remember them or look them up in online references.
One of TypeScript’s core principles is interfaces, sometimes called “duck typing” or “structural subtyping”. Interfaces fill the role of naming these types and are a powerful way of defining formal, precise, and valid contracts inside the project as well as outside of it.
When it comes to extensive codebase management — the larger it grows, the more necessary it is to have substantial contracts between different parts of the code.
Ts.ED, LoopBack, and NestJS are just a few of the TypeScript frameworks for Node. They make use of all the language’s most robust features (like classes, interfaces, and decorators); thus, they enable high scalability and flexibility and get the best out of the language. They also combine Object-Oriented programming with a variety of design patterns.
Bonus: Our Choice — NestJS Framework
Nest (NestJS) is a progressive Node framework used to build scalable server-side applications. Nest is heavily inspired by Angular architecture with the same concepts as Pipes, Interceptors, Providers, and Controllers. It created with and fully supports TypeScript and combines elements of OOP, Functional Programming, and Reactive Programming.
As a philosophy, Nest provides no logic of its own; it’s an architecture friendly thin wrapper over existing frameworks (like Express and Mongoose, for example). It provides a level of abstraction above those frameworks but also exposes their API directly, which allows the freedom to use the myriad of third-party modules that are available for the underlying them.
The ecosystem is excellent, too — there is growing community support, and the Nest team even suggests a suitable course with 60+ chapters walkthrough of all the fundamentals of a Nest application.