types: mixin and extends typing on data and setup (#2404)

close #2350
This commit is contained in:
Carlos Rodrigues
2020-12-04 21:06:34 +00:00
committed by GitHub
parent 0af8c8d972
commit 6684c6334d
2 changed files with 72 additions and 3 deletions

View File

@@ -445,10 +445,18 @@ describe('with mixins', () => {
const MixinD = defineComponent({
mixins: [MixinA],
data() {
//@ts-expect-error computed are not available on data()
expectError<number>(this.dC1)
//@ts-expect-error computed are not available on data()
expectError<string>(this.dC2)
return {
d: 4
}
},
setup(props) {
expectType<string>(props.aP1)
},
computed: {
dC1(): number {
return this.d + this.a
@@ -467,6 +475,34 @@ describe('with mixins', () => {
required: true
}
},
data(vm) {
expectType<number>(vm.a)
expectType<number>(vm.b)
expectType<number>(vm.c)
expectType<number>(vm.d)
// should also expose declared props on `this`
expectType<number>(this.a)
expectType<string>(this.aP1)
expectType<boolean | undefined>(this.aP2)
expectType<number>(this.b)
expectType<any>(this.bP1)
expectType<number>(this.c)
expectType<number>(this.d)
return {}
},
setup(props) {
expectType<string>(props.z)
// props
expectType<string>(props.aP1)
expectType<boolean | undefined>(props.aP2)
expectType<any>(props.bP1)
expectType<any>(props.bP2)
expectType<string>(props.z)
},
render() {
const props = this.$props
// props