News

Microsoft Ships TypeScript 4.6

Microsoft shipped TypeScript 4.6, listing these highlights:

  • Allowing Code in Constructors Before super(): TypeScript 4.6 is much more lenient in ensuring that super() is called before referring to this, no longer generating an error in certain circumstances while still ensuring that super() occurs at the top-level before any references to this.
  • Control Flow Analysis for Destructured Discriminated Unions: "When destructuring individual properties into a const declaration, or when destructuring a parameter into variables that are never assigned to, TypeScript will check for if the destructured type is a discriminated union. If it is, TypeScript can now narrow the types of variables depending on checks of other variables So in our example, a check on kind narrows the type of payload."
  • Improved Recursion Depth Checks: This has to do with comparing object types for compatibility in a structural type system that allows for generics, effectively cleaning up some false negatives that could be discernible by a human looking at the code.
  • Indexed Access Inference Improvements: "TypeScript now can correctly infer to indexed access types which immediately index into a mapped object type."
  • Control Flow Analysis for Dependent Parameters: TypeScript can now narrow parameters that depend on each other n cases where TypeScript infers the type of a function from a signature declared with a rest parameter whose type is a discriminated union of tuples.
  • --target es2022: "TypeScript's --target option now supports es2022. This means features like class fields now have a stable output target where they can be preserved. It also means that new built-in functionality like the at() method on Arrays, Object.hasOwn, or the cause option on new Error can be used either with this new --target setting, or with --lib es2022."
  • Removed Unnecessary Arguments in react-jsx: This drops a void 0 that is unnecessarily generated in certain scenarios, decreasing bundle sizes.
  • JSDoc Name Suggestions: "TypeScript now provides suggestions for when parameter names don't match between your function and its JSDoc comment."
  • More Syntax and Binding Errors in JavaScript: New syntax and binding errors in JavaScript files can now be seen in Visual Studio or VS Code or when code is run through the TypeScript compiler. "These errors can be disabled by adding a // @ts-nocheck at the top of your file, but we're interested in hearing some early feedback about how it works for your JavaScript workflow."
  • TypeScript Trace Analyzer: A new tool provides a more readable view of the information provided by the generateTrace flag that identifies types that are computationally expensive to create and compare against other types.

The Feb. 28 announcement fleshes out all of the above in much greater detail and and also details breaking changes.

TypeScript 4.7 Iteration Plan
TypeScript 4.7 Iteration Plan (source: Microsoft).

Going forward, the TypeScript 4.7 Iteration Plan (pictured above) shows what's on tap for the next edition, due to debut on May 24.

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