Jon Sud
Jon Sud

Reputation: 11671

Property does not exist on the type in vue-class-component

I got an error in my TypeScript component file that a prop doesn't exist, but I declared the prop exactly as described in the vue-class-component documentation example.

Property 'propMessage' does not exist on type 'MyComponent'.Vetur(2339)

How do I fix this?

screenshot of error

Upvotes: 10

Views: 4568

Answers (1)

JKL
JKL

Reputation: 1070

The documentation you linked states:

Following is the example written in Babel. If you are looking for TypeScript version, it's in the example directory.

Example:

<script lang="ts">
    import Vue from 'vue';
    import { Component } from 'vue-class-component';

    const AppProps = Vue.extend({
      props: {
        propMessage: String
      }
    })

    @Component
    export default class YourComponent extends AppProps {

        get something() {
            return this.propMessage;
        }
    }
</script>

Upvotes: 2

Related Questions