TypeScript creator: How the programming language beat Microsoft's open-source fears

After initial internal Microsoft resistance, open-source TypeScript is now a go-to language for building web apps.
Written by Liam Tung, Contributing Writer

Microsoft's open-source programming language TypeScript – the alter ego of JavaScript but with a type system – turns 10 years old this December. 

It's grown to become a go-to language for building apps that run in the browser but back in 2010 it had to pick its way through a Microsoft company culture that was still fearful of open source. 

TypeScript co-creator Anders Hejlsberg, a Danish software engineer and technical fellow at Microsoft, describes to ZDNet the moment in 2010 when, under the then Microsoft chief Steve Ballmer, his team decided that an open-source strategy was the only way to win over JavaScript developers. 

SEE: Hiring Kit: Python developer (TechRepublic Premium)

Ballmer in 2001 called Linux a "cancer" that threatened all Microsoft's intellectual property, and in 2010 open source at Microsoft was still a prickly issue for top management. 

"Linux was [seen as] a threat to Windows, and it turns out that it is exactly the opposite," Hejlsberg says.   

Ballmer, who stepped down as CEO in August 2014, has since recanted that position and today, under Microsoft CEO Satya Nadella and with a focus on the cloud, the company loves open source and owns the open-source code repository, GitHub. 

Its other major open-source projects include the popular code editor Visual Studio Code (VS Code), .NET Code, and TypeScript, a superset of JavaScript with a type system that compiles into JavaScript.

Since its official release in 2012, TypeScript has become a crucial language to front-end development for browser applications, adopted by the likes of Slack, Airbnb and of course Microsoft, which built VS Code in TypeScript. The language now has a firm spot in the top 10 programming languages along with Java, JavaScript and Python.    

But in 2010, Hejlsberg knew that pitching TypeScript as an open-source project could be a tough sell at Microsoft's Redmond headquarters. As the programming language approaches its 10th anniversary, Hejlsberg recalls how Microsoft viewed anything open source with trepidation.  

"It'll be 10 years come Christmas time," he tells ZDNet. "TypeScript was really just an idea of, 'Let's see if we can do a little bit better for JavaScript'.  

"We built some prototypes and we threw it together. But it was really clear that the only way we're going to appeal to the JavaScript community is by being open source. And at that time, that was a different conversation to have at the Microsoft of that day." 

Hejlsberg's TypeScript team "had to actually run it way up the flagpole with a bunch of people who had strong opinions about what we should do here", he says, without mentioning names of any execs who might have opposed it. But he notes that at the time, under Ballmer, Microsoft was "very ambivalent" about open source and "afraid" of it.

"We kind of knew that it was something we had to do but we had no experience doing it," says Hejlsberg. 

But as TypeScript matured and open source gained acceptance at Microsoft in its pivot from Windows to the cloud, the company would in 2014 shift TypeScript to a model of "open development" via a public repository on GitHub. Using GitHub allowed the community of TypeScript and JavaScript developers to influence its future.

Because of that different approach, his team now has "zero distance" to its customers – the developers who use either JavaScript or TypeScript.  

"There's open source in the technical sense in that you give people your source code and give away your intellectual property rights, and technically that's open source," explains Hejlsberg. 

"But then there's open development, where you actually do your entire development process in the open, which we've been doing now since TypeScript moved to GitHub in 2014." 

Today, GitHub, which Microsoft acquired in 2018 for $7.5bn, is where the TypeScript team of about 20 Microsoft engineers do all its daily work, allowing for a "closeness to our customers like nothing I've seen before".

Hejlsberg has been at Microsoft since 1996 after a stint at Borland, building the Turbo Pascal compiler. At Microsoft he was also the lead architect of C#.

Before the move to GitHub, Hejlsberg says TypeScript users would submit bugs or demand requests at developer conferences, but his team would take a year to deliver new features that would often miss the mark.

Why create TypeScript?

TypeScript was hatched at Microsoft at an interesting juncture for the web and the company. With Internet Explorer losing share to Google Chrome, Microsoft would later launch its Edge browser in 2015 with the open-source Chakra JavaScript engine. But by then Google Chrome, with its focus on web standards and a powerful JavaScript engine called V8, had already emerged as a clear winner of the browser wars. 

"The browser wars were over, Google had built Chrome, and HTML5 was happening. Google had also built a very efficient JavaScript engine and the efficiency of JavaScript had gone up tremendously. Everyone was starting to realize that the browser was going to be where real apps were being built," recalls Hejlsberg. 

Developers by then had started to build huge JavaScript apps for the browser and were struggling to write them in JavaScript, a language he says lacked key features like modules, classes, and, importantly, a type system for creating order through rules in a program. 

Then there were developer tools, such as integrated development environments (IDEs) like VS Code for enhancing developer productivity. 

"If you think about what powers our development tools, like modern IDEs, that we all take for granted, like Visual Studio or WebStorm [from JetBrains] and other products out there – all the programmer productivity features we have like VSCode's IntelliSense, code definition and code navigation require the IDE to be able to reason about the code that you're working on," he says.  

"A type system is one way you can reason about your code. It's the ability to check your code before you run and deploy it. Without types in a language that's almost impossible.

"At the time, developers were doing crazy things like writing an entire product like Outlook.com, which at one point was written in a variant of C# that was being cross-compiled to JavaScript using a tool called Script Sharp."   

Google had a similar cross-compiling tool called the Google Web Toolkit (GWT), which allowed its developers to write in Java and cross-compile to JavaScript.

"That way [Google] could get grown-up developer tooling. They could get a real IDE with project features, modules and classes and IntelliSense and statement completion, and then they could just view JavaScript as an instruction language," he says. 

Before TypeScript emerged, Microsoft was looking to turn a tool called Script Sharp into a product. But Hejlsberg wondered if these developers were willing to "bend over that far backwards to write in JavaScript". So why not try to solve the real problems with JavaScript? 

"Because surely you're not going to build a best-of-breed development experience for JavaScript by telling people to write in a different language," he says. 

"So we started looking at what we could do to address these issues to build better tooling for JavaScript. That was really the genesis of TypeScript. The key was to add a type system to the language in a way that doesn't take away all the things that made JavaScript so popular in the first place."

Hejlsberg and company decided to build an "erasable type system" – the component that makes TypeScript a superset of JavaScript. At compile time, TypeScript would remove all the types and return it to JavaScript. 

"In a sense it's a type system that only exists during the developer experience, but it goes away at run time. But it gives you all of the benefits and none of the drawbacks when you run," he explains. 

What is TypeScript's main competitor? 

According to Hejlsberg, TypeScript's only real competitor is JavaScript, given both now are the go-to languages for running front-end applications, while WebAssembly is blurring the boundaries between native apps and browser apps.  

"But JavaScript is not really a competitor. It is our twin or alter ego," he says. 

"The question is really, 'Are there languages that compete with JavaScript and/or TypeScript?' Yes and no. But every language you see on these lists typically have a point of affinity. Like Python has found a whole lot of use in machine learning and AI, and SQL is used to create databases, and C# and Java are important in the enterprise back end. 

"JavaScript and TypeScript are, you know, how the front end runs. It's the only language that runs in the browser, except for WebAssembly now. So there's a completely natural affinity. If you're going to write a web application, you're going to write it in JavaScript or TypeScript."

Like JavaScript, Microsoft TypeScript tracks the development of the ECMAScript standard and increasingly TypeScript is being developed to cater to developers who prefer plain JavaScript. 

"Once a feature reaches stage three in the ECMAScript standardization process, we consider it ready for adoption in TypeScript and then we work with the community to get a pull request merged," he says. 

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

Over the past two years, the TypeScript team have focused on building TypeScript "for the people who don't want TypeScript" through improved support for type annotations in JavaScript js.doc comments. 

"Because TypeScript is a superset of JavaScript, you could also think of JavaScript as a subset of TypeScript. And that means that our entire TypeScript toolchain is perfectly happy to process JavaScript and provide all the services on top of JavaScript," says Hejlsberg. 

"In a sense, JavaScript is like TypeScript with no type annotations. And so one popular way of using JavaScript is, instead of using type annotations directly in your source code, people will put type annotations in comments (js.doc comments) and a compiler can actually derive a lot of information from those comments. 

"So, we have actually beefed up our support for js.doc comments over the past couple of years and beefed up our ability to just consume JavaScript straight out of the box."  


TypeScript co-creator Anders Hejlsberg: "Linux was [seen as] a threat to Windows, and it turns out that it is exactly the opposite."  

Image: Microsoft/YouTube

More on Microsoft's TypeScript programming language  

Editorial standards