`props.XXX.validator` + `setup()` explode TypeScript compiler.
Version
3.0.11
Reproduction link
https://github.com/kuanyui/vue-3-0-11-bug-reproduce-props-and-setup
Steps to reproduce
When props.XXX.validator
and setup(props, ctx)
are used simultaneously, all props
will explode and tsc
boom. (though data.XXX
are safe.)
Try to remove one of them, compilation will pass.
import { defineComponent } from 'vue';
export default defineComponent({
props: {
bystander: { type: String, required: false }, // (Mere an innocent bystander)
msg: {
type: String,
default: '[msg]',
validator: (x: string) => x.length !== 0 // [[[[[1. Remove this validator
},
size: {
type: Number,
validator: function (x: number) { return x <= 100 } // and this validator]]]]]
},
},
data () {
return {
numData: 111
}
},
computed: {
computedNumData (): string { return this.numData + '' },
computedSize (): string { return this.size + '' },
computedBystander (): string { return this.bystander + '' },
},
methods: {
onClick () {
window.alert(this.msg)
window.alert(this.bystander)
},
},
setup (props, ctx) { return {} } // [[[[[2. Or remove this setup(props)]]]]]
});
What is expected?
No explosion.
What is actually happening?
Exploded.
Art is an explosion.