Legacy JavaScript systems lack type safety, making maintenance risky. While TypeScript can help, manually adding types is expensive. Previous automated typing research focuses on type inference but rarely addresses type checking setup, definition generation, bug identification, or behavioral correctness at repository scale. We present AgenticTyper, a Large Language Model (LLM)-based agentic system that addresses these gaps through iterative error correction and behavior preservation via transpilation comparison. Evaluation on two proprietary repositories (81K LOC) shows that AgenticTyper resolves all 633 initial type errors in 20 minutes, reducing manual effort from one working day.
Figures & tables
Figure 1. Three-phase typing approach. A flowchart diagram showing three sequential phases for automated typing. Phase 1 (Minimal Setup) includes enabling TypeScript, installing missing types packages, and fixing or suppressing type errors. Phase 2 (Full Coverage) enables noImplicitAny, adds definitions and annotations, and addresses new errors. Phase 3 (Strict Mode) enables strict mode, refactors for type safety, and performs regression testing. Thick arrows connect the phases sequentially.
Figure 2. Single-agent architecture for phase one and two. The hook preventing behavior changes is highlighted. A flowchart showing the workflow of a single agent. Starting from a code file at the top, errors flow to a coding agent. A hook triggers on file edits and sends back transpiled diff via a red dashed feedback arrow if there are any changes. When the agent finishes, a verification step is executed. If remaining errors exist, a red dashed feedback arrow returns to the agent. On success, the flow completes with a checkmark.
Repo
LOC
Type Errors
Necessary Suppressions
Additional Suppressions
Time
Cost
A
75K
570
327
+26 (+8.0%)
16:51 min
$22.85
B
6K
63
56
+0 (+0.0%)
3:06 min
$2.08
Total
81K
633
383
+26 (+6.8%)
19:57 min
$24.93
Table 1. Phase one results on two proprietary JavaScript repositories. Average of three runs each.