White Label Coders  /  Blog  /  Why TypeScript?

Category: Software Engineering

Why TypeScript?

Why TypeScript
05.08.2019
2 min read

Node JS is great for api development, we have used it for ages. We also have great web frameworks like express and koa, nice orms like sequelize, bookshelf, objection and mongoos, and we have a lot of other libraries and plugins that we love to use. Although, sometimes, it feels like it’s not enough. We want something better, something cleaner, something more stylish, state of the art technology. That’s why we TypeScript.

Can we have it? Yes, we can!

Switch to TypeScript – the next generation of JavaScript. It’s a superset of Javascript, so you don’t even have to rewrite your old JS code. It compiles to JavaScript, so it runs on all the devices you already support.

What does TypeScript have to offer?

Typings!

From this point forward, we now have type definitions, and type definitions check in javascript. This is not a change in how the code runs, but it makes a huge difference in how the code is written, how clean it is, how understandable it is and how bug-free it is. It simply forces us to write clean code, all with good practices, and forces us to define everything while still leaving the opportunity to exercise a little freedom when necessary. Finally, it lets us write full objective code in node.

Another tool is reflection-mapping, another reason why you should switch to TypeScript. It’s like php annotations, but better…not in comments. You can annotate anything, make your own annotations, use them however you want, or just use the ones others have already implemented.

Those are just the tools we have, but that’s nothing if we have to implement everything on our own. So here comes our new sets of libraries, written specifically for TypeScript:

  1. typestack/routing-controller s- so now you can create your controller classes, and annotate routing in annotations! Behind the new mask it still uses good old expressjs or koa (your choice)
  2. typeORM – typeScript ORM maps your database into classes, and supports all the databases you want to use; sql or no-sql, it’s your choice!
  3. typestack/class-transformer – so you can transform your class models into, or out of, plain JSON.
  4. typestack/class-validator – after you transform your request into classes, you have to validate it. Why don’t you setup validators as an annotation next to the class properties?
  5. typestack/typedi – and now let’s connect it all together with this lovely dependency injection library, so you don’t have to worry about where your classes are anymore.

If you bring all these pieces together, I promise you that your new project will be a piece of art!

See slides on this topic below:

How to
About
What is TypeScript
What is TypeORM?
What is TypeStack?
TypeORM - Model
TypeORM - Migration
Router-Controller
Router-Controller
Router-Controller
Class Transformer
Class Transformer
Class Validation
Type DI
Bialas-WLC

JavaScript Developer / Team Leader

Professional in full-stack web development. His competencies, besides solid technical background, include strengths such as business analysis, solution design or writing technical documentation. His interpersonal skills led him to be involved in project management, team leadership and recruitment.

Related Articles
SEE OUR BLOG
Check related articles
How to implement an IT project
How to implement an IT Project nicely and easily?

Nowadays many commercial companies create an IT product that becomes the basis of business. An example is the Yearful startup (London, UK), who created a calendar for planning the whole year and setting milestones in it.

Read more
Testing before Deployment
Testing of a website, our best practicies for testing before deployment

Testing a website or an app before it’s launch is like a rehearsal before the show. This is like the last wardrobe fitting before the gala.

Read more
How to migrate system?
How Do You Migrate Systems?

Well-prepared system migrations can go smoothly and exactly as planned, or just the opposite, they can go sideways. They can take minutes, or they may drag on for hours or even days. In the worst case, everybody involved is unhappy and the system is frozen.

Read more
how to prepare design for web development
12 Tips on how to prepare your design for web development

Admit it or not, we simply judge things based on their look. And that goes for websites design too. If you make them look and function well, as designers and developers try to do, people are going to trust the content more. That’s how things are.

Read more
practical applications of design patterns
Practical Application of Design Patterns

The use of SOLID, KISS and other guidelines not only help maintain order in the code itself, but also in communication between programmers.

Read more
delighted programmer with glasses using computer
Let’s talk about your WordPress project!

Do you have an exciting strategic project coming up that you would like to talk about?

wp
woo
php
node
nest
js
angular-2