Typescript: Property ‘foo’ does not exist on type ‘Vue’

Sami C.
Oct 12, 2021

--

Today I was plagued with an annoying bug! I was banging my head for a while!

Let’s get into it! For example purposes, I will show you a snippet of how my code looked like:

export default Vue.extend({
name: 'justaname',
data() {
return {
currentSlide: 0 as number
};
},
computed: {
internalOpen: {
get(): boolean {
return this.value;
},
set(val) {
(this as any).$emit('input', false);
},
},
},
});

This resulted in the following error:

Typescript: Property ‘currentSlide’ does not exist on type ‘Vue’

When I added a type on my setter val the error was no longer present!

set(val: boolean) {
(this as any).$emit('input', false);
},

Basically if your setter is missing a type you’ll get this strange error.

Hopefully this helps some people out there! 😄

--

--