Microsoft is nearing the discharge of TypeScript 5.1, and earlier than the ultimate launch has launched the launch candidate. The corporate says that no new options or adjustments will likely be made between this and the ultimate launch.
In TypeScript 5.1 features that return “undefined” will not be required to have a return assertion. Beforehand the one features that would don’t have any return statements had been people who returned “void” or “any”. One other replace is that when a perform doesn’t have a return expression and is handed to one thing that expects a perform to return “undefined,” TypeScript will now infer that the perform’s return sort is “undefined.”
This launch additionally builds upon one thing that was launched in TypeScript 4.3, which was that “get” and “set” accessor pairs may specify two differing kinds. Now, it’s attainable for these varieties to be utterly unrelated, whereas earlier than there was a requirement that the “get” sort be a subset of the “set” sort.
TypeScript 5.1 decouples type-checking amongst JSX parts and JSX tag varieties. The brand new sort, “JSX.ElementType.ElementType” will be referred to to seek out what the legitimate tags in JSX factor are.
This model of TypeScript additionally provides assist for namespaced attribute names when utilizing JSX, in addition to the flexibility to edit JSX tags in a number of areas mechanically.
One other new characteristic is that the language will have the ability to present snippet completions on @param tags, decreasing the time spent typing and transferring round within the code.
Different enhancements embody avoiding performing sort instantiation for objects that don’t often reference outer sort parameters, detrimental case checks for union literals, and diminished calls into the scanner when parsing JSDoc feedback.
Extra details about this launch will be present in Microsoft’s weblog submit about it.