Property does not exist on the type in vue-class-component
See original GitHub issueI created new vue with typescript application using latest @vue/cli (v3).
When I use component decorator from vue-class-component
with computed
/props
/methods
, I got an error:
Property 'count' does not exist on type 'HelloWorld'.Vetur(2339)
Here my code:
<script lang="ts">
import { Prop, Vue } from "vue-property-decorator";
import Component from "vue-class-component";
@Component({
computed: {
count() {
return 'blabla';
}
}
})
export default class HelloWorld extends Vue {
@Prop() private msg!: string;
onClick() {
const y = this.count;
}
}
</script>
But according to the example it should be working fine. How do I fix this?
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Property does not exist on the type in vue-class-component
I got an error in my TypeScript component file ...
Read more >Property does not exist on the type in vue-class-component ...
[Solved]-Property does not exist on the type in vue-class-component-Vue.js ... If you are looking for TypeScript version, it's in the example directory.
Read more >Vue support breaks when extending Mixin (TypeScript)
And annoyingly, a workaround I tried doesn't work either, as TS reports errors: TS2339: Property does not exist on type 'CombinedVueInstance ...>>'. import...
Read more >TypeScript with Composition API - Vue.js
This is because Vue components are compiled in isolation and the compiler currently does not crawl imported files in order to analyze the...
Read more >Vue + Typescript, how do I annotate this? : r/vuejs - Reddit
Property 'style' does not exist on type 'Vue'. ... I use Vue Class Component to achieve this, might be a good alternative -...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
From the first example on the landing page
You need to write that getter differently.
Unfortunately, decorators (as they are proposed/implemented now) cannot modify the type that they decorate, which is why nothing you ever pass to the decorator will ever show up in a typesafe manner.
And the example that you mention has a workaround added for this specific issue
This is because decorator cannot change the class instance type. You have to declare the property type by yourself or use some decorator like vuex-class to map getters on class properties.