“We expect skepticism” — Visual Studio Magazine

News

Microsoft Proposes Big JavaScript Change: “We Expect Skepticism”

Microsoft has announced an ambitious project to inject type syntax into ECMAScript, the official JavaScript standard.

While it may look a lot like TypeScript, it’s different.

The company is supporting and collaborating on an initial Stage 0 proposal to bring optional, erasable type syntax to JavaScript, titled “ECMAScript Proposal: Types as Comments”.

It reads:

This proposal aims to allow developers to add type annotations to their JavaScript code, allowing these annotations to be checked by a type checker that is external to JavaScript. At runtime, a JavaScript engine ignores them, treating the types as comments.

The intent of this proposal is to allow developers to run programs written in TypeScript, Flow, and other statically typed supersets of JavaScript without any need for transpilation, if they stay within some reasonably broad subset of language.

Microsoft’s Daniel Rosenwasser, senior program manager for TypeScript, wrote a comprehensive blog post on March 9 explaining the proposal, which could take years to develop if it goes ahead.

He said this has to do with the recent trend of faster JavaScript iteration, as well as fewer build steps, to make JavaScript coding faster and easier. This trend has been spurred by modern evergreen browsers which often no longer require developers to compile new versions of JavaScript to run on older runtimes.

As the proposal above indicates, the syntax would act as comments, not affecting the execution of the surrounding code.

“The idea of ​​this proposal is that JavaScript could create a set of syntax for types that engines completely ignorebut what tools like TypeScript, Flow and others could use,” he said. removing the need for a build step in development.”

Here’s a graphic showing what a developer’s inner loop would look like in the new schema as it relates to writing and race coded:

Faster and easier
[Click on image for larger view.] Faster and easier (source: Microsoft).

Since the type syntax for JavaScript has appeared before, and developers offer many different opinions on how such a feature works, there are many details that still need to be fleshed out. Rosenwasser said that at a minimum, syntax should be added for things like:

  • type annotations on variables and functions
  • (optional) modifiers (?) for parameters and class members
  • type declarations (interfaces and type a.k.a)
  • type assertion operators (as and !)

While other constructs like visibility modifiers — for example, public, private and protected — could also be in scope, others like enumerations, namespaces and parameter properties would be out of scope as they have observable runtime behavior.

“These features could be offered as separate ECMAScript features based on feedback, but our current focus is to support a large subset of TypeScript that we believe could be a valuable addition to JavaScript,” said- he declared.

The proposal will be presented at the next March 2022 plenary meeting of the TC39 (“Specifying JavaScript”) group of developers, implementers, academics and others who work with the community to maintain and evolve the definition of JavaScript, in the hope of move from Stage 0 to Stage 1.

“Achieving Stage 1 would mean that the standards committee believes type syntax support is worth considering for ECMAScript,” Rosenwasser said. “It’s not a foolproof thing – there are many valuable perspectives on the committee, and we expect some skepticism. A proposal like this will receive plenty of commentary and proper consideration. This may involve many design changes along the way, and can take years to show results.

“But if we pull it all off, we have the chance to deliver one of the most impactful improvements to the world of JavaScript. We’re thrilled about it, and we hope you are too.”

About the Author


David Ramel is an editor and writer for Converge360.



Comments are closed.