Checking Correctness of TypeScript Interfaces for JavaScript Libraries

Asger Feldthaus, Anders Møller

Research output: Contribution to book/anthology/report/proceedingArticle in proceedingsResearchpeer-review

35 Citations (Scopus)

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.
Original languageEnglish
Title of host publicationOOPSLA '14 Proceedings of the 2014 ACM International Conference on Object Oriented Programming Systems Languages & Applications
Number of pages16
PublisherAssociation for Computing Machinery
Publication date2014
ISBN (Print)78-1-4503-2585-1/
DOIs
Publication statusPublished - 2014
EventACM International Conference on Object Oriented Programming Systems Languages and Applications (OOPSLA) - Portland, United States
Duration: 20 Oct 201425 Oct 2014

Conference

ConferenceACM International Conference on Object Oriented Programming Systems Languages and Applications (OOPSLA)
Country/TerritoryUnited States
CityPortland
Period20/10/201425/10/2014

Fingerprint

Dive into the research topics of 'Checking Correctness of TypeScript Interfaces for JavaScript Libraries'. Together they form a unique fingerprint.

Cite this