Do Machine Learning Models Produce TypeScript Types That Type Check? (Artifact)

Authors Ming-Ho Yee , Arjun Guha



PDF
Thumbnail PDF

Artifact Description

DARTS.9.2.5.pdf
  • Filesize: 0.58 MB
  • 3 pages

Document Identifiers

Author Details

Ming-Ho Yee
  • Northeastern University, Boston, MA, USA
Arjun Guha
  • Northeastern University, Boston, MA, USA
  • Roblox Research, San Mateo, CA, USA

Acknowledgements

We thank Northeastern Research Computing and the New England Research Cloud for providing computing resources; and Donald Pinckney and the anonymous reviewers for their feedback.

Cite AsGet BibTex

Ming-Ho Yee and Arjun Guha. Do Machine Learning Models Produce TypeScript Types That Type Check? (Artifact). In Special Issue of the 37th European Conference on Object-Oriented Programming (ECOOP 2023). Dagstuhl Artifacts Series (DARTS), Volume 9, Issue 2, pp. 5:1-5:3, Schloss Dagstuhl – Leibniz-Zentrum für Informatik (2023)
https://doi.org/10.4230/DARTS.9.2.5

Artifact

Artifact Evaluation Policy

The artifact has been evaluated as described in the ECOOP 2023 Call for Artifacts and the ACM Artifact Review and Badging Policy

Abstract

Type migration is the process of adding types to untyped code to gain assurance at compile time. TypeScript and other gradual type systems facilitate type migration by allowing programmers to start with imprecise types and gradually strengthen them. However, adding types is a manual effort and several migrations on large, industry codebases have been reported to have taken several years. In the research community, there has been significant interest in using machine learning to automate TypeScript type migration. Existing machine learning models report a high degree of accuracy in predicting individual TypeScript type annotations. However, in this paper we argue that accuracy can be misleading, and we should address a different question: can an automatic type migration tool produce code that passes the TypeScript type checker? We present TypeWeaver, a TypeScript type migration tool that can be used with an arbitrary type prediction model. We evaluate TypeWeaver with three models from the literature: DeepTyper, a recurrent neural network; LambdaNet, a graph neural network; and InCoder, a general-purpose, multi-language transformer that supports fill-in-the-middle tasks. Our tool automates several steps that are necessary for using a type prediction model, including (1) importing types for a project’s dependencies; (2) migrating JavaScript modules to TypeScript notation; (3) inserting predicted type annotations into the program to produce TypeScript when needed; and (4) rejecting non-type predictions when needed. We evaluate TypeWeaver on a dataset of 513 JavaScript packages, including packages that have never been typed before. With the best type prediction model, we find that only 21% of packages type check, but more encouragingly, 69% of files type check successfully.

Subject Classification

ACM Subject Classification
  • Software and its engineering → Source code generation
  • General and reference → Evaluation
  • Theory of computation → Type structures
Keywords
  • Type migration
  • deep learning

Metrics

  • Access Statistics
  • Total Accesses (updated on a weekly basis)
    0
    PDF Downloads

References

  1. Creative Commons. Attribution 4.0 International (CC BY 4.0). https://creativecommons.org/licenses/by/4.0/. Accessed: 2023-05-25.
  2. Docker Inc. Docker. https://www.docker.com/. Accessed: 2023-05-25.
  3. Podman. Podman. https://podman.io/. Accessed: 2023-05-25.
  4. The Linux Foundation. Open Container Initiative. https://opencontainers.org/. Accessed: 2023-05-25.
Questions / Remarks / Feedback
X

Feedback for Dagstuhl Publishing


Thanks for your feedback!

Feedback submitted

Could not send message

Please try again later or send an E-mail