[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-detail-121672-en":3,"doc-seo-121672-105":30,"detail-sidebar-cat-0-en-105":91},{"code":4,"msg":5,"data":6},0,"success",{"doc_id":7,"user_id":8,"nickname":9,"user_avatar":10,"doc_module":4,"category_id":11,"category_name":12,"doc_title":13,"doc_description":14,"doc_content":15,"file_id":16,"file_url":17,"file_type":18,"file_size":19,"view_count":4,"is_deleted":4,"is_public":20,"is_downloadable":20,"audit_status":20,"page_count":21,"language":22,"language_code":23,"site_id":24,"html_lang":23,"table_of_contents":25,"faqs":26,"seo_title":27,"seo_description":14,"update_tm":28,"read_time":29},121672,687197100911,"Himbo","https://ap-avatar.wpscdn.com/avatar/a000239b6f1da00475?x-image-process=image/resize,m_fixed,w_180,h_180&k=1785132997149421697",8,"Research & Report","Do Machine Learning Models Produce TypeScript Types That Type Check - TypeWeaver 研究评估","Type migration adds static types to untyped code to obtain compile-time assurance. TypeScript enables gradual type migration, but adding types in large industry codebases can require years of manual work. Research explores machine learning to predict TypeScript type annotations with high per-annotation accuracy; however, accuracy alone may not guarantee successful compilation. This work asks whether an automatic migration tool can generate code that passes the TypeScript type checker and introduces TypeWeaver to evaluate that capability.","arXiv :2302 . 12 163v2 [ cs . SE] 11 Jul 2023  \nDo Machine Learning Models Produce TypeScript Types That Type Check?  \nMing-Ho Yee !   \nNortheastern University, Boston, MA, USA  \nArjun Guha !   \nNortheastern University, Boston, MA, USA Roblox Research, San Mateo, CA, USA  \n~~ Abstract ~~  \nType 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?  \nWe 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.  \nWe 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.  \n2012 ACM Subject Classification Software and its engineering → Source code generation; General and reference → Evaluation; Theory of computation → Type structures  \nKeywords and phrases Type migration, deep learning  \n(Placeholder to maintain spacing)  \nSupplementary Material Software (ECOOP 2023 Artifact Evaluation approved artifact) : [https://doi.org/10.4230/DARTS.9.2.5](https://doi.org/10.4230/DARTS.9.2.5)  \nSoftware (Artifact Evaluation approved artifact): [https://doi.org/10.5281/zenodo.7662708](https://doi.org/10.5281/zenodo.7662708)  \nSoftware (code repository): [https://github.com/nuprl/TypeWeaver](https://github.com/nuprl/TypeWeaver)[ ](https://github.com/nuprl/TypeWeaver)archived at swh:1:dir:34399ede560aa59cfe736bf9994185d54b8c2e7e  \nFunding This work is partially supported by the National Science Foundation grant CCF-2102291 .  \nAcknowledgements We thank Northeastern Research Computing and the New England Research Cloud for providing computing resources; and Leif Andersen, Luna Phipps-Costin, Donald Pinckney, and the anonymous reviewers for their feedback.  \n2 Do Machine Learning Models Produce TypeScript Types That Type Check?  \n 1  Introduction  \nGradual typing allows programmers to freely mix statically and dynamically typed code. This makes it possible to add static types to a large program incrementally, and slowly reap the benefits of static typing without requiring a complete rewrite of an existing codebase at once [22, 46 , 48] . Over the past decade, gradual typing has proliferated, and there are now gradually typed versions of several mainstream languages [6, 7, 11, 14, 31, 33, 37, 48, 52] .  \nTypeScript is a widely used gradually typed language, and a syntactic superset of JavaScript. Programmers can write their code in TypeScript, benefit from static typing, and then compile to JavaScript. However, the process of migrating an untyped JavaScript p","cbCaikWE7jRQTCFG","https://ap.wps.com/l/cbCaikWE7jRQTCFG","pdf",826387,1,28,"English","en",105,"# Introduction\n## Gradual typing and TypeScript migration\n## Motivation for ML-based type migration\n## Research question and tool overview\n# TypeWeaver evaluation\n## Models used in the evaluation\n## Dataset and type-checking results","[{\"question\":\"为什么仅靠预测单个 TypeScript 类型的准确率可能会产生误导？\",\"answer\":\"因为迁移不仅需要给出类型注释，还要求生成的代码能通过 TypeScript 类型检查器。单注释高准确率不等价于整体能成功类型检查。\"},{\"question\":\"TypeWeaver 能自动完成哪些与类型迁移相关的步骤？\",\"answer\":\"TypeWeaver 可导入依赖项目所需的类型，将 JavaScript 模块迁移为 TypeScript 记法，在需要时插入预测的类型注释，并在需要时拒绝非类型预测。\"},{\"question\":\"在评估中，迁移后的代码通过类型检查的比例是多少？\",\"answer\":\"在 513 个 JavaScript 包的数据集上，使用最佳类型预测模型时，只有 21% 的包能通过类型检查，但 69% 的文件能成功通过类型检查。\"}]","Do Machine Learning Models Produce TypeScript Types That Type Check - TypeWeaver 研究评估 | PDF",1785806133,71,{"code":4,"msg":31,"data":32},"ok",{"site_id":24,"language":23,"slug":33,"title":13,"keywords":34,"description":14,"schema_data":35,"social_meta":86,"head_meta":88,"extra_data":90,"updated_unix":28},"do-machine-learning-models-produce-typescript-types-that-type-check-typeweaver-study","",{"@graph":36,"@context":85},[37,54,68],{"@type":38,"itemListElement":39},"BreadcrumbList",[40,44,48,51],{"item":41,"name":42,"@type":43,"position":20},"https://docshare.wps.com","Home","ListItem",{"item":45,"name":46,"@type":43,"position":47},"https://docshare.wps.com/document/","Document",2,{"item":49,"name":12,"@type":43,"position":50},"https://docshare.wps.com/document/research-report/",3,{"item":52,"name":13,"@type":43,"position":53},"https://docshare.wps.com/document/do-machine-learning-models-produce-typescript-types-that-type-check-typeweaver-study/121672/",4,{"url":52,"name":13,"@type":55,"author":56,"headline":13,"publisher":58,"fileFormat":61,"inLanguage":23,"description":14,"dateModified":62,"datePublished":62,"encodingFormat":61,"isAccessibleForFree":63,"interactionStatistic":64},"DigitalDocument",{"name":9,"@type":57},"Person",{"url":41,"name":59,"@type":60},"DocShare","Organization","application/pdf","2026-08-04",true,{"@type":65,"interactionType":66,"userInteractionCount":4},"InteractionCounter",{"@type":67},"ViewAction",{"@type":69,"mainEntity":70},"FAQPage",[71,77,81],{"name":72,"@type":73,"acceptedAnswer":74},"为什么仅靠预测单个 TypeScript 类型的准确率可能会产生误导？","Question",{"text":75,"@type":76},"因为迁移不仅需要给出类型注释，还要求生成的代码能通过 TypeScript 类型检查器。单注释高准确率不等价于整体能成功类型检查。","Answer",{"name":78,"@type":73,"acceptedAnswer":79},"TypeWeaver 能自动完成哪些与类型迁移相关的步骤？",{"text":80,"@type":76},"TypeWeaver 可导入依赖项目所需的类型，将 JavaScript 模块迁移为 TypeScript 记法，在需要时插入预测的类型注释，并在需要时拒绝非类型预测。",{"name":82,"@type":73,"acceptedAnswer":83},"在评估中，迁移后的代码通过类型检查的比例是多少？",{"text":84,"@type":76},"在 513 个 JavaScript 包的数据集上，使用最佳类型预测模型时，只有 21% 的包能通过类型检查，但 69% 的文件能成功通过类型检查。","https://schema.org",{"og:url":52,"og:type":87,"og:title":13,"og:site_name":59,"og:description":14},"article",{"robots":89,"canonical":52},"index,follow",{"doc_id":7,"site_id":24},{"code":4,"msg":5,"data":92},[93,97,101,105,110,115,120,123,128,131,135],{"id":20,"doc_module":4,"doc_module_name":46,"category_name":94,"show_sort_weight":95,"slug":96},"Story & Novel",90,"story-novel",{"id":47,"doc_module":4,"doc_module_name":46,"category_name":98,"show_sort_weight":99,"slug":100},"Literature",80,"literature",{"id":53,"doc_module":4,"doc_module_name":46,"category_name":102,"show_sort_weight":103,"slug":104},"Exam",70,"exam",{"id":106,"doc_module":4,"doc_module_name":46,"category_name":107,"show_sort_weight":108,"slug":109},5,"Comic",60,"comic",{"id":111,"doc_module":4,"doc_module_name":46,"category_name":112,"show_sort_weight":113,"slug":114},6,"Technology",50,"technology",{"id":116,"doc_module":4,"doc_module_name":46,"category_name":117,"show_sort_weight":118,"slug":119},7,"Healthcare",40,"healthcare",{"id":11,"doc_module":4,"doc_module_name":46,"category_name":12,"show_sort_weight":121,"slug":122},30,"research-report",{"id":124,"doc_module":4,"doc_module_name":46,"category_name":125,"show_sort_weight":126,"slug":127},9,"Religion & Spirituality",20,"religion-spirituality",{"id":126,"doc_module":4,"doc_module_name":46,"category_name":129,"show_sort_weight":126,"slug":130},"World Cup","world-cup",{"id":132,"doc_module":4,"doc_module_name":46,"category_name":133,"show_sort_weight":132,"slug":134},10,"Lifestyle","lifestyle",{"id":136,"doc_module":4,"doc_module_name":46,"category_name":137,"show_sort_weight":106,"slug":138},19,"General","general"]