Skip navigation
developer typing code onto a computer screen Getty Images

Bloomberg Embraces TypeScript Language to Improve JavaScript Code

The TypeScript open source project can help make JavaScript code more robust, which is why Bloomberg has embraced it across millions of lines of code.

JavaScript is one of the most popular and widely deployed programming languages, being used by organizations of sizes, including financial information services organizations such as Bloomberg.

Having adopted JavaScript at scale in 2005, New York-based Bloomberg realized in recent years that it needed something more to help it be even more performant and stable, which led the company to embrace the TypeScript programming language.

Microsoft announced the TypeScript language in 2012, and it has been steadily improved over the past eight years as an open source effort. TypeScript provides a "static type" system for JavaScript, offering a way to define a variable type at the time code is compiled. A key advantage of being statically typed is code checking can more easily be done by the compiler, enabling more bugs to be caught before code is deployed to production.

Inside JavaScript at Bloomberg

Bloomberg has approximately 2,000 JavaScript developers, with most writing applications for the company's core platform, the Bloomberg Terminal, according to Rob Palmer, who leads the JavaScript tooling and infrastructure team at Bloomberg.

"We adopted JavaScript at scale in 2005 before node.js existed, which wasn't introduced until around 2009," Palmer told ITPro Today.

Node.js was one of the key drivers for mainstream JavaScript adoption on servers. As such, Palmer noted that Bloomberg had to develop a number of customized systems to enable JavaScript on the server side. In 2012, Bloomberg began to use the open source Chromium web engine, which is at the core of Google Chrome web browser, as a key technology. Palmer explained that Bloomberg has its own JavaScript runtime environment, which is separate from the web browser.

"The investment in JavaScript is huge, with 50 million lines of code or more, because essentially all of our application layer is built using JavaScript," he said.

Why Bloomberg Embraced TypeScript

Bloomberg first began to look at the TypeScript language in 2016, as the company had a long history of engineers who were familiar with C and C++, Palmer said. Both of those language are "typed languages" and, as such, JavaScript was somewhat at odds as it is not statically typed, he added.

"TypeScript fills that gap; it's a very natural complement to JavaScript," Palmer said. "The definition of TypeScript really is JavaScript plus types."

Palmer noted that at Bloomberg, moving to TypeScript meant errors could be caught earlier in the process by the compiler, which helps increase the overall robustness and reliability of running code.

How TypeScript and JavaScript Complement Each Other

Before his group started any of the code migration, Palmer said rigorous tooling and safeguards were put in place to allow for safe conversion.

The nature of TypeScript itself also helped Bloomberg migrate in a methodical process. A key feature of TypeScript is that it is a gradually typed language, Palmer said, meaning a developer can start with JavaScript and then increase the amount of code that is typed a little at a time.

For example, a developer can take just one JavaScript file and convert that to TypeScript. Palmer emphasized that a key thing to remember with TypeScript is that all of the types only exist at compile time, and when TypeScript is compiled, the output of that is JavaScript.

"The TypeScript compiler is converting TypeScript into JavaScript, and this gradual approach was essential for converting such a huge codebase," he said. "There might be a perception that TypeScript is a completely different language than JavaScript, but that is not true — TypeScript is firmly based on JavaScript."

Open Source and Bloomberg Contributions

Bloomberg has been using the open source version of the TypeScript language and has not forked the code, as it is pleased with the way Microsoft has run the open source TypeScript project, according to Palmer.

"It's open source in every sense of the word," he said. "Even things like planning documents, release procedures and iteration plans are all public on the TypeScript GitHub repository, and this makes it really easy to see what's going on to see what's coming up."

The project is open to contributions, and Bloomberg has made multiple of them, including support for private fields in the TypeScript 3.8 release, Palmer said. Private fields allow information to hide inside of JavaScript classes.

For other organizations looking to embrace TypeScript to improve the stability and robustness of JavaScript, Palmer has a key recommendation — don't do a massive migration to start.

"There is no need to go for a big bang," he said. "Migrate project by project, file by file, and then you can rely on word of mouth and the enthusiasm of the engineers that are experiencing it to drive progress throughout the rest of the organization."

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.