Microsoft has released TypeScript 5.1, with improvements including less fuss over functions that return void or undefined, and allowing properties to have unrelated types for setting and getting. The 5.2 beta is expected later this month, with a major new feature on the roadmap: a “using” keyword that is reminiscent of C#.
TypeScript 5.1 has around 8 key new features, according to Senior Program Manager Daniel Rossenwasser, though none are huge changes.
Another change is TypeScript 5.1 no longer requires that the get type of a property is a subtype of that used for set. It might seem intuitively that properties should use the same type both when setting or getting the value; but in practice they do not. An example is the CSSStyleRule API which can be set only with a string, but returns a value of the type CSSDeclarationStyle. This will now be possible in TypeScript.
Several changes in the new version improve support for React’s JSX components.
TypeScript 5.2 therefore has on its roadmap ECMAScript Explicit Resource Management & using Declarations including “using” declarations, Symbol.dispose and “possibly a new interface called Disposable (which I think we should consider calling DisposableLike.” The proposal adds that “it would be reasonable for our first stab at this feature to include only support for –target esnext,” referencing the forthcoming as opposed to the current version of ECMAScript. TypeScript therefore could become a little more like C#.
The first beta of TypeScript 5.2 is scheduled for June 27th.