When JavaScript Met TypeScript

Recent news involving JavaScript is being overshadowed by its smarter brother TypeScript.

This summer Microsoft shipped the final TypeScript 3.0 release after a brief preview. “The open source programming language is primarily developed and maintained by Microsoft, providing a strict syntactical superset of JavaScript with the addition of optional static typing,” as Visual Studio Magazine explained in announcing TypeScript.

More than brothers, the two scripting languages are almost Siamese twins as a Wikipedia article explains: “TypeScript is a strict superset of ECMAScript 2015, which is itself a superset of ECMAScript 5, commonly referred to as JavaScript. As such, a JavaScript program is also a valid TypeScript program, and a TypeScript program can seamlessly consume JavaScript.”

Now you know.

The Typescript open source group’s website explains the relationship this way: “TypeScript starts from the same syntax and semantics that millions of JavaScript developers know today. Use existing JavaScript code, incorporate popular JavaScript libraries, and call TypeScript code from JavaScript. TypeScript compiles to clean, simple JavaScript code which runs on any browser, in Node.js, or in any JavaScript engine that supports ECMAScript 3 (or newer).”

Okay, glad we got that cleared up.

As with any relationship between brothers, there is sibling rivalry.

“There's a dialogue that goes on between TypeScript and JavaScript because, essentially, JavaScript isn't typed and TypeScript is,” Peter Vogel explained in a Visual Studio Magazine article. He goes on to add: “As Douglas Crockford points out in JavaScript: The Good Parts, the lack of data typing in JavaScript shouldn't be regarded as a mistake but, instead, as one of the language's features. With that view, by adding data typing, TypeScript takes some of the power of JavaScript away.”

For Vogel, the debate isn’t either/or but both/and as he writes: “I'm not complaining about that loss. My background is in data-typed languages and I value the IntelliSense support and compile-time checking that TypeScript gives me. However, I've done enough JavaScript programming to also value the advantages that developing without types gives me.”

However, TypeScript’s super power is the ability to essentially transform itself into its brother. As another Wikipedia article explains: “TypeScript provides static typing through type annotations to enable type checking at compile time. This is optional and can be ignored to use the regular dynamic typing of JavaScript.”

Imitation is the sincerest form of flattery.

Just be prepared for a lot of JavaScript meets TypeScript news coming out of Microsoft and the open source community.

In other JavaScript news...

Babel 7 JavaScript Compiler Adds TypeScript Support – Earlier this month, Visual Studio Magazine reported: “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.”

This summer, Microsoft released documentation for ASP.NET Core SignalR JavaScript client library, which “enables developers to call server-side hub code.” For Visual Studio developers, the page explains: “The SignalR JavaScript client library is delivered as an npm package. If you're using Visual Studio, run npm install from the Package Manager Console while in the root folder. For Visual Studio Code, run the command from the Integrated Terminal.”

In June, up-and-coming TypeScript broke into the Top 100 in programming language rankings, according to this Visual Studio Magazine article, which quotes the TIOBE Index popularity report: "This month TypeScript debuts at position 93 in the TIOBE index top 100 … The Microsoft language has been tracked for a couple of years now, but although its popularity in industry seems high, it never made it to the top 100. So finally it has got sufficient traction to be noticed.”

Little brothers are so competitive.

Posted by Richard Seeley on 09/13/2018

Keep Up-to-Date with Visual Studio Live!

Email address*Country*