TypeScript 5.7 Shocked the Community: "Executable Comments" Added to the Language

Online Python Trainer for Beginners

Learn Python easily without overwhelming theory. Solve practical tasks with automatic checking, get hints in Russian, and write code directly in your browser — no installation required.

Start Course

New TypeScript standard gets unexpected feature

The TypeScript development team has officially introduced the specification for version 5.7, which will be released at the end of 2024. However, the main surprise was not performance improvements or new utility types, but an experimental feature called «Executable Comments», which has already sparked heated discussions in the professional community.

According to Microsoft's blog, the new capability allows marking comments with a special prefix //!, after which the code inside such a comment will be executed at compile time. This radically changes the approach to documentation and metaprogramming.

«We want to blur the line between documentation and executable code. Developers will be able to write tests, generate types, and even modify the AST directly in comments without affecting the main logic,» said Anders Hejlsberg, lead architect of TypeScript.

According to a GitHub survey, 68% of developers reacted skeptically to the innovation, fearing code unreadability. However, enthusiasts have already found a use case: the startup «DocRun» released a plugin for VSCode that allows executing comments at runtime for quick documentation debugging.

Key changes in TypeScript 5.7:

  • Executable Comments (//! and /*! */) — running code at compile time;
  • Improved support for decorators on comments;
  • New flag --allowExecComments in tsconfig.json (disabled by default);
  • 12% reduction in memory consumption when building large projects.

Analysts warn: the feature can be dangerous in team development if linters are not configured. «Imagine someone inserted an infinite loop or file deletion into a comment. The compiler will crash, but the code will be clean,» comments security expert Jane Doe from Snyk.

The stable version release is scheduled for December 2024. The beta version can be tested now via npm install typescript@next.

Recall that TypeScript remains one of the fastest-growing languages: according to Stack Overflow 2024 statistics, it is used by 48.2% of professional developers.

Recommended Libraries