Starting with v23.6.0, Node.js supports TypeScript without any flags. This blog post explains how it works and what to look out for.
Current TypeScript support in Node.js is done via type stripping: All Node.js does is remove all syntax related to types. It never transpiles anything. Let’s explore how that changes how we write TypeScript.
TypeScript supports some upcoming JavaScript features and transpiles them so that they run on current JavaScript engines. One such feature is decorators. Those will be supported by Node.js in TypeScript when they are supported in JavaScript.
Why is that? Traditionally, the TypeScript compiler never touched module specifiers such as './my-module.js'. Therefore, we had to use module specifiers that made sense in the transpiled output.
Given that Node.js uses the filename extension to determine the type of a module, this approach had to change. We now have to write: