Maxim Mironjuk
-
January 02, 2025
A list component that renders rows regardless of whether they represent users, products or orders is a classic case for TypeScript generics, yet Vue components long lacked the right syntax for it. Since Vue 3.3, script setup supports its own generic attribute, letting props, emits and slots bind type-safely to a generic type parameter without falling back on any or unknown. The result is components that behave like generic functions: written once, but usable for arbitrary, concrete item types with full autocompletion.