Skip to content

Get component prop type when using defineProps with TypeScript in production #11079

Discussion options

You must be logged in to vote

This is by design. It's mentioned at https://vuejs.org/api/sfc-script-setup.html#type-only-props-emit-declarations.

The main use of the type option is to validate prop values. That validation isn't performed in production, so the type is discarded to reduce the bundle size.

There are a handful of cases where the type serves another purpose, not just validating prop values. For example, for a Boolean, the value is interpreted differently to determine whether it is true or false. In those cases the type needs to be retained, even in production.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@OlaAlsaker
Comment options

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