Subscribe on changes!

Typescript "defineProps" removes "Boolean" type in production

avatar
Nov 11th 2021

Version

3.2.21

Reproduction link

github.com

Steps to reproduce

Set type "boolean" in the type annotation of "defineProps" macro, like this:

<script setup lang="ts">
defineProps<{ callable?: boolean }>();
</script>

run npm run build command

What is expected?

Component props to be inferred as

props: {
    callable: Boolean, // or {type: Boolean, required: false}
  }

What is actually happening?

Component props is inferred as

props: {
    callable: null,
  }

The reason being is that I can't use callable shortcut on a component instead of :callable="true".

This works in development thought (and was hard to spot on production :)))