You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Vetur cannot find the type when using PropType<User> in the referenced component. TemplateInterpolationService is set to true as well as validate templateProps.
Reproducible Case
Use "vetur.experimental.templateInterpolationService": true,
Use "vetur.validation.templateProps": true,
Create file Hello.vue
<template>
<div>
Hello, {{ user.name }}
</div>
</template>
<script lang="ts">
import { defineComponent } from '@nuxtjs/composition-api'
import type { PropType } from '@nuxtjs/composition-api'
type User = {
name: string;
}
export default defineComponent({
props: {
user: {
type: Object as PropType<User>,
required: true
}
},
setup () {
return {}
}
})
</script>
This works fine if I use an anonymous type. Tried to trick the compiler to omit the actual type without any success.
type User = {name: string}
const trick = <T extends unknown>() => () => undefined as unknown as {
[K in keyof T]: T[K]
}
const TrickedUser = trick<User>()
export default defineComponent({
props: {
user: {
type: Object as PropType<ReturnType<typeof TrickedUser>>,
required: true
}
},
setup () {
return {}
}
})
This gives the following component type props:
But vetur is still complaining, in this case it cannot find TrickedUser
The text was updated successfully, but these errors were encountered:
dietergoetelen
changed the title
Template interpolation service in combination with templateProps
Type error when Template interpolation service in combination with templateProps is set to true
Sep 23, 2020
Info
Problem
Vetur cannot find the type when using
PropType<User>
in the referenced component. TemplateInterpolationService is set to true as well as validate templateProps.Reproducible Case
"vetur.experimental.templateInterpolationService": true,
"vetur.validation.templateProps": true,
Hello.vue
Greeting.vue
This works fine if I use an anonymous type. Tried to trick the compiler to omit the actual type without any success.
This gives the following component type props:
But vetur is still complaining, in this case it cannot find
TrickedUser
The text was updated successfully, but these errors were encountered: