The NodeSource Blog

#NeedToNode Recap: Best Practices using TypeScript with Node.js

Yesterday, we had our monthly webinar #NeedToNode with Bryan Hughes of Microsoft, on the topic of best practices when using TypeScript with Node.js. Here's a quick recap of what he covered.

Top 5 Takeaways

  • TypeScript is a typed superset of JavaScript, with static typing built-in
  • TypeScript implements much of the ES6 spec, and compiles to plain JS
  • TypeScript can be mixed with regular JavaScript
  • TypeScript extensions exist for many text editors (VS Code, Atom, Sublime, Vim, and others)
  • Install with npm install -g typescript typings



TypeScript runs regular JavaScript, but the TypeScript interpreter has built in Type checking. TypeScript makes this possible through Primitives and Interfaces. This allows for safer shipping, ensuring that you don’t write or refactor with missing arguments or have typos in variable and function calls.

TypeScript uses the ES6 Module Spec, but also allows for use of CommonJS modules - including when you’re using TypeScript in Node.js. If you want to run your TypeScript-based modules or applications in the stable version of Node, you can just compile to ES6. If you want to run in the LTS version of Node, you can compile to ES6 and use Babel to transpile to ES5 for the best result.

TypeScript allows for quicker understanding of source code, as its statically-typed structure is, to a reader, more self-documenting than JavaScript.

TypeScript is ideal for use in larger team, for larger projects, and for people coming from Java, C#, C++, and other statically Typed language.

TypeScript doesn’t extend the native Types in JavaScript - TypeScript doesn’t add a bunch of extra types that are present in many of the statically typed languages.

TypeScript plays well with JavaScript! You can run any regular JavaScript within the TypeScript compiler and it will run exactly how it should. This makes it simple to convert a project to TypeScript - you can convert file by file, testing your changes incrementally.


Demo code for this #NeedToNode:

Official TypeScript Resources:

Visual Studio Code, written by Microsoft in TypeScript:

Writing with TypeScript:


N|Solid is a superior Node.js platform enhanced to help you build, manage, secure, and analyze mission-critical Node.js applications.

Get Started

Build, manage, secure, and analyze mission-critical Node.js applications with a superior Node.js runtime.

Get Started

Monitor local module usage for security vulnerabilities, license issues, and more.

Get Started