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 might be made between this and the ultimate launch.
In TypeScript 5.1 features that return “undefined” will now not be required to have a return assertion. Beforehand the one features that might haven’t any return statements have been people who returned “void” or “any”. One other replace is that when a operate doesn’t have a return expression and is handed to one thing that expects a operate to return “undefined,” TypeScript will now infer that the operate’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 types. 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 components and JSX tag varieties. The brand new sort, “JSX.ElementType.ElementType” could be referred to to seek out what the legitimate tags in JSX ingredient are.
This model of TypeScript additionally provides help for namespaced attribute names when utilizing JSX, in addition to the power to edit JSX tags in a number of places robotically.
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 embrace avoiding performing sort instantiation for objects that don’t normally reference outer sort parameters, adverse case checks for union literals, and diminished calls into the scanner when parsing JSDoc feedback.
Extra details about this launch could be present in Microsoft’s weblog submit about it.