License: Creative Commons Attribution 4.0 International license (CC BY 4.0)
When quoting this document, please refer to the following
DOI: 10.4230/LIPIcs.ECOOP.2023.37
URN: urn:nbn:de:0030-drops-182307
URL: http://dagstuhl.sunsite.rwth-aachen.de/volltexte/2023/18230/
Go to the corresponding LIPIcs Volume Portal


Yee, Ming-Ho ; Guha, Arjun

Do Machine Learning Models Produce TypeScript Types That Type Check?

pdf-format:
LIPIcs-ECOOP-2023-37.pdf (1.0 MB)


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.

BibTeX - Entry

@InProceedings{yee_et_al:LIPIcs.ECOOP.2023.37,
  author =	{Yee, Ming-Ho and Guha, Arjun},
  title =	{{Do Machine Learning Models Produce TypeScript Types That Type Check?}},
  booktitle =	{37th European Conference on Object-Oriented Programming (ECOOP 2023)},
  pages =	{37:1--37:28},
  series =	{Leibniz International Proceedings in Informatics (LIPIcs)},
  ISBN =	{978-3-95977-281-5},
  ISSN =	{1868-8969},
  year =	{2023},
  volume =	{263},
  editor =	{Ali, Karim and Salvaneschi, Guido},
  publisher =	{Schloss Dagstuhl -- Leibniz-Zentrum f{\"u}r Informatik},
  address =	{Dagstuhl, Germany},
  URL =		{https://drops.dagstuhl.de/opus/volltexte/2023/18230},
  URN =		{urn:nbn:de:0030-drops-182307},
  doi =		{10.4230/LIPIcs.ECOOP.2023.37},
  annote =	{Keywords: Type migration, deep learning}
}

Keywords: Type migration, deep learning
Collection: 37th European Conference on Object-Oriented Programming (ECOOP 2023)
Issue Date: 2023
Date of publication: 11.07.2023
Supplementary Material: Software (ECOOP 2023 Artifact Evaluation approved artifact): https://doi.org/10.4230/DARTS.9.2.5
Software (Artifact Evaluation approved artifact): https://doi.org/10.5281/zenodo.7662708
Software (code repository): https://github.com/nuprl/TypeWeaver archived at: https://archive.softwareheritage.org/swh:1:dir:34399ede560aa59cfe736bf9994185d54b8c2e7e


DROPS-Home | Fulltext Search | Imprint | Privacy Published by LZI