Tech Report CS-10-05
Runtime Type-Discovery for JavaScript
Claudiu Saftoiu, Arjun Guha, and Shriram Krishnamurthi
December 2010
Abstract:
We present a static, explicitly-typed variant of JavaScript. In employs a novel strategy that integrates typing with flow analysis, in addition to other well-known features, such as subtyping and union types. The resulting type system is capable of typing several JavaScript patterns employed by third-party programs. However, these features make conventional, Hindley-Milner type inference difficult.
We do not present a novel static type inference technique. Instead, we present a lightweight runtime instrumentation technique that ``discovers types'' during execution. Although runtime analysis necessarily makes type-discovery unsound, the system as a whole is sound, since we type-check after type-discovery. We employ type-discovery to ascribe types to a body of previously untyped, third-party JavaScript programs and report on the effectiveness of our type system and type-discovery.
(complete text in pdf)