Abstract
We present Refined TypeScript (RSC), a lightweight refinement type system for TypeScript, that enables static verification of higher-order, imperative programs. We develop a formal system for RSC that delineates the interaction between refinement types and mutability, and enables flow-sensitive reasoning by translating input programs to an equivalent intermediate SSA form. By establishing type safety for the intermediate form, we prove safety for the input programs. Next, we extend the core to account for imperative and dynamic features of TypeScript, including overloading, type reflection, ad hoc type hierarchies and object initialization. Finally, we evaluate RSC on a set of real-world benchmarks, including parts of the Octane benchmarks, D3, Transducers, and the TypeScript compiler. We show how RSC successfully establishes a number of value dependent properties, such as the safety of array accesses and downcasts, while incurring a modest overhead in type annotations and code restructuring.
- C. Anderson, P. Giannini, and S. Drossopoulou. Towards Type Inference for JavaScript. In Proceedings of ECOOP, 2005. Google Scholar
Digital Library
- G. M. Bierman, A. D. Gordon, C. Hri¸tcu, and D. Langworthy. Semantic Subtyping with an SMT Solver. In Proceedings of ICFP, 2010. Google Scholar
Digital Library
- G. M. Bierman, M. Abadi, and M. Torgersen. Understanding TypeScript. In Proceedings of ECOOP, 2014. Google Scholar
Digital Library
- M. Bostock. http://d3js.org/.Google Scholar
- R. Chugh, D. Herman, and R. Jhala. Dependent Types for JavaScript. In Proceedings of OOPSLA, 2012. Google Scholar
Digital Library
- R. Chugh, P. M. Rondon, and R. Jhala. Nested Refinements: A Logic for Duck Typing. In Proceedings of POPL, 2012. Google Scholar
Digital Library
- Cognitect Labs. https://github.com/cognitect-labs/ transducers-js.Google Scholar
- A. Feldthaus and A. Møller. Checking Correctness of Type-Script Interfaces for JavaScript Libraries. In Proceedings of OOPLSA, 2014. Google Scholar
Digital Library
- C. Flanagan, K. R. M. Leino, M. Lillibridge, G. Nelson, J. B. Saxe, and R. Stata. Extended Static Checking for Java. In Proceedings of PLDI, 2002. Google Scholar
Digital Library
- M. Furr, J.-h. D. An, J. S. Foster, and M. Hicks. Static Type Inference for Ruby. In Proceedings of the Symposium on Applied Computing, 2009. Google Scholar
Digital Library
- P. Gardner, S. Maffeis, and G. D. Smith. Towards a program logic for JavaScript. In Proceedings of POPL, 2012. Google Scholar
Digital Library
- Google Developers. https://developers.google.com/ octane/.Google Scholar
- C. S. Gordon, M. J. Parkinson, J. Parsons, A. Bromfield, and J. Duffy. Uniqueness and Reference Immutability for Safe Parallelism. In Proceedings of OOPSLA, 2012. Google Scholar
Digital Library
- C. S. Gordon, M. D. Ernst, and D. Grossman. Rely-guarantee References for Refinement Types over Aliased Mutable Data. In Proceedings of PLDI, 2013. Google Scholar
Digital Library
- A. Guha, M. Fredrikson, B. Livshits, and N. Swamy. Verified Security for Browser Extensions. In Proceedings of the IEEE Symposium on Security and Privacy, 2011. Google Scholar
Digital Library
- S. Guo and B. Hackett. Fast and Precise Hybrid Type Inference for JavaScript. In Proceeding of PLDI, 2012. Google Scholar
Digital Library
- C. Haack and E. Poll. Type-Based Object Immutability with Flexible Initialization. In Proceedings of ECOOP, 2009. Google Scholar
Digital Library
- A. Igarashi, B. C. Pierce, and P. Wadler. Featherweight Java: A Minimal Core Calculus for Java and GJ. ACM Trans. Program. Lang. Syst., May 2001. Google Scholar
Digital Library
- K. Knowles and C. Flanagan. Hybrid Type Checking. ACM Trans. Program. Lang. Syst., Feb. 2010. Google Scholar
Digital Library
- K. Knowles and C. Flanagan. Compositional Reasoning and Decidable Checking for Dependent Contract Types. In Proceedings of PLPV, 2008. Google Scholar
Digital Library
- B. S. Lerner, J. G. Politz, A. Guha, and S. Krishnamurthi. Te-JaS: Retrofitting Type Systems for JavaScript. In Proceedings of DLS, 2013. Google Scholar
Digital Library
- Microsoft Corporation. TypeScript v1.4. http://www. typescriptlang.org/.Google Scholar
- F. Militão, J. Aldrich, and L. Caires. Rely-Guarantee Protocols. In Proceedings of ECOOP, 2014. Google Scholar
Digital Library
- G. Nelson. Techniques for Program Verification. Technical Report CSL81-10, Xerox Palo Alto Research Center, 1981.Google Scholar
- N. Nystrom, V. Saraswat, J. Palsberg, and C. Grothoff. Constrained Types for Object-oriented Languages. In Proceedings of OOPSLA, 2008. Google Scholar
Digital Library
- X. Qi and A. C. Myers. Masked Types for Sound Object Initialization. In Proceedings of POPL, 2009. Google Scholar
Digital Library
- A. Rastogi, N. Swamy, C. Fournet, G. Bierman, and P. Vekris. Safe & Efficient Gradual Typing for TypeScript. In Proceedings of POPL, 2015. Google Scholar
Digital Library
- P. M. Rondon, M. Kawaguci, and R. Jhala. Liquid Types. In Proceedings of PLDI, 2008. Google Scholar
Digital Library
- J. Rushby, S. Owre, and N. Shankar. Subtypes for Specifications: Predicate Subtyping in PVS. IEEE TSE, 1998. Google Scholar
Digital Library
- E. L. Seidel, N. Vazou, and R. Jhala. Type Targeted Testing. In Proceedings of ESOP, 2015. Google Scholar
Digital Library
- F. Smith, D. Walker, and G. Morrisett. Alias Types. In Proceedings of ESOP, 2000. Google Scholar
Digital Library
- A. J. Summers and P. Mueller. Freedom Before Commitment: A Lightweight Type System for Object Initialisation. In Proceedings of OOPSLA, 2011. Google Scholar
Digital Library
- N. Swamy, J. Chen, C. Fournet, P.-Y. Strub, K. Bhargavan, and J. Yang. Secure Distributed Programming with Valuedependent Types. In Proceedings of ICFP, 2011. Google Scholar
Digital Library
- O. Tardieu, N. Nystrom, I. Peshansky, and V. Saraswat. Constrained Kinds. In Proceedings of OOPSLA, 2012. Google Scholar
Digital Library
- P. Thiemann. Towards a Type System for Analyzing JavaScript Programs. In Proceedings of ESOP, 2005. Google Scholar
Digital Library
- S. Tobin-Hochstadt and M. Felleisen. Logical Types for Untyped Languages. In Proceedings of ICFP, 2010. Google Scholar
Digital Library
- N. Vazou, E. L. Seidel, R. Jhala, D. Vytiniotis, and S. Peyton-Jones. Refinement Types for Haskell. In Proceedings of ICFP, 2014. Google Scholar
Digital Library
- P. Vekris, B. Cosman, and R. Jhala. Refinement Types for TypeScript (Extended version). http://arxiv.org/abs/ 1604.02480.Google Scholar
- P. Vekris, B. Cosman, and R. Jhala. Trust, but Verify: Two-Phase Typing for Dynamic Languages. In Proceedings of ECOOP, 2015.Google Scholar
- H. Xi and F. Pfenning. Dependent Types in Practical Programming. In Proceedings of POPL, 1999. Google Scholar
Digital Library
- B. Yankov. http://definitelytyped.org.Google Scholar
- Y. Zibin, A. Potanin, M. Ali, S. Artzi, A. Kiezun, and M. D. Ernst. Object and Reference Immutability Using Java Generics. In Proceedings of ESEC/FSE, 2007. Google Scholar
Digital Library
- Y. Zibin, A. Potanin, P. Li, M. Ali, and M. D. Ernst. Ownership and Immutability in Generic Java. In Proceedings of OOPSLA, 2010. Google Scholar
Digital Library
- Y. Zibin, D. Cunningham, I. Peshansky, and V. Saraswat. Object Initialization in X10. In Proceedings of ECOOP, 2012. Google Scholar
Digital Library
Index Terms
Refinement types for TypeScript
Recommendations
Refinement types for TypeScript
PLDI '16: Proceedings of the 37th ACM SIGPLAN Conference on Programming Language Design and ImplementationWe present Refined TypeScript (RSC), a lightweight refinement type system for TypeScript, that enables static verification of higher-order, imperative programs. We develop a formal system for RSC that delineates the interaction between refinement types ...
Gradual refinement types
POPL '17Refinement types are an effective language-based verification technique. However, as any expressive typing discipline, its strength is its weakness, imposing sometimes undesired rigidity. Guided by abstract interpretation, we extend the gradual typing ...
Gradual refinement types
POPL '17: Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming LanguagesRefinement types are an effective language-based verification technique. However, as any expressive typing discipline, its strength is its weakness, imposing sometimes undesired rigidity. Guided by abstract interpretation, we extend the gradual typing ...







Comments