News

What's New in TypeScript 5.5, Now Generally Available

Microsoft shipped the latest iteration of its type-infused superset of JavaScript, TypeScript 5.5, introducing inferred type predicates, control flow narrowing, JSDoc @import and other enhancements.

"Although JavaScript is used to create cross-platform apps, it wasn't conceived for large apps involving thousands, or even millions, of lines of code," Microsoft explains. "JavaScript lacks some of the features of more mature languages that power today's sophisticated applications. Integrated development editors (IDEs) can find it challenging to manage JavaScript and maintain these large code bases.

"TypeScript addresses the limitations of JavaScript, doing so without compromising the key value proposition of JavaScript: the ability to run your code anywhere and on every platform, browser, or host."

Early this year, the firm RedMonk placed TypeScript at No. 6 (in a tie with CSS) in its language rankings.

TypeScript Tied for 6th
[Click on image for larger view.] TypeScript Tied for 6th (source: RedMonk).

Here's a summary of new features in v5.5, as described in a June 20 announcement.

  • Inferred Type Predicates: Automatically infers type predicates for functions that return boolean values, allowing TypeScript to better understand and narrow types based on the function's return type.
  • Control Flow Narrowing for Indexed Accesses: Enhances type narrowing for constant indexed property accesses, improving type checking precision and reducing potential errors.
  • JSDoc @import Tag: Introduces a new JSDoc tag to simplify importing types in JavaScript projects, making it easier to integrate TypeScript's type checking capabilities.
  • Regular Expression Syntax Checking: Adds syntax validation for regular expressions, ensuring they are correctly formed and reducing runtime errors.
  • New ECMAScript Set Methods: Supports new ECMAScript methods such as union, intersection, and difference for Set objects, aligning with the latest ECMAScript standards and enhancing functionality.
  • Isolated Declarations: Introduces the --isolatedDeclarations option, allowing developers to generate declaration files without requiring a full type check, speeding up the build process.
  • The ${configDir} Template Variable for Configuration Files: Adds a template variable for specifying paths in configuration files, providing more flexibility in project setups.
  • Consulting package.json Dependencies for Declaration File Generation: Uses dependencies listed in package.json to assist in generating declaration files, ensuring accurate type definitions.
  • Editor and Watch-Mode Reliability Improvements: Enhances reliability and performance in editor integrations and watch mode, providing a smoother development experience.
  • Performance and Size Optimizations: Includes various optimizations to improve compiler performance and reduce the size of generated output, making builds faster and more efficient.
  • Easier API Consumption from ECMAScript Modules: Simplifies the process of consuming APIs from ECMAScript modules, improving interoperability and developer experience.
  • The transpileDeclaration API: Introduces a new API for transforming TypeScript declarations, offering more control and customization for advanced use cases.

The next version, TypeScript 5.6, is expected to ship in early September, with iteration plans listed on the GitHub-hosted issue tracker.

About the Author

David Ramel is an editor and writer for Converge360.

comments powered by Disqus

Featured

Subscribe on YouTube