Microsoft just released the latest version of a programming language that builds on top of JavaScript, TypeScript 5.4, which is a high-level programming language.
The program's latest version is very straightforward to install and users can get it from NuGet or if they prefer npm, they can use the command "npm install -D typescript." While the tech giant was explaining TypeScript, it also mentioned a detail if users use Visual Studio or VS Code to write JavaScript code,
Microsoft's New TypeScript 5.4
It turns out that they have really been writing TypeScript code all this time without even knowing it. This enables TypeScript's editor tooling to do auto-completion, code navigation, as well refactorings, which is a systematic process of improving code without creating new functionality that is able to transform a mess into clean code and simple design.
The newly released TypeScript 5.4 comes with several new upgrades for software developers to fiddle with as well as leverage in their projects. Microsoft also issued various announcements regarding the new features in the latest version and descriptions of each feature plus code examples, as per Neowin.
One example of the new features is the preserved narrowing in closures following last assignments. TypeScript is capable of figuring out a more specific type for a variable based on checks that users could perform, which is a process called narrowing.
Previously, one common issue was that these narrowed types were not always preserved within function closures. The latest version makes narrowing a little smarter by making previously unworkable functions workable. However, one thing to note is that narrowing analysis does not occur if the variable is assigned anywhere in a nested function.
Another new feature is the NoInfer Utility Type, which addresses problems with determining just what the "best" type is to infer. That particular issue has led to previous versions of TypeScript rejecting valid calls, accepting questionable calls, or simply reporting worse error messages when it catches a bug.
A Variety of New Features
TypeScript 5.4 fixes this problem by surrounding a type in NoInfer<...> that gives a signal to the program to dig in and match against the inner types to find other candidates for type inference, according to Microsoft.
Various other improvements that Microsoft included in the latest version of the program are that it now more accurately checks whether or not strings are assignable to the placeholder slots of a template string type.
Additionally, new assignability restrictions were added for enums. In older versions of TypeScript, when two enums had the same names and the same enum member names, they were considered compatible.
Despite this, TypeScript would silently allow them to have differing values. The newest version of the program requires the values to be identical (when known). Microsoft also implemented new restrictions for when one of the enum members does not have a statically known value.
The tech giant has also added a Quick Fix that allows users to add a new parameter to functions that are called with too many arguments. TypeScript 5.4 also reduces intersections with type variables and primitives more aggressively. This depends on how the type variable's constraint overlaps with these primitives, said InfoWorld.