skip to main content
research-article

TeJaS: retrofitting type systems for JavaScript

Published:28 October 2013Publication History
Skip Abstract Section

Abstract

JavaScript programs vary widely in functionality, complexity, and use, and analyses of these programs must accommodate such variations. Type-based analyses are typically the simplest such analyses, but due to the language's subtle idioms and many application-specific needs---such as ensuring general-purpose type correctness, security properties, or proper library usage---we have found that a single type system does not suffice for all purposes. However, these varied uses still share many reusable common elements.

In this paper we present TeJaS, a framework for building type systems for JavaScript. TeJaS has been engineered modularly to encourage experimentation. Its initial type environment is reified, to admit easy modeling of the various execution contexts of JavaScript programs, and its type language and typing rules are extensible, to enable variations of the type system to be constructed easily.

The paper presents the base TeJaS type system, which performs traditional type-checking for JavaScript. Because JavaScript demands complex types, we explain several design decisions to improve user ergonomics. We then describe TeJaS's modular structure, and illustrate it by reconstructing the essence of a very different type system for JavaScript. Systems built from TeJaS have been applied to several real-world, third-party JavaScript programs.

References

  1. A. H. Borning and D. H. H. Ingalls. A type declaration and inference system for Smalltalk. In ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL), 1982. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Chugh, Herman, and Jhala}Chugh2012R. Chugh, D. Herman, and R. Jhala. Dependent types for JavaScript. In ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA), 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. R. Chugh, P. M. Rondon, and R. Jhala. Nested refinements: a logic for duck typing. In ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL), 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. D. Crockford. JavaScript: The Good Parts. O'Reilly Media, Inc., 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. B. Delaware, B. C. de Oliveira, and T. Schrijvers. Meta-theory à la carte. In ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL), 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. A. Guha, C. Saftoiu, and S. Krishnamurthi. The essence of JavaScript. In European Conference on Object-Oriented Programming (ECOOP), 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. A. Guha, C. Saftoiu, and S. Krishnamurthi. Typing local control and state using flow analysis. In European Symposium on Programming Languages and Systems (ESOP), 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. B. S. Lerner, L. Elberty, J. Li, and S. Krishnamurthi. Combining form and function: Static types for JQuery programs. In European Conference on Object-Oriented Programming (ECOOP), 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. B. S. Lerner, L. Elberty, N. Poole, and S. Krishnamurthi. Verifying web browser extensions' compliance with private-browsing mode. In European Symposium on Research in Computer Security (ESORICS), Sept. 2013.Google ScholarGoogle ScholarCross RefCross Ref
  10. M. Y. Levin and B. C. Pierce. TinkerType: a language for playing with formal systems. Journal of Functional Programming (JFP), 13 (2): 295--316, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. J. H. Morris. Lambda-calculus Models of Programming Languages. PhD thesis, Massacheusetts Institute of Technology, 1968.Google ScholarGoogle Scholar
  12. N. Nystrom, M. R. Clarkson, and A. C. Myers. Polyglot: an extensible compiler framework for Java. In International Conference on Compiler Construction (CC), 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. B. C. Pierce. Bounded quantification is undecidable. In ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL), 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. B. C. Pierce and D. N. Turner. Local type inference. ACM Transactions on Programming Languages and Systems (TOPLAS), 22 (1): 1--44, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. J. G. Politz, S. A. Eliopoulos, A. Guha, and S. Krishnamurthi. ADsafety: type-based verification of JavaScript sandboxing. In USENIX Security Symposium, Aug. 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Politz, de la Vallee, and Krishnamurthi}Politz2012bJ. G. Politz, H. Q. de la Vallee, and S. Krishnamurthi. Progressive types. In ACM International Symposium on New Ideas, New Paradigms, and Reflections on Programming and Software (Onward!), 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Politz, Guha, and Krishnamurthi}Politz2012J. G. Politz, A. Guha, and S. Krishnamurthi. Semantics and types for objects with first-class member names. In Workshop on Foundations of Object-Oriented Languages (FOOL), 2012.Google ScholarGoogle Scholar
  18. C. Saftoiu. JSTrace: Run-time type discovery for JavaScript. Technical Report CS-10-05, Brown University, 2010.Google ScholarGoogle Scholar
  19. C. Schwaab and J. G. Siek. Modular type-safety proofs in Agda. In Programming Languages meets Program Verification (PLPV), 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. V. Simonet and F. Pottier. A constraint-based approach to guarded algebraic data types. ACM Transactions on Programming Languages and Systems (TOPLAS), 29 (1): 1--56, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. V. St-Amour, S. Tobin-Hochstadt, M. Flatt, and M. Felleisen. Typing the numeric tower. In Practical Aspects of Declarative Languages (PADL), 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. N. Suzuki. Inferring types in smalltalk. In ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL), 1982. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. S. Tobin-Hochstadt and M. Felleisen. The design and implementation of Typed Scheme. In ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL), 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. W3C. Web IDL. Written Apr. 2012. http://www.w3.org/TR/WebIDL/.Google ScholarGoogle Scholar
  25. A. K. Wright and R. Cartwright. A practical soft type system for Scheme. In ACM conference on LISP and functional programming (LFP), 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. C. Zenger. Indexed types. Theoretical Computer Science, 187 (1--2): 147--165, 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. TeJaS: retrofitting type systems for JavaScript

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in

      Full Access

      • Published in

        cover image ACM SIGPLAN Notices
        ACM SIGPLAN Notices  Volume 49, Issue 2
        DLS '13
        February 2014
        105 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/2578856
        Issue’s Table of Contents
        • cover image ACM Conferences
          DLS '13: Proceedings of the 9th symposium on Dynamic languages
          October 2013
          118 pages
          ISBN:9781450324335
          DOI:10.1145/2508168

        Copyright © 2013 ACM

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 28 October 2013

        Check for updates

        Qualifiers

        • research-article

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!