Towards a Type System for Analyzing JavaScript Programs

JavaScript is a popular language for client-side web scripting. It has a dubious reputation among programmers for two reasons. First, many JavaScript programs are written against a rapidly evolving API whose implementations are sometimes contradictory and idiosyncratic. Second, the language is only weakly typed and comes virtually without development tools. The present work is a first attempt to address the second point. It does so by defining a type system that tracks the possible traits of an object and flags suspicious type conversions. Because JavaScript is a classless, object-based language with first-class functions, the type system must include singleton types, subtyping, and first class record labels. The type system covers a representative subset of the language and there is a type soundness proof with respect to an operational semantics.

[1]  Thomas Arts,et al.  Proceedings of the 2003 ACM SIGPLAN Workshop on Erlang, Uppsala, Sweden, August 29, 2003 , 2003, Erlang Workshop.

[2]  Didier Rémy,et al.  Type inference for records in natural extension of ML , 1994 .

[3]  Robert Cartwright,et al.  Soft typing , 1991, PLDI '91.

[4]  Sven-Olof Nyström A soft-typing system for Erlang , 2003, ERLANG '03.

[5]  Joe Armstrong,et al.  Concurrent programming in ERLANG , 1993 .

[6]  François Pessaux,et al.  Type-based analysis of uncaught exceptions , 2000, TOPL.

[7]  John C. Mitchell,et al.  Theoretical aspects of object-oriented programming: types, semantics, and language design , 1994, Choice Reviews Online.

[8]  Susumu Nishimura,et al.  Static typing for dynamic messages , 1998, POPL '98.

[9]  Philip Wadler,et al.  A practical subtyping system for Erlang , 1997, ICFP '97.

[10]  Robert Cartwright,et al.  A practical soft type system for scheme , 1997, TOPL.

[11]  Mike Williams,et al.  ERLANG for Concurrent Programming , 1993 .

[12]  Martín Abadi,et al.  A Theory of Objects , 1996, Monographs in Computer Science.

[13]  Fritz Henglein,et al.  Safe polymorphic type inference for a dynamically typed language: translating Scheme to ML , 1995, FPCA '95.

[14]  Jack Trout,et al.  The Power Of Simplicity , 1998 .

[15]  Kwangkeun Yi An Abstract Interpretation for Estimating Uncaught Exceptions in Standard ML Programs , 1998, Sci. Comput. Program..

[16]  Benedict R. Gaster,et al.  A Polymorphic Type System for Extensible Records and Variants , 1996 .

[17]  Randall B. Smith,et al.  SELF: The power of simplicity , 1987, OOPSLA '87.

[18]  Simon L. Peyton Jones,et al.  Imperative functional programming , 1993, POPL '93.

[19]  Fritz Henglein,et al.  Dynamic Typing: Syntax and Proof Theory , 1994, Sci. Comput. Program..