Categories
Vue Answers

How to fix the “Property does not exist on type ‘Vue'” error?

Spread the love

Sometimes, we want to fix the "Property does not exist on type ‘Vue’" error.

In this article, we’ll look at how to fix the "Property does not exist on type ‘Vue’" error.

How to fix the "Property does not exist on type ‘Vue’" error?

To fix the "Property does not exist on type ‘Vue’" error, we can add the missing property into TypeScript type definition file.

For instance, in vue-file-import.d.ts, we add

declare module "*.vue" {
  import Vue from "vue";
  export default Vue;
}

to add the type definition for .vue files by exporting Vue as a default export within the declare module statement.

Conclusion

To fix the "Property does not exist on type ‘Vue’" error, we can add the missing property into TypeScript type definition file.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

2 replies on “How to fix the “Property does not exist on type ‘Vue'” error?”

Where do you put it, if it’s not “Vue”?

In my case: Property 'PriceFormat' does not exist on type 'DigitalVoucherInput'.ts(2339)

Let’s say DigitalVoucherInput.ts look like this:
typescript/html
<template>
<span>{{ price | PriceFormat }}</span>
</template>
<script lang="ts">
import { Component, Vue, Prop } from "vue-property-decorator";
import priceFormat from '@/filters/priceFormat';
@Component({
filters: {
PriceFormat: priceFormat,
},
})
export default class DigitalVoucherInput extends Vue {
public price = 100;
}
</script>

Where is the corresponding d.ts file and how to edit it?

Leave a Reply

Your email address will not be published. Required fields are marked *