Node.js Adds Default Type Stripping |
Written by Kay Ewbank | |||
Thursday, 21 August 2025 | |||
The latest update to Node.js adds type stripping by default, along with other more minor improvements including the propagation of permission model flags on spawn; and a fix to allow correct handling of burst in fs-events with AsyncIterator. Node.js is an open-source, cross-platform asynchronous event driven JavaScript runtime built on Chrome's JavaScript engine. It uses an event-driven, non-blocking I/O mode and executes JavaScript code outside web browsers. Node.js 22 is the current production version; Node.js 23 is available for early feature testing for your own specific environment, and Node.js 24 is an early preview. Even-numbered releases like the current Node. js 22, once LTS, are focused on creating stability and security and are supported for 30 months. The major change to this release is that Node.js will be able to execute TypeScript files without additional configuration. Node.js will replace TypeScript syntax with whitespace, and no type checking is performed. To enable the transformation of non erasable TypeScript syntax, which requires JavaScript code generation, such as enum declarations, parameter properties use the flag --experimental-transform-types. The type stripping feature is designed to be lightweight. By intentionally not supporting syntax that require JavaScript code generation, and by replacing inline types with whitespace, Node.js can run TypeScript code without the need for source maps. The thinking behind the new feature is that while TypeScript has been supported in Node.js for some time through loaders, they relied heavily on configuration and user libraries. This reliance led to inconsistencies between different loaders, making them difficult to use interchangeably. The new automatic type stripping is designed to speed up the cycle between writing code and executing it. TypeScript, as a language, is a superset of JavaScript that supports static typing. However, TypeScript relies on a toolchain to implement its features, the primary tool being tsc, the TypeScript compiler CLI. This supports type checking and transpilation, but there is no formal specification for how the language's type system should behave. tsc does not follow semantic versioning, so even minor updates can introduce changes to type checking that may break existing code. Tsc changes frequently and is large, so the Node.js team was reluctant to include it within Node.js. Instead, they've gone for type stripping - running TypeScript files by simply stripping inline types without performing type checking or any other code transformation. By excluding type checking and traditional transpilation, the more unstable aspects of TypeScript, Node.js reduces the risk of instability and mostly sidesteps the need to track minor TypeScript updates. Moreover, this solution does not require any configuration in order to execute code. Type stripping is compatible with most versions of TypeScript but the Node.js team recommends version 5.8 or newer. Node.js 22.18 is downloadable now. More InformationNode.js Experimental Type Stripper On GitHub Related ArticlesNode.js 22 Adds WebSocket Client Node.js 21 Has Stable WebStreams Node.js 20 Adds Permission Module Node.js 19 Updates JavaScript Engine More InformationRelated ArticlesTo be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.
Comments
or email your comment to: comments@i-programmer.info |
|||
Last Updated ( Thursday, 21 August 2025 ) |