Closed
Description
Vue version
3.3.2
Link to minimal reproduction
Steps to reproduce
import { defineProps, withDefaults } from 'vue'
function fakeComponent<T extends string | null>() {
return withDefaults(defineProps<{
test: T
}>(), {
test: () => 'test' as T // this is error
})
}
Or
<script lang="ts" generic="T extends string | null">
withDefaults(defineProps<{
test: T
}>(), {
test: () => 'test' as T // this is error
})
</script>
What is expected?
The error not to be showing, like the non generic version:
import { defineProps, withDefaults } from 'vue'
function fakeComponent() {
return withDefaults(defineProps<{
test: string | null
}>(), {
test: () => 'test' as T
})
}
Or
<script lang="ts" generic="T extends string | null">
withDefaults(defineProps<{
test: T
}>(), {
test: () => 'test' as T
})
</script>
What is actually happening?
withDefaults
is not accepting the generic type
System Info
No response
Any additional comments?
No response