Type inference for static compilation of JavaScript
By Satish Chandra, Colin S. Gordon, Jean-Baptiste Jeannin, Cole Schlesinger, Manu Sridharan, Frank Tip, Young-Il Choi. 2016
42 citations recorded by the source corpus.
We present a type system and inference algorithm for a rich subset of JavaScript equipped with objects, structural subtyping, prototype inheritance, and first-class methods. The type system supports abstract and recursive objects, and is expressive enough to accommodate several standard benchmarks with only minor workarounds. The invariants enforced by the types enable an ahead-of-time compiler to carry out optimizations typically beyond the reach of static compilers for dynamic languages. Unlike previous inference techniques for prototype inheritance, our algorithm uses a combination of lower and upper bound propagation to infer types and discover type errors in all code, including uninvoked functions. The inference is expressed in a simple constraint language, designed to leverage off-the-shelf fixed point solvers. We prove soundness for both the type system and inference algorithm. An experimental evaluation showed that the inference is powerful, handling the aforementioned benchmarks with no manual type annotation, and that the inferred types enable effective static compilation.
Subfields: Artificial Intelligence, Hardware and Architecture, Information Systems, Program Analysis & Verification
How researchers see this paper
The researchers whose trusted networks rank it highest, strongest advocate first. Every researcher gets a different order.
In Artificial Intelligence
- Erik Krogh Kristensen
- Anders Møller
- Michael Pradel
- Panagiotis Vekris
- Georgios Gousios
- Satish Chandra
- Sam Goldman
- Jason Liu
In Hardware and Architecture
In Information Systems
- Erik Krogh Kristensen
- Georgios Gousios
- Anders Møller
- Michael Pradel
- Satish Chandra
- Jason Liu
- Panagiotis Vekris
- Sam Goldman
In Program Analysis & Verification
- Erik Krogh Kristensen
- Anders Møller
- Georgios Gousios
- Satish Chandra
- Jason Liu
- Michael Pradel
- Panagiotis Vekris
- Avik Chaudhuri
Citations in the corpus
- TypeWriter: neural type prediction with search-based validation (2019, background): “As all existing type prediction models [15, 21, 29] target JavaScript code, it is difficult to draw conclusions as to whether the TypeWriter architecture is the best for the task.”
- Fast and precise type checking for JavaScript (2017, background): “Chandra et al. [2016] build on this work by adding support for abstract objects, first-class methods, and recursive objects, and prove their extensions sound.”
- Inference and Evolution of TypeScript Declaration Files (2017, methodology): “Other research on TypeScript includes formalization and variations of its type system [4,17,18,22], and several alternative techniques for JavaScript type inference exist [16,11,6], however, none of that work addresses the challenges that arise when integrating JavaScript libraries into typed applic”