Microsoft wants to make a potentially huge change to JavaScript

JavaScript code on a computer screen
(Image credit: Shutterstock / BEST-BACKGROUNDS)

Microsoft has backed a proposal to bring optional and erasable type syntax to JavaScript in an effort to make its TypeScript language both faster and easier to use.

In a new blog post, the software giant provided further insight on the proposal and what it aims to do. Essentially, the proposal is calling for type annotations to be added to JavaScript code that can be checked by external type checkers and treated as comments by a JavaScript engine at runtime.

A set of syntax for types that engines would ignore but TypeScript, Flow and other tools could use would also need to be created as part of the proposal.

If the proposal is approved, developers would be able to run programs in TypeScript, Flow and other static typing supersets of JavaScript without the need for transpilation according to InfoWorld.

Type syntax in JavaScript

The new Stage 0 proposal was written and put forth by Gil Tayar, Microsoft's Daniel Rosenwasser, Igalia's Romulo Cintra and Bloomberg's Rob Palmer and is available to read in its entirety on GitHub.

The reason behind the proposal is that over the past decade, static type checking has proven to be fairly successful. In addition to Microsoft's TypeScript, Google created its Closure Compiler while Facebook built Flow to provide syntax for declaring and using types in JavaScript.

At the same time, 69 percent of respondents in the 2021 State of JavaScript survey said that they use TypeScript to compile JavaScript and static typing was voted as the number one feature missing from the programming language.

It's worth noting that Microsoft isn't calling for TypeScript's type checking to be added to every browser and JavaScript runtime. Instead, the company has proposed a JavaScript syntax compatible with TypeScript that could be used by any type checker while being ignored by JavaScript engines.

Via InfoWorld

Anthony Spadafora

After working with the TechRadar Pro team for the last several years, Anthony is now the security and networking editor at Tom’s Guide where he covers everything from data breaches and ransomware gangs to the best way to cover your whole home or business with Wi-Fi. When not writing, you can find him tinkering with PCs and game consoles, managing cables and upgrading his smart home.