By Zheng Gao, Earl T. Barr, and Christian Bird

JavaScript is growing explosively and is now used in large mature projects even outside the web domain. JavaScript is also a dynamically typed language for which static type systems, notably Facebook’s Flow and Microsoft’s TypeScript, have been written. What benefits do these static type systems provide?

Leveraging JavaScript project histories, we select a fixed bug and check out the code just prior to the fix. We manually add type annotations to the buggy code and test whether Flow and TypeScript report an error on the buggy code, thereby possibly prompting a developer to fix the bug before its public release. We then report the proportion of bugs on which these type systems reported an error.

Evaluating static type systems against public bugs, which have survived testing and review, is conservative: it understates their effectiveness at detecting bugs during private development, not to mention their other benefits such as facilitating code search/completion and serving as documentation. Despite this uneven playing field, our central finding is that both static type systems find an important percentage of public bugs: both Flow 0.30 and TypeScript 2.0 successfully detect 15%!


  author = {Zheng Gao and Christian Bird 
    and Earl T. Barr},
  title = {{To Type or not to Type: On the Effectiveness 
    of Static typing for JavaScript}},
  booktitle = {{Proceedings of the 39th International 
    Conference on Software Engineering}},
  year = {2017},
  publisher = {{IEEE}}
To Type or not to Type: On the Effectiveness of Static typing for JavaScript

Leave a Reply

Your email address will not be published. Required fields are marked *