News

Babel 7 JavaScript Compiler Adds TypeScript Support

The popular open source Babel compiler that makes modern JavaScript compatible with older environments has shipped in version 7 and, with help from Microsoft, now supports TypeScript.

Babel, a compiler toolchain, is used by millions of JavaScript developers to convert ECMAScript 2015 and later code into backwards-compatible JavaScript versions to make it work in older Web browsers or other environments.

Unlike many open source projects that have strong backing from corporate dev teams, it's primarily driven by individual volunteers. Those volunteers worked for a year to create Babel 7, shipping it last week. Babel 6 was released almost three years ago.

"We worked with the TypeScript team on getting Babel to parse/transform type syntax with @babel/preset-typescript, similar to how we handle Flow with @babel/preset-flow," said Babel volunteer Henry Zhu in a blog post last week.

Daniel Rosenwasser, the TypeScript guru on the Microsoft dev team, provided more information on the new support.

"Over a year ago, we set out to find what the biggest difficulties users were running into with TypeScript, and we found that a common theme among Babel users was that trying to get TypeScript set up was just too hard," Rosenwasser said. "The reasons often varied, but for a lot of developers, rewiring a build that's already working can be a daunting task."

So, for about a year, the Microsoft team worked with the Babel community volunteers to add TypeScript support to the project. While Babel will compile types to plain JavaScript code, it won't actually do type-checking, which is still the exclusive province of TypeScript. That doesn't do much for existing TypeScript coders, Rosenwasser acknowledged, "But if you're already using Babel, or interested in the Babel ecosystem, and you want to get the benefits of TypeScript like catching typos, error checking, and the editing experiences you might've seen in the likes of Visual Studio and Visual Studio Code, this is for you!"

There are some caveats with the new functionality -- such as a few constructs that don't compile -- and Microsoft still recommends use of its tsc TypeScript compiler for type-checking TypeScript code, which Babel doesn't do.

Besides the TypeScript support, Babel 7 also features a lot of other new functionality. "Babel 7 is a huge release," Zhu said, "we've made it faster, created an upgrade tool, JS configs, config 'overrides,' more options for size/minification, JSX Fragments, TypeScript, new proposals, and more!"

About the Author

David Ramel is an editor and writer at Converge 360.

comments powered by Disqus

Featured

  • Hands On: New VS Code Insiders Build Creates Web Page from Image in Seconds

    New Vision support with GitHub Copilot in the latest Visual Studio Code Insiders build takes a user-supplied mockup image and creates a web page from it in seconds, handling all the HTML and CSS.

  • Naive Bayes Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the naive Bayes regression technique, where the goal is to predict a single numeric value. Compared to other machine learning regression techniques, naive Bayes regression is usually less accurate, but is simple, easy to implement and customize, works on both large and small datasets, is highly interpretable, and doesn't require tuning any hyperparameters.

  • VS Code Copilot Previews New GPT-4o AI Code Completion Model

    The 4o upgrade includes additional training on more than 275,000 high-quality public repositories in over 30 popular programming languages, said Microsoft-owned GitHub, which created the original "AI pair programmer" years ago.

  • Microsoft's Rust Embrace Continues with Azure SDK Beta

    "Rust's strong type system and ownership model help prevent common programming errors such as null pointer dereferencing and buffer overflows, leading to more secure and stable code."

  • Xcode IDE from Microsoft Archrival Apple Gets Copilot AI

    Just after expanding the reach of its Copilot AI coding assistant to the open-source Eclipse IDE, Microsoft showcased how it's going even further, providing details about a preview version for the Xcode IDE from archrival Apple.

Subscribe on YouTube

Upcoming Training Events