X
Business

Programming language TypeScript 4.1 beta: These are the new features, says Microsoft

Microsoft has released the 4.1 beta of TypeScript, its programming language for big web apps.
Written by Liam Tung, Contributing Writer

Microsoft's open-source TypeScript team has issued the first beta of TypeScript 4.1, bringing new features, new checking flags, and editor productivity improvements.

TypeScript, a superset of JavaScript, introduces types to describe the shape of an object. It offers JavaScript developers an 'erasable type system' that removes all the types at compile time and returns it to JavaScript for run time. It's become a popular language for building apps for the browser. 

TypeScript 4.1 introduces the template literal string type, which uses the same syntax as JavaScript's template literal strings but used in type positions.    

SEE: Virtual hiring tips for job seekers and recruiters (free PDF) (TechRepublic)

"String literal types in TypeScript allow us to model functions and APIs that expect a set of specific strings," explains Daniel Rosenwasser, a program manager on the TypeScript team. 

"This is pretty nice because string literal types can basically spell-check our string values."

The template also acts as a building block for building other string literal types. 

The beta brings key remapping in mapped types, allowing users to remap keys in mapped types with a new 'as' clause so they can use template literal types to create property names based on old ones. 

TypeScript 4.1 allows for recursive conditional types, too. Now conditional types can reference themselves within their branches, making it easier to write recursive type aliases. 

Rosenwasser notes recursive types are powerful, but should be used sparingly because they can be computationally intensive and can lead to compile-time errors. 

TypeScript 4.1 also supports Facebook's new React 17 JavaScript library's factory functions jsx and jsxs via two new options for the jsx compiler options, react-jsx and react-jsxdev.  

SEE: Microsoft's TypeScript 4.0 programming language arrives: It's a big milestone

Finally, the JSDoc tag @see now has better support in code editors like VS Code for TypeScript and JavaScript.

Users can access the beta on NuGet, or use npm to install it. 

At the release of TypeScript 4.0 in August, Typescript's co-creator Anders Hejlsberg told ZDNet that the main changes in TypeScript over the past two years have focused on improving the experience with editors like Microsoft's VS Code, better error messages and better refactoring. 

More on Microsoft's TypeScript programming language

  • TypeScript creator: How the programming language beat Microsoft's open-source fears  
  • Microsoft: VS Code update gets new features with programming language TypeScript 4.0
  • Microsoft's TypeScript 4.0 programming language arrives: It's a big milestone
  • Microsoft to developers: These are our biggest and best open-source projects
  • Microsoft: This new update makes VS Code friendlier for Java programming language jobs
  • Microsoft VS Code turns 5: How GitHub, open source, Google made it a hit, reveals creator
  • JavaScript creator Eich: My take on 20 years of the world's top programming language
  • Microsoft lead engineer: Programming language TypeScript took off thanks to Google's Angular
  • Deno 1.0: Node.js makers have new JavaScript runtime for TypeScript programming language
  • Programming language TypeScript 3.9 cuts compile times by up to 40%, says Microsoft
  • JavaScript programming language developers: This is Kite's new free AI code-completion tool
  • Programming languages: Kotlin rises fastest but JavaScript lures millions more developers
  • New programming language rankings: Python now as popular as Java, as TypeScript climbs
  • These are the top JavaScript libraries and frameworks
  • Programming languages: Why JavaScript developers are choosing TypeScript
  • Who built Microsoft TypeScript and why  
  • Editorial standards