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.
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?
Take a look at https://v2.vuejs.org/v2/guide/typescript.html#Augmenting-Types-for-Use-with-Plugins