Do Machine Learning Models Produce TypeScript Types That Type Check?

02/23/2023
by   Ming-Ho Yee, et al.
0

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, (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 69

READ FULL TEXT

page 7

page 9

page 14

page 15

page 16

page 20

page 21

page 23

research
09/10/2021

Solver-based Gradual Type Migration

Gradually typed languages allow programmers to mix statically and dynami...
research
06/05/2020

Using an interpretable Machine Learning approach to study the drivers of International Migration

Globally increasing migration pressures call for new modelling approache...
research
05/25/2023

Type Prediction With Program Decomposition and Fill-in-the-Type Training

TypeScript and Python are two programming languages that support optiona...
research
07/10/2021

Approximate Normalization and Eager Equality Checking for Gradual Inductive Families

Harnessing the power of dependently typed languages can be difficult. Pr...
research
05/18/2015

DopeLearning: A Computational Approach to Rap Lyrics Generation

Writing rap lyrics requires both creativity to construct a meaningful, i...
research
11/11/2020

Guiding user annotations for units-of-measure verification

This extended abstract reports on previous work of the CamFort project i...
research
10/06/2019

Migration through Machine Learning Lens – Predicting Sexual and Reproductive Health Vulnerability of Young Migrants

In this paper, we have discussed initial findings and results of our exp...

Please sign up or login with your details

Forgot password? Click here to reset