News

What's New in TypeScript 5.3

Microsoft advanced TypeScript to version 5.3 with a bevy of changes affecting everything from import attributes to interactive inlay hints for types, along with multiple optimizations.

Coming three months on the heels of TypeScript 5.2, Microsoft also outlined breaking changes and correctness improvements to its type-optional take on JavaScript.

Here's a summary of the release highlights as presented by Microsoft:
  • Import Attributes: The release supports the latest updates to the import attributes proposal, which allows specifying additional information about the expected format of a module to the runtime. The syntax uses the with keyword instead of the deprecated assert keyword.
  • Interactive Inlay Hints for Types: The update adds a new editor feature that displays interactive inlay hints for the types of variables, parameters and return values in TypeScript and JavaScript files. These hints can help users understand the types of their code and provide quick actions to annotate or refactor their code.
    Clickable Inlay Parameter Hints in Animated Action
    [Click on image for larger, animated GIF view.] Clickable Inlay Parameter Hints in Animated Action (source: Microsoft).
  • Stable Support resolution-mode in Import Types: TypeScript 5.3 allows controlling whether a specifier should be resolved via import or require semantics using a resolution-mode attribute in /// reference types="..." /> declarations. This feature was introduced in TypeScript 4.7 as experimental and is now stable.
  • switch (true) Narrowing: The latest update improves the type narrowing behavior of switch (true) statements, which are often used as a replacement for if-else if chains. The compiler can now narrow the types of variables based on the conditions in each case clause.
  • instanceof Narrowing Through Symbol.hasInstance Checks: TypeScript 5.3 also improves the type narrowing behavior of instanceof checks by taking into account the Symbol.hasInstance method, which allows customizing the behavior of the instanceof operator for user-defined classes. The compiler can now narrow the types of variables based on the return value of the Symbol.hasInstance method.
  • Checks for super Property Accesses on Instance Fields: TypeScript 5.3 introduces stricter checks for property accesses on super in classes with instance fields. The compiler will now report an error when accessing a property on super that is not a method or a getter, as this can lead to unexpected behavior at runtime.
  • Optimizations by Skipping JSDoc Parsing: v5.3 improves the performance of the compiler and the language service by skipping the parsing of JSDoc comments in .d.ts files unless explicitly requested by the --checkJs or --allowJs flags. This can reduce the memory usage and startup time of the compiler.
  • Optimizations by Comparing Non-Normalized Intersections: TypeScript 5.3 also improves the performance of the compiler by avoiding unnecessary normalization of intersection types when comparing them for equality or assignability. This can reduce the number of expensive type operations and speed up type-checking.
  • Consolidation Between tsserverlibrary.js and typescript.js: TypeScript 5.3 consolidates the functionality of the tsserverlibrary.js and typescript.js files, which are used to power the TypeScript language service and the TypeScript compiler, respectively. This can simplify the development and maintenance of TypeScript tools and plugins.

As far as those breaking changes and correctness improvements, they include changes in lib.d.ts and enhanced checks for super accesses on instance properties.

v5.4 Milestones
[Click on image for larger view.] v5.4 Milestones (source: GitHub).

Microsoft expects to ship TypeScript 5.4 near the end of February 2024. The GitHub repo for v5.4 milestones shows 27 percent completion, with 26 open items and 10 closed items. As can be seen in the partial graphic above, the milestones include bugs, breaking changes and more.

About the Author

David Ramel is an editor and writer at Converge 360.

comments powered by Disqus

Featured

  • Compare New GitHub Copilot Free Plan for Visual Studio/VS Code to Paid Plans

    The free plan restricts the number of completions, chat requests and access to AI models, being suitable for occasional users and small projects.

  • Diving Deep into .NET MAUI

    Ever since someone figured out that fiddling bits results in source code, developers have sought one codebase for all types of apps on all platforms, with Microsoft's latest attempt to further that effort being .NET MAUI.

  • Copilot AI Boosts Abound in New VS Code v1.96

    Microsoft improved on its new "Copilot Edit" functionality in the latest release of Visual Studio Code, v1.96, its open-source based code editor that has become the most popular in the world according to many surveys.

  • AdaBoost Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the AdaBoost.R2 algorithm for regression problems (where the goal is to predict a single numeric value). The implementation follows the original source research paper closely, so you can use it as a guide for customization for specific scenarios.

  • Versioning and Documenting ASP.NET Core Services

    Building an API with ASP.NET Core is only half the job. If your API is going to live more than one release cycle, you're going to need to version it. If you have other people building clients for it, you're going to need to document it.

Subscribe on YouTube