🤖 AI Summary
This study investigates whether AI systems are more prone than human developers to misuse or overuse unsafe type constructs—such as `any`—in TypeScript, thereby compromising type safety. Employing empirical software engineering methods, the research combines large-scale code mining with statistical analysis to systematically compare how AI-generated code and human-written code utilize type constructs in real-world projects. The findings reveal, for the first time, that AI employs the `any` type nine times more frequently than humans and more often resorts to advanced patterns that circumvent type checking. Paradoxically, pull requests containing AI-generated code achieve a 1.8× higher acceptance rate, highlighting a tension between high adoption rates and latent type-related risks. These results provide empirical evidence to inform governance strategies for type safety in AI-assisted programming.
📝 Abstract
Artificial Intelligence (AI) increasingly automates various parts of the software development tasks. Although AI has enhanced the productivity of development tasks, it remains unstudied whether AI essentially outperforms humans in type-related programming tasks, such as employing type constructs properly for type safety, during its tasks. Moreover, there is no systematic study that evaluates whether AI agents overuse or misuse the type constructs under the complicated type systems to the same extent as humans. In this study, we present the first empirical analysis to answer these questions in the domain of TypeScript projects. Our findings show that, in contrast to humans, AI agents are 9x more prone to use the'any'keyword. In addition, we observed that AI agents use advanced type constructs, including those that ignore type checks, more often compared to humans. Surprisingly, even with all these issues, Agentic pull requests (PRs) have 1.8x higher acceptance rates compared to humans for TypeScript. We encourage software developers to carefully confirm the type safety of their codebases whenever they coordinate with AI agents in the development process.