Reputation: 329
I am trying to convert the js code to ts. My attempt is as below.
<script lang="ts">
export default {
data() {
return {
isShow: false as boolean
}
},
methods: {
openCalendar() : void {
this.isShow = true;
},
}
}
</script>
But when I run the app it's throws an error in the console saying Property isShow
does not exist on type {open(): void;}
. Where I was got wrong and how can I fix it?
Upvotes: 0
Views: 2273
Reputation: 1
To get types inference try to wrap your options with Vue.extend({})
:
<script lang="ts">
import Vue from 'vue'
export default Vue.extend({
data() {
return {
isShow: false as boolean
}
}
methods: {
openCalendar() : void {
this.isShow = true;
},
},
})
</script>
Upvotes: 5