`props` object does not define optional properties without default
Version
3.0.9
Reproduction link
<template>
<h1>{{ keys }}</h1>
</template>
<script>
import { defineComponent } from 'vue'
export default defineComponent({
props: {
notDefined: String,
defined: {
type: String,
default: undefined,
},
},
setup(props) {
const keys = Object.keys(props);
// keys: ['defined']
// instead of
// keys: ['notDefined', 'defined']
return {
keys
}
},
});
</script>
Steps to reproduce
- Declare an optional
prop
:foo: String
- do
'foo in props
- it will be false because
foo
is not defined in theprops
object
What is expected?
props
should contain that property foo
defined
What is actually happening?
props
is an empty object {}
Duplicate of https://github.com/vuejs/vue-next/issues/3288