Skip to content

[Feature] Derive the prop type from the Vue/Svelte component  #17206

@sand4rt

Description

@sand4rt

Would be great if the type of prop could be derived from the component (mount(Component)) instead of explicitly defining it through the generic (mount<Props>). Vue test utils also managed to do this: https://github.com/vuejs/test-utils/blob/main/test-dts/mount.d-test.ts#L60.

<script lang="ts" setup>
  defineProps<{ title: string }>();
</script>
<template>
  <button>{{ title }}</button>
</template>
test('should not work', async ({ mount }) => {
  await mount(Button, { props: {} }) // Should throw a type error because title is a required prop
})
  • Svelte
  • Vue 3
  • Vue 2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions