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

  • Hands On: New VS Code Insiders Build Creates Web Page from Image in Seconds

    New Vision support with GitHub Copilot in the latest Visual Studio Code Insiders build takes a user-supplied mockup image and creates a web page from it in seconds, handling all the HTML and CSS.

  • Naive Bayes Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the naive Bayes regression technique, where the goal is to predict a single numeric value. Compared to other machine learning regression techniques, naive Bayes regression is usually less accurate, but is simple, easy to implement and customize, works on both large and small datasets, is highly interpretable, and doesn't require tuning any hyperparameters.

  • VS Code Copilot Previews New GPT-4o AI Code Completion Model

    The 4o upgrade includes additional training on more than 275,000 high-quality public repositories in over 30 popular programming languages, said Microsoft-owned GitHub, which created the original "AI pair programmer" years ago.

  • Microsoft's Rust Embrace Continues with Azure SDK Beta

    "Rust's strong type system and ownership model help prevent common programming errors such as null pointer dereferencing and buffer overflows, leading to more secure and stable code."

  • Xcode IDE from Microsoft Archrival Apple Gets Copilot AI

    Just after expanding the reach of its Copilot AI coding assistant to the open-source Eclipse IDE, Microsoft showcased how it's going even further, providing details about a preview version for the Xcode IDE from archrival Apple.

Subscribe on YouTube

Upcoming Training Events