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

TypeScript 4.0 is the culmination of Microsoft's work of the past two years based on feedback from developers.
Written by Liam Tung, Contributing Writer

Microsoft has released TypeScript 4.0, the latest iteration on its hugely popular programming language for building large JavaScript web applications. 

The 4.0 release is technically a major milestone with a host of new features. However, according to TypeScript's creator, Anders Hejlsberg, a technical fellow at Microsoft, it's just the culmination of work his team has been focusing on since TypeScript 3.0 was released two years ago. 

"It's funny. We were joking that 4.0, well, it just so happens to be what comes after 3.9 and literally if you look at our release history… yes we hit round numbers every 10 releases and we hit 3.0 about two years ago," Hejlsberg told ZDNet. 

"But of course in a sense a good way to look at it is as what's happened in those two years since 3.0." 

SEE: Hiring Kit: Python developer (TechRepublic Premium)

Hejlsberg says there are several main themes driving changes in TypeScript, including the experience with editors like Microsoft's Visual Studio Code editor, better error messages and better refactoring. 

"We've worked a lot on performance, scalability, because people are starting to build really large projects in TypeScript and they still want this super-snappy performance on a project with hundreds of thousands of lines of code in it – and that's not an easy problem to solve."

Microsoft released TypeScript in 2012 and the language – a superset of JavaScript – has, as of July, become a top-10 programming language among developers, according to analyst firm RedMonk. 

RedMonk analyst Stephen O'Grady reckons TypeScript's popularity is sustainable and was "no fluke" given the ubiquity of JavaScript and its optional type safety.   

Microsoft boasts that on npm, the popular JavaScript package manager, TypeScript for the first time cracked 50 million monthly downloads this July.   

One of the performance improvements in TypeScript 4.0 addresses slow startup times on bigger projects. 

Daniel Rosenwasser of the TypeScript team explains that the culprit is usually a process called 'project loading', where multiple dependencies are resolving. So the team has been working on a partial editing mode at startup.  

"The core idea is that editors can run a lightweight partial server that only looks at the current files that the editor has open," he notes. "This has always been an option for editors, but TypeScript 4.0 expands the functionality on that server to some semantic operations – as opposed to just syntactic operations, which was previously the case."

While this limits the information available, it's enough for basic code completion and other quick information when an editor is first opened up.  

According to Rosenwasser, he's seen machines take up to a minute before TypeScript is responsive on a file in VS Code but the new mode in TypeScript 4.0 cuts the time to responsiveness down to a few seconds.  

SEE: Programming languages: Developers reveal what they love and loathe, and what pays best

Among the many other improvements in TypeScript 4.0 are smarter auto-imports to help when auto-imports doesn't work as expected and harms developer productivity. One stumbling block was that auto-imports sometimes would work on packages that were written in TypeScript.

"TypeScript 4.0 now does a little extra work in editor scenarios to include a limited number of packages you've listed in your package.json's dependencies field," notes Rosenwasser. 

"The information from these packages is only used to improve auto-imports, and doesn't change anything else like type-checking. This helps alleviate the cost of walking through your node_modules directories while still fixing one of the most common problems we've heard for new projects."

More on programming languages

  • Programming language Kotlin 1.4 is out: This is how it's improved quality and performance  
  • Developer jobs: Demand for programming language Python falls amid pandemic  
  • Programming language Julia version 1.5 is out: Lots of new features, better performance  
  • Programming language popularity: Python overtakes Java – as Rust reaches top 20  
  • Programming languages: Julia touts its speed edge over Python and R  
  • Programming language Julia: Version 1.4 is even faster and brings these new features  
  • Top programming languages: Python still rules but old Cobol gets a pandemic bump  
  • Kotlin programming language: How Google is using it to squash the code bugs that cause most crashes  
  • Microsoft: We're pulling the plug on Windows builds of programming language PHP  
  • Kotlin programming language: Google offers free course for Android development  
  • Programming languages: Now Rust project looks for a way into the Linux kernel  
  • Programming language rankings: R makes a comeback but there's debate about its rise  
  • Programming languages: Julia touts its speed edge over Python and R  
  • Microsoft lead engineer: Programming language TypeScript took off thanks to Google's Angular  
  • JavaScript creator Eich: My take on 20 years of the world's top programming language  
  • Programming languages: Java still rules over Python and JavaScript as primary language  
  • Julia programming language: Users reveal what they love and hate the most about it    
  • Mozilla is funding a way to support Julia in Firefox
  • MIT: We're building on Julia programming language to open up AI coding to novices
  • Is Julia fastest-growing new programming language? Stats chart rapid rise in 2018
  • Python vs R for data science: Professor rates programming language rivals
  • Is Julia the next big programming language? MIT thinks so, as version 1.0 lands TechRepublic
  • Mozilla's radical open-source move helped rewrite rules of tech CNET
  • Editorial standards