#16935·quasar

Add TypeScript generics to component types

Author: yusufkandemirCreated Feb 27, 2024Updated Sep 22, 2026
Labelskind/feature 💡

Needs #16934

People generally recognize it as <script setup lang="ts" generic="T">. But, as Quasar components are not SFCs, nor written in TypeScript, introducing generics is different. We have to start manually authoring TS files, and then add generics on top, which requires #16934.

Adding this feature would allow components like QSelect, QTable, etc. to have type-safety, autocomplete, etc. in their certain props and slots. Here is an example:

xml
<template>
  <q-select
    :options="options"
    :option-value="option => option.id"
    option-label="name"
  />
  <!-- ^^^ `name` doesn't have auto-complete, `option` is seen as any -->
  <!-- With the addition of generics, both props will be aware of the type of `options` -->
</template>

<script setup lang="ts">
const options = [
  { id: 1, name: 'test' }
];
</script>