Do Developers Read Type Information? An Eye-Tracking Study on TypeScript
Samuel W. Flint, Robert Dyer, Bonita Sharif
TL;DR
This study uses an eye-tracking experiment with 22 analyzable participants to test whether TypeScript type annotations function as in-code documentation during code comprehension and bug localization. Across code samples that are annotated and unannotated, the results show that developers read type annotations infrequently and that their presence does not measurably alter reading behavior or task correctness; working memory exerts only weak, context-dependent effects. Participants nonetheless report positive perceptions of type annotations, suggesting potential benefits for tooling, language design, and education even if reading patterns are subtle. The work provides a replication package and implications for tool builders, communities, and future research into how developers seek and use type information, highlighting the need for deeper, qualitative studies and broader population analyses.
Abstract
Statically-annotated types have been shown to aid developers in a number of programming tasks, and this benefit holds true even when static type checking is not used. It is hypothesized that this is because developers use type annotations as in-code documentation. In this study, we aim to provide evidence that developers use type annotations as in-code documentation. Understanding this hypothesized use will help to understand how, and in what contexts, developers use type information; additionally, it may help to design better development tools and inform educational decisions. To provide this evidence, we conduct an eye tracking study with 26 undergraduate students to determine if they read type annotations during code comprehension and bug localization in the TypeScript language. We found that developers do not look directly at lines containing type annotations or type declarations more often when they are present, in either code summarization or bug localization tasks. The results have implications for tool builders to improve the availability of type information, the development community to build good standards for use of type annotations, and education to enforce deliberate teaching of reading patterns.
