skip to main content
10.1145/2660193.2660215acmconferencesArticle/Chapter ViewAbstractPublication PagessplashConference Proceedingsconference-collections
research-article

Checking correctness of TypeScript interfaces for JavaScript libraries

Published: 15 October 2014 Publication History

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.

References

[1]
R. Chugh, D. Herman, and R. Jhala. Dependent types for JavaScript. In Proc. 27th ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications, 2012.
[2]
A. Feldthaus and A. Møller. Semi-automatic rename refactoring for JavaScript. In Proc. 28th ACM SIGPLAN Conference on Object Oriented Programming Systems Languages, and Applications, 2013.
[3]
M. Furr and J. S. Foster. Checking type safety of foreign function calls. ACM Transactions on Programming Languages and Systems, 30(4), 2008.
[4]
Google. GWT - JavaScript Native Interface, March 2013. http://www.gwtproject.org/doc/latest/DevGuideCodingBasicsJSNI.html.
[5]
Google. The Dart programming language specification, March 2014. https://www.dartlang.org/docs/spec/.
[6]
S. Guarnieri and V. B. Livshits. Gatekeeper: Mostly static enforcement of security and reliability policies for JavaScript code. In Proc. 18th USENIX Security Symposium, 2009.
[7]
S. H. Jensen, A. Møller, and P. Thiemann. Type analysis for JavaScript. In Proc. 16th International Static Analysis Symposium, 2009.
[8]
K. L. Knowles and C. Flanagan. Hybrid type checking. ACM Transactions on Programming Languages and Systems, 32(2), 2010.
[9]
B. S. Lerner, J. G. Politz, A. Guha, and S. Krishnamurthi. TeJaS: retrofitting type systems for JavaScript. In Proc. 9th Symposium on Dynamic Languages, 2013.
[10]
Microsoft. TypeScript language specification, February 2014. http://www.typescriptlang.org/Content/ TypeScript%20Language%20Specification.pdf.
[11]
M. Polishchuk, B. Liblit, and C. W. Schulze. Dynamic heap type inference for program understanding and debugging. In Proc. 34th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, 2007.
[12]
M. Sridharan, J. Dolby, S. Chandra, M. Schäfer, and F. Tip. Correlation tracking for points-to analysis of JavaScript. In Proc. 26th European Conference on Object-Oriented Programming, 2012.
[13]
V. St-Amour and N. Toronto. Experience report: applying random testing to a base type environment. In Proc. 18th ACM SIGPLAN International Conference on Functional Programming, 2013.
[14]
B. Steensgaard. Points-to analysis in almost linear time. In Proc. 23rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, 1996.

Cited By

View all

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Conferences
OOPSLA '14: Proceedings of the 2014 ACM International Conference on Object Oriented Programming Systems Languages & Applications
October 2014
946 pages
ISBN:9781450325851
DOI:10.1145/2660193
  • cover image ACM SIGPLAN Notices
    ACM SIGPLAN Notices  Volume 49, Issue 10
    OOPSLA '14
    October 2014
    907 pages
    ISSN:0362-1340
    EISSN:1558-1160
    DOI:10.1145/2714064
    • Editor:
    • Andy Gill
    Issue’s Table of Contents
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected].

Sponsors

In-Cooperation

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 15 October 2014

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. program analysis
  2. type checking

Qualifiers

  • Research-article

Conference

SPLASH '14
Sponsor:

Acceptance Rates

OOPSLA '14 Paper Acceptance Rate 52 of 186 submissions, 28%;
Overall Acceptance Rate 268 of 1,244 submissions, 22%

Upcoming Conference

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)42
  • Downloads (Last 6 weeks)3
Reflects downloads up to 14 Sep 2024

Other Metrics

Citations

Cited By

View all

View Options

Get Access

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media