In a recent update to the code base of the JavaScript platform node.js, a new change has been accepted, allowing for the execution of files written in the programming language TypeScript. This update introduces support for TypeScript through the use of the “–experimental-strip-types” option, which cleans the type definitions specific to TypeScript before compiling the source code into JavaScript. Developers can now test this new feature with the latest nightly builds of node.js 23.
Additionally, the SWC compiler (Speedy Web Compiler), created for efficient code compilation, has been integrated into node.js without adding extra dependencies. Utilizing WebAssembly intermediate code, specifically the swc/wasm-typescript presentation, the compiler is now capable of executing TypeScript code directly. This change was made in response to user demands for running TypeScript code in node.js without the need for external loaders or additional dependencies, a feature already present in competing platforms like Deno and Bun.
The main distinction between JavaScript and TypeScript lies in their approach to type definition. TypeScript’s static typing helps prevent errors during development, enables optimization techniques, facilitates debugging, and enhances code readability. However, in the current implementation in Node.js, the benefits of TypeScript’s type checking are lost as the code is transpiled to JavaScript without verifying type consistency.