An Exploratory Study of Decorators in the TypeScript Programming Language
Abstract
Decorators are a feature of the TypeScript language that allows the configuration of additional metadata on code elements, such as members, methods, and the class definition itself. It has been officially supported only since version 5.0. This feature also exists in other languages, such as Java annotations and C# attributes. To understand and further study how developers use decorators, we conducted an exploratory study on 30 real-world, open-source, and popular projects hosted on GitHub. To extract the characteristics of decorators from the analyzed projects, the DSniffer (Decorators Sniffer) was developed. It can collect source code metrics’ values dedicated to metadata configuration. Among the results obtained, it was observed that 46% of the projects use decorators, among which we highlight some popular ones such as Angular and Visual Studio Code. We also noted that decorators use at most four parameters, but these can be quite complex objects, occupying up to 84 lines of source code. Thus, the study reveals high numbers of decorators in the projects and many repeated metadata configurations. This can negatively impact the readability of the source code and compromise maintenance. The study carried out in this work can serve as a basis for defining reference values or implementing a software visualization approach.References
Borges, H. and Tulio Valente, M. (2018). What’s in a github star? understanding repository starring practices in a social coding platform. Journal of Systems and Software, 146:112–129.
Chidamber, S. R. and Kemerer, C. F. (1991). Towards a metrics suite for object-oriented design. In Proceedings..., pages 197–211, New York. ANNUAL ACM SIGPLAN CONFERENCE ON OBJECT-ORIENTED PROGRAMMING SYSTEM, LANGUAGES, AND APPLICATIONS, ACM.
Lanza, M. and Marinescu, R. (2006). Object-oriented metrics in practice: using software metrics to characterize, evaluate, and improve the design of object-oriented systems. Springer.
Lima, P., Guerra, E., Meirelles, P., Kanashiro, L., Silva, H., and Silveira, F. (2018). A metrics suite for code annotation assessment. Journal of Systems and Software, 137:163 – 183.
Lima, P., Melegati, J., Gomes, E., Pereira, N. S., Guerra, E., and Meirelles, P. (2023). Cadv: A software visualization approach for code annotations distribution. Information and Software Technology, 154:107089.
Nagappan, M., Zimmermann, T., and Bird, C. (2013). Diversity in software engineering research. In Proceedings of the 2013 9th Joint Meeting on Foundations of Software Engineering, ESEC/FSE 2013, pages 466–476, New York, NY, USA. ACM.
Rosenwasser, D. (2023). Announcing typescript 5.0 rc. [link].
Teixeira, R., Guerra, E., Lima, P., Meirelles, P., and Kon, F. (2018). Does it make sense to have application-specific code conventions as a complementary approach to code annotations? In Proceedings of the 3rd ACM SIGPLAN International Workshop on Meta-Programming Techniques and Reflection, pages 15–22.
Valente, M. T. (2020). Engenharia de software moderna. Princípios e Práticas para Desenvolvimento de Software com Produtividade, 1.
Chidamber, S. R. and Kemerer, C. F. (1991). Towards a metrics suite for object-oriented design. In Proceedings..., pages 197–211, New York. ANNUAL ACM SIGPLAN CONFERENCE ON OBJECT-ORIENTED PROGRAMMING SYSTEM, LANGUAGES, AND APPLICATIONS, ACM.
Lanza, M. and Marinescu, R. (2006). Object-oriented metrics in practice: using software metrics to characterize, evaluate, and improve the design of object-oriented systems. Springer.
Lima, P., Guerra, E., Meirelles, P., Kanashiro, L., Silva, H., and Silveira, F. (2018). A metrics suite for code annotation assessment. Journal of Systems and Software, 137:163 – 183.
Lima, P., Melegati, J., Gomes, E., Pereira, N. S., Guerra, E., and Meirelles, P. (2023). Cadv: A software visualization approach for code annotations distribution. Information and Software Technology, 154:107089.
Nagappan, M., Zimmermann, T., and Bird, C. (2013). Diversity in software engineering research. In Proceedings of the 2013 9th Joint Meeting on Foundations of Software Engineering, ESEC/FSE 2013, pages 466–476, New York, NY, USA. ACM.
Rosenwasser, D. (2023). Announcing typescript 5.0 rc. [link].
Teixeira, R., Guerra, E., Lima, P., Meirelles, P., and Kon, F. (2018). Does it make sense to have application-specific code conventions as a complementary approach to code annotations? In Proceedings of the 3rd ACM SIGPLAN International Workshop on Meta-Programming Techniques and Reflection, pages 15–22.
Valente, M. T. (2020). Engenharia de software moderna. Princípios e Práticas para Desenvolvimento de Software com Produtividade, 1.
Published
2025-09-22
How to Cite
MARTINS, Luiz; FRANCISCO, Phyllipe; MEIRELLES, Paulo.
An Exploratory Study of Decorators in the TypeScript Programming Language. In: WORKSHOP ON SOFTWARE VISUALIZATION, EVOLUTION AND MAINTENANCE (VEM), 13. , 2025, Recife/PE.
Anais [...].
Porto Alegre: Sociedade Brasileira de Computação,
2025
.
p. 58-68.
DOI: https://doi.org/10.5753/vem.2025.14563.
