Highly illogical, Kirk: spotting type mismatches in the large despite broken contracts, unsound types, and too many linters - Inria - Institut national de recherche en sciences et technologies du numérique Accéder directement au contenu
Article Dans Une Revue Proceedings of the ACM on Programming Languages Année : 2022

Highly illogical, Kirk: spotting type mismatches in the large despite broken contracts, unsound types, and too many linters

Joshua Hoeflich
Robert Bruce Findler
Manuel Serrano

Résumé

The DefinitelyTyped repository hosts type declarations for thousands of JavaScript libraries. Given the lack of formal connection between the types and the corresponding code, a natural question is are the types right? An equally important question, as DefinitelyTyped and the libraries it supports change over time, is how can we keep the types from becoming wrong? In this paper we offer Scotty, a tool that detects mismatches between the types and code in the Definitely-Typed repository. More specifically, Scotty checks each package by converting its types into contracts and installing the contracts on the boundary between the library and its test suite. Running the test suite in this environment can reveal mismatches between the types and the JavaScript code. As automation and generality are both essential if such a tool is going to remain useful in the long term, we focus on techniques that sacrifice completeness, instead preferring to avoid false positives. Scotty currently handles about 26% of the 8006 packages on DefinitelyTyped (61% of the packages whose code is available and whose test suite passes). Perhaps unsurprisingly, running the tests with these contracts in place revealed many errors in Definitely-Typed. More surprisingly, despite the inherent limitations of the techniques we use, this exercise led to one hundred accepted pull requests that fix errors in DefinitelyTyped, demonstrating the value of this approach for the long-term maintenance of DefinitelyTyped. It also revealed a number of lessons about working in the JavaScript ecosystem and how details beyond the semantics of the language can be surprisingly important. Best of all, it also revealed a few places where programmers preferred incorrect types, suggesting some avenues of research to improve TypeScript.

Dates et versions

hal-03920363 , version 1 (03-01-2023)

Identifiants

Citer

Joshua Hoeflich, Robert Bruce Findler, Manuel Serrano. Highly illogical, Kirk: spotting type mismatches in the large despite broken contracts, unsound types, and too many linters. Proceedings of the ACM on Programming Languages, 2022, 6 (OOPSLA2), pp.479-504. ⟨10.1145/3563305⟩. ⟨hal-03920363⟩
26 Consultations
0 Téléchargements

Altmetric

Partager

Gmail Facebook X LinkedIn More