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.
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- D. Crockford. JavaScript: The Good Parts. O'Reilly Media, Inc., 2008. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- A. Guha, C. Saftoiu, and S. Krishnamurthi. The essence of JavaScript. In European Conference on Object-Oriented Programming (ECOOP), 2010. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Cross Ref
- 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 Scholar
Digital Library
- J. H. Morris. Lambda-calculus Models of Programming Languages. PhD thesis, Massacheusetts Institute of Technology, 1968.Google Scholar
- 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 Scholar
Digital Library
- B. C. Pierce. Bounded quantification is undecidable. In ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL), 1992. Google Scholar
Digital Library
- B. C. Pierce and D. N. Turner. Local type inference. ACM Transactions on Programming Languages and Systems (TOPLAS), 22 (1): 1--44, 2000. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
- C. Saftoiu. JSTrace: Run-time type discovery for JavaScript. Technical Report CS-10-05, Brown University, 2010.Google Scholar
- C. Schwaab and J. G. Siek. Modular type-safety proofs in Agda. In Programming Languages meets Program Verification (PLPV), 2013. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- V. St-Amour, S. Tobin-Hochstadt, M. Flatt, and M. Felleisen. Typing the numeric tower. In Practical Aspects of Declarative Languages (PADL), 2012. Google Scholar
Digital Library
- N. Suzuki. Inferring types in smalltalk. In ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL), 1982. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- W3C. Web IDL. Written Apr. 2012. http://www.w3.org/TR/WebIDL/.Google Scholar
- A. K. Wright and R. Cartwright. A practical soft type system for Scheme. In ACM conference on LISP and functional programming (LFP), 1994. Google Scholar
Digital Library
- C. Zenger. Indexed types. Theoretical Computer Science, 187 (1--2): 147--165, 1997. Google Scholar
Digital Library
Index Terms
TeJaS: retrofitting type systems for JavaScript
Recommendations
TeJaS: retrofitting type systems for JavaScript
DLS '13: Proceedings of the 9th symposium on Dynamic languagesJavaScript 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 ...
Type inference, principal typings, and let-polymorphism for first-class mixin modules
Proceedings of the tenth ACM SIGPLAN international conference on Functional programmingA mixin module is a programming abstraction that simultaneously generalizes λ-abstractions, records, and mutually recursive definitions. Although various mixin module type systems have been developed, no one has investigated principal typings or ...
Type inference, principal typings, and let-polymorphism for first-class mixin modules
ICFP '05: Proceedings of the tenth ACM SIGPLAN international conference on Functional programmingA mixin module is a programming abstraction that simultaneously generalizes λ-abstractions, records, and mutually recursive definitions. Although various mixin module type systems have been developed, no one has investigated principal typings or ...







Comments