playwright
playwright copied to clipboard
[Feature] Derive the prop type from the Vue/Svelte component
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
})
- [x] Svelte
- [ ] Vue 3
- [ ] Vue 2
Vue released some type helpers that could solve this issue: https://www.npmjs.com/package/vue-component-type-helpers