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

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! 😄

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store