Skip to content
Discussion options

You must be logged in to vote

You've hit a real limit, not a syntax mistake. defineProps resolves its type at compile time, and it can't resolve a type parameter, so TProps & { ... } fails with "Unresolvable type reference". Adding generic="TProps" on its own doesn't help.

The way through is @vue-ignore:

<script setup lang="ts" generic="TProps extends Record<string, any>">
const props = defineProps</* @vue-ignore */ TProps & {
  component: unknown
}>()
</script>

That tells the compiler to skip runtime prop generation for that type and keeps the type surface for TS, which is the part you actually want for Intellisense.

The tradeoff: only your own props get a runtime declaration. I compiled the above with @vue/compiler-sfc

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@webJose
Comment options

@webJose
Comment options

Answer selected by webJose
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants