Advertisement

Inference and Evolution of TypeScript Declaration Files

  • Erik Krogh Kristensen
  • Anders MøllerEmail author
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 10202)

Abstract

TypeScript is a typed extension of JavaScript that has become widely used. More than 2000 JavaScript libraries now have publicly available TypeScript declaration files, which allows the libraries to be used when programming TypeScript applications. Such declaration files are written manually, however, and they are often lagging behind the continuous development of the libraries, thereby hindering their usability. The existing tool tscheck is capable of detecting mismatches between the libraries and their declaration files, but it is less suitable when creating and evolving declaration files.

In this work we present the tools tsinfer and tsevolve that are designed to assist the construction of new TypeScript declaration files and support the co-evolution of the declaration files as the underlying JavaScript libraries evolve. Our experimental results involving major libraries demonstrate that tsinfer and tsevolve are superior to tscheck regarding these tasks and that the tools are sufficiently fast and precise for practical use.

Keywords

Return Type Intentional Discrepancy Pull Request Type Declaration Spurious Change 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Notes

Acknowledgments

This work was supported by the European Research Council (ERC) under the European Union’s Horizon 2020 research and innovation program (grant agreement No 647544).

References

  1. 1.
    Andersen, L.O.: Program analysis and specialization for the C programming language. PhD thesis, University of Copenhagen (1994)Google Scholar
  2. 2.
    Andreasen, E., Møller, A.: Determinacy in static analysis for jQuery. In: Proceeding ACM International Conference on Object Oriented Programming Systems Languages & Applications (2014)Google Scholar
  3. 3.
    Bae, S., Cho, H., Lim, I., Ryu, S.: SAFE\(_\text{WAPI}\): web API misuse detector for web applications. In: Proceeding 22nd ACM SIGSOFT International Symposium on Foundations of Software Engineering (2014)Google Scholar
  4. 4.
    Bierman, G.M., Abadi, M., Torgersen, M.: Understanding typescript. In: Proceeding 28th European Conference on Object-Oriented Programming (2014)Google Scholar
  5. 5.
    Bonnaire-Sergeant, A., Davies, R., Tobin-Hochstadt, S.: Practical optional types for clojure. In: Thiemann, P. (ed.) ESOP 2016. LNCS, vol. 9632, pp. 68–94. Springer, Heidelberg (2016). doi: 10.1007/978-3-662-49498-1_4 CrossRefGoogle Scholar
  6. 6.
    Chandra, S., Gordon, C.S., Jeannin, J.-B., Schlesinger, C., Sridharan, M., Tip, F., Choi, Y.-I.: Type inference for static compilation of JavaScript. In: Proceeding ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications (2016)Google Scholar
  7. 7.
    Facebook. Flow (2016). http://flowtype.org/
  8. 8.
    Feldthaus, A., Møller, A.: Checking correctness of TypeScript interfaces for JavaScript libraries. In: Proceeding ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications (2014)Google Scholar
  9. 9.
    Jensen, S.H., Møller, A., Thiemann, P.: Type analysis for JavaScript. In: Proceeding 16th International Static Analysis Symposium (2009)Google Scholar
  10. 10.
    Lehtosalo, J., et al.: Mypy (2016). http://www.mypy-lang.org/
  11. 11.
    Lerner, B.S., Politz, J.G., Guha, A., Krishnamurthi, S.: TeJaS: retrofitting type systems for JavaScript. In: Proceeding 9th Symposium on Dynamic Languages (2013)Google Scholar
  12. 12.
    ‘Matz’ Matsumoto, Y.: RubyConf 2014 – opening keynote (2014). http://confreaks.tv/videos/rubyconf2014-opening-keynote
  13. 13.
    Microsoft. TypeScript language specification, February 2015. https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md
  14. 14.
    Padioleau, Y., Lawall, J.L., Hansen, R.R., Muller, G.: Documenting and automating collateral evolutions in Linux device drivers. In: Proceeding EuroSys Conference. ACM (2008)Google Scholar
  15. 15.
    Pottier, F.: A framework for type inference with subtyping. In: Proceeding 3rd ACM SIGPLAN International Conference on Functional Programming (1998)Google Scholar
  16. 16.
    Rastogi, A., Chaudhuri, A., Hosmer, B.: The ins and outs of gradual type inference. In: Proceeding 39th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (2012)Google Scholar
  17. 17.
    Rastogi, A., Swamy, N., Fournet, C., Bierman, G.M., Vekris, P.: Safe & efficient gradual typing for TypeScript. In: Proceeding 42nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (2015)Google Scholar
  18. 18.
    Richards, G., Zappa Nardelli, F., Vitek, J.: In: Proceeding 29th European Conference on Object-Oriented Programming (2015)Google Scholar
  19. 19.
    Sridharan, M., Dolby, J., Chandra, S., Schäfer, M., Tip, F.: Correlation tracking for points-to analysis of JavaScript. In: Noble, J. (ed.) ECOOP 2012. LNCS, vol. 7313, pp. 435–458. Springer, Heidelberg (2012). doi: 10.1007/978-3-642-31057-7_20 CrossRefGoogle Scholar
  20. 20.
    Steensgaard, B.: Points-to analysis in almost linear time. In: Proceeding 23rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (1996)Google Scholar
  21. 21.
    Tobin-Hochstadt, S., Felleisen, M.: The design and implementation of typed Scheme (2008)Google Scholar
  22. 22.
    Vekris, P., Cosman, B., Jhala, R.: Refinement types for TypeScript. In: Proceeding 37th ACM SIGPLAN Conference on Programming Language Design and Implementation (2016)Google Scholar
  23. 23.
    Vitousek, M.M., Kent, A.M., Siek, J.G., Baker, J.: Design and evaluation of gradual typing for Python. In: Proceeding 10th ACM Symposium on Dynamic Languages (2014)Google Scholar

Copyright information

© Springer-Verlag GmbH Germany 2017

Authors and Affiliations

  1. 1.Aarhus UniversityAarhusDenmark

Personalised recommendations