Do Machine Learning Models Produce TypeScript Types That Type Check?
Not on the map. Why?
Abstract (arXiv)
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% of packages type check, but more encouragingly, 69% of files type check successfully.
Key facts. Cited by 6 papers in the map (data through 14 Oct 2026). First posted on arXiv 23 Feb 2023.
Builds on
No reference list yet.
Built on by
Citing papers per year: 2023: 3; 2024: 1; 2025: 0; 2026: 2.
6 papers.
- 2023StarCoder: may the source be with you!cited by 799
- 2023Can It Edit? Evaluating the Ability of Large Language Models to Follow Code Editing Instructionscited by 48
- 2023Type Prediction With Program Decomposition and Fill-in-the-Type Trainingcited by 6
- 2024Understanding How CodeLLMs (Mis)Predict Types with Activation Steeringcited by 5
- 2026AgenticTyper: Automated Typing of Legacy Software Projects Using Agentic AIcited by 2
- 2026Verifier-Guided Code Translation via Meta-Step Decodingcited by 2
- 2026Verifier-Guided Code Translation via Meta-Step Decoding17 May 2026
- 2026AgenticTyper: Automated Typing of Legacy Software Projects Using Agentic AI21 Feb 2026
- 2024Understanding How CodeLLMs (Mis)Predict Types with Activation Steering2 Apr 2024
- 2023Can It Edit? Evaluating the Ability of Large Language Models to Follow Code Editing Instructions11 Dec 2023
- 2023Type Prediction With Program Decomposition and Fill-in-the-Type Training25 May 2023
- 2023StarCoder: may the source be with you!9 May 2023