Advertisement

Understanding TypeScript

  • Gavin Bierman
  • Martín Abadi
  • Mads Torgersen
Part of the Lecture Notes in Computer Science book series (LNCS, volume 8586)

Abstract

TypeScript is an extension of JavaScript intended to enable easier development of large-scale JavaScript applications. While every JavaScript program is a TypeScript program, TypeScript offers a module system, classes, interfaces, and a rich gradual type system. The intention is that TypeScript provides a smooth transition for JavaScript programmers—well-established JavaScript programming idioms are supported without any major rewriting or annotations. One interesting consequence is that the TypeScript type system is not statically sound by design. The goal of this paper is to capture the essence of TypeScript by giving a precise definition of this type system on a core set of constructs of the language. Our main contribution, beyond the familiar advantages of a robust, mathematical formalization, is a refactoring into a safe inner fragment and an additional layer of unsafe rules.

Keywords

Type System Operational Semantic Object Type Call Signature Return Type 
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.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Abadi, M., Cardelli, L.: A theory of objects. Springer (1996)Google Scholar
  2. 2.
    Anderson, C., Giannini, P., Drossopoulou, S.: Towards type inference for javaScript. In: Gao, X.-X. (ed.) ECOOP 2005. LNCS, vol. 3586, pp. 428–452. Springer, Heidelberg (2005)CrossRefGoogle Scholar
  3. 3.
    Bierman, G., Parkinson, M., Pitts, A.: MJ: An imperative core calculus for Java and Java with effects. Technical Report 563, University of Cambridge Computer Laboratory (2003)Google Scholar
  4. 4.
    Chugh, R., Herman, D., Jhala, R.: Dependent types for JavaScript. In: Proceedings of OOSLA (2012)Google Scholar
  5. 5.
    Crockford, D.: JavaScript: The good parts. O’Reilly (2008)Google Scholar
  6. 6.
    Gapeyev, V., Levin, M., Pierce, B.: Recursive subtyping revealed. JFP 12(6), 511–548 (2002)zbMATHMathSciNetGoogle Scholar
  7. 7.
    Gardner, P., Maffeis, S., Smith, G.: Towards a program logic for JavaScript. In: Proceedings of POPL (2013)Google Scholar
  8. 8.
    Google. Dart programming language, http://www.dartlang.org
  9. 9.
    Guha, A., Saftoiu, C., Krishnamurthi, S.: Typing local control and state using flow analysis. In: Barthe, G. (ed.) ESOP 2011. LNCS, vol. 6602, pp. 256–275. Springer, Heidelberg (2011)CrossRefGoogle Scholar
  10. 10.
    Igarashi, A., Pierce, B., Wadler, P.: Featherweight Java: A minimal core calculus for Java and GJ. ACM TOPLAS 23(3), 396–450 (2001)CrossRefGoogle Scholar
  11. 11.
    Microsoft Corporation. TypeScript Language Specification, 0.9.5 edn. (2014), http://typescriptlang.org
  12. 12.
    Pierce, B., Turner, D.: Local type inference. In: Proceedings of POPL (1998)Google Scholar
  13. 13.
    Sénizergues, G.: The equivalence problem for deterministic pushdown automata is decidable. In: Degano, P., Gorrieri, R., Marchetti-Spaccamela, A. (eds.) ICALP 1997. LNCS, vol. 1256, pp. 671–681. Springer, Heidelberg (1997)CrossRefGoogle Scholar
  14. 14.
    Siek, J.G., Taha, W.: Gradual typing for objects. In: Ernst, E. (ed.) ECOOP 2007. LNCS, vol. 4609, pp. 2–27. Springer, Heidelberg (2007)CrossRefGoogle Scholar
  15. 15.
    Swamy, N., Fournet, C., Rastogi, A., Bhargavan, K., Chen, J., Strub, P.-Y., Bierman, G.: Gradual typing embedded securely in JavaScript. In: Proceedings of POPL (2014)Google Scholar
  16. 16.
    Solomon, M.H.: Type definitions with parameters. In: Proceedings of POPL (1978)Google Scholar
  17. 17.
    Thiemann, P.: Towards a type system for analyzing javaScript programs. In: Sagiv, M. (ed.) ESOP 2005. LNCS, vol. 3444, pp. 408–422. Springer, Heidelberg (2005)CrossRefGoogle Scholar
  18. 18.
    Tobin-Hochstadt, S., Felleisen, M.: The design and implementation of Typed Scheme. In: Proceedings of POPL (2008)Google Scholar
  19. 19.
    Wadler, P., Findler, R.B.: Well-typed programs can’t be blamed. In: Castagna, G. (ed.) ESOP 2009. LNCS, vol. 5502, pp. 1–16. Springer, Heidelberg (2009)CrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2014

Authors and Affiliations

  • Gavin Bierman
    • 1
  • Martín Abadi
    • 2
  • Mads Torgersen
    • 2
  1. 1.OracleUSA
  2. 2.MicrosoftUSA

Personalised recommendations