Subscribe on changes!

Wrong optional type in setup props for prop that default value is null

avatar
Apr 10th 2021

Version

3.0.11

Reproduction link

https://codesandbox.io/s/wonderful-frog-2wp60?file=/src/index.ts:0-189

Steps to reproduce

follow the link

import { defineComponent } from "vue";

defineComponent({
  props: {
    notUndefined: {
      type: Number,
      defualt: null
    }
  },
  setup(props) {
    props.notUndefined;
  }
});

What is expected?

notUndefined should not be optional

What is actually happening?

notUndefined is optional

avatar
Apr 10th 2021

need required:true option ?

avatar
Apr 10th 2021

need required:true option ?

In runtime it can't be undefined or just not in the keys, so I think required: true is just a workaround.

Also it may cause runtime warning.

image

avatar
Apr 11th 2021

defualt => default your spelling is incorrect.

avatar
Apr 11th 2021

defualt => default your spelling is incorrect.

Sorry for that😂