Abstract
The TypeScript programming language adds optional types to JavaScript, with support for interaction with existing JavaScript libraries via interface declarations. Such declarations have been written for hundreds of libraries, but they can be difficult to write and often contain errors, which may affect the type checking and misguide code completion for the application code in IDEs.
We present a pragmatic approach to check correctness of TypeScript declaration files with respect to JavaScript library implementations. The key idea in our algorithm is that many declaration errors can be detected by an analysis of the library initialization state combined with a light-weight static analysis of the library function code.
Our experimental results demonstrate the effectiveness of the approach: it has found 142 errors in the declaration files of 10 libraries, with an analysis time of a few minutes per library and with a low number of false positives. Our analysis of how programmers use library interface declarations furthermore reveals some practical limitations of the TypeScript type system.
We present a pragmatic approach to check correctness of TypeScript declaration files with respect to JavaScript library implementations. The key idea in our algorithm is that many declaration errors can be detected by an analysis of the library initialization state combined with a light-weight static analysis of the library function code.
Our experimental results demonstrate the effectiveness of the approach: it has found 142 errors in the declaration files of 10 libraries, with an analysis time of a few minutes per library and with a low number of false positives. Our analysis of how programmers use library interface declarations furthermore reveals some practical limitations of the TypeScript type system.
Original language | English |
---|---|
Title of host publication | OOPSLA '14 Proceedings of the 2014 ACM International Conference on Object Oriented Programming Systems Languages & Applications |
Number of pages | 16 |
Publisher | Association for Computing Machinery |
Publication date | 2014 |
ISBN (Print) | 78-1-4503-2585-1/ |
DOIs | |
Publication status | Published - 2014 |
Event | ACM International Conference on Object Oriented Programming Systems Languages and Applications (OOPSLA) - Portland, United States Duration: 20 Oct 2014 → 25 Oct 2014 |
Conference
Conference | ACM International Conference on Object Oriented Programming Systems Languages and Applications (OOPSLA) |
---|---|
Country/Territory | United States |
City | Portland |
Period | 20/10/2014 → 25/10/2014 |