TypeScript programming language: Microsoft updates its JavaScript spinoff to make it more efficient

The new release, TypeScript 3.4, reduces the time it takes to build software and adds a swathe of other new features.

The best programming languages to learn in 2019: Top coding skills that pay you the most These are the languages that are in the highest demand and offer the highest salaries.

Microsoft has released a new version of the increasingly popular TypeScript programming language, promising new features and shorter build times.

TypeScript is a superset of JavaScript and in recent years more and more JavaScript developers appear to be adopting the language, drawn to features that help them build larger and more complex programs.

The language makes it easier to work with classes and modules, thanks to features such as static types, and offers simpler tools for verifying and checking the structure of the code.

However, TypeScript compiles to vanilla JavaScript, adding an intermediate step between writing and running the code.

SEE: 10 ways to prevent developer burnout (free PDF) (TechRepublic)

The new release, TypeScript 3.4, reduces the time it takes to build software, using a new --incremental flag that can be added when compiling.

Using this flag will save information about the current state of the code and its dependencies when it is compiled. Next time code is compiled using the --incremental flag, TypeScript will use that saved information from the previous compilation to only perform necessary type checks and changes, reducing how long the process takes.

This will result in a slightly longer initial compilation time, followed by faster build times for subsequent compilations.

Using the --incremental flag, Microsoft says it was able to reduce build times for its Visual Studio Code editor, which is written in TypeScript, to approximately one fifth of what it was originally.

One of the biggest benefits TypeScript offers over JavaScript is type safety, its ability for the compiler to check the data types passed to and returned from functions and ensure they match what's expected. Doing so allows a whole category of errors that could slip through unnoticed in JavaScript to be detected by TypeScript before the code is deployed.

In previous versions of TypeScript that type safety would be lost when when passing one generic function to another generic function as an argument. TypeScript 3.4 fixes this issue, ensuring type safety remains in place.

Read-only arrays can also now be defined using slightly simpler syntax, by applying a readonly modifier to an array declaration, for example, readonly string[].The readonly modifier can also be applied to tuples, a type of array where the number of elements is known and can be of mixed types, for example, readonly [string, string].

There's also a new way of carrying out type assertion, of specifying the type of a variable to the compiler, using the const keyword, which will also automatically assign readonly properties to object and array literals.

In TypeScript, setting and accessing variables that are defined globally, rather than locally within the current module, can be carried out using the globalThis variable, and TypeScript 3.4 introduces support for type checking on the globalThis variable.

You can read more about the new features and some of the breaking changes the update introduces here.

Microsoft publishes a roadmap for TypeScript, and has outlined plans to introduce negated types and strongly typed iterators and generators in TypeScript 3.5, due out in May.

If you want to get started with TypeScript then check out TechRepublic's guide to the best free resources for learning the language online.

Also see