I'm using a Vue.js app with typescript and I'm getting this error:
Property 'faillogout' does not exist on type '{ failed(): void; onSubmit(): void; }'.
101 | failed () {
This is the script part of my .vue file
<script lang="ts">
import store from '../store'
export default {
data () {
return {
email: '',
password: '',
faillogout: false
}
},
methods: {
failed () {
if (!store.state.idToken) {
this.faillogout = true
}
},
onSubmit () {
const formData = {
email: this.email,
password: this.password
}
console.log(formData)
store.dispatch('login', {email: formData.email, password: formData.password})
setTimeout(this.failed, 3000)
}
}
}
</script>
Any idea how this can be fixed please?
CodePudding user response:
Try wrapping your component with defineComponent() to allow TypeScript to properly infer types
import { defineComponent } from 'vue'
export default defineComponent({
data() {
return {
email: '',
password: '',
faillogout: false
}
},
})