question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot use @Prop() Decorator

See original GitHub issue

Hi, I am in the midst of trying to rewrite my hobby project from js to ts, and I am currently trying to use the @Prop decorator in my component using the code below;

<template>
...
</template>
<script lang="ts">

    import Vue from "vue";
    import Component from "vue-class-component";
    import {Prop} from "vue-property-decorator";

    @Component({
        name: "Additional"
    })

    export default class Additional extends Vue {
        notes: string = '';

        @Prop() value: any;
 }
</script>

But I get the following error in my IDE;

Argument of type 'Additional' is not assignable to parameter of type 'Vue'.
  Types of property '$options' are incompatible.
    Type 'Vue.ComponentOptions<import("/{...}/node_modules/vue/types/vue").Vue, import("/{...}/node_modules/vue/types/options").DefaultData<import("/{...}/node_modules/vue/types/vue").Vue>, import("/Users/{username}/proj...' is not assignable to type 'import("/{...}/node_modules/vue-property-decorator/node_modules/vue/types/options").ComponentOptions<import("/{...}/node_modules/vue-property-decorator/node_modules/vue/types/vue").Vue, import("/{...}/node_...'.
      Types of property 'methods' are incompatible.
        Type 'import("/{...}/node_modules/vue/types/options").DefaultMethods<import("/{...}/node_modules/vue/types/vue").Vue> | undefined' is not assignable to type 'import("/{...}/node_modules/vue-property-decorator/node_modules/vue/types/options").DefaultMethods<import("/{...}/node_modules/vue-property-decorator/node_modules/vue/types/vue").Vue> | undefined'.
          Type 'import("/{...}/node_modules/vue/types/options").DefaultMethods<import("/{...}/node_modules/vue/types/vue").Vue>' is not assignable to type 'import("/{...}/node_modules/vue-property-decorator/node_modules/vue/types/options").DefaultMethods<import("/{...}/node_modules/vue-property-decorator/node_modules/vue/types/vue").Vue>'.
            Index signatures are incompatible.
              Type '(this: import("/{...}/node_modules/vue/types/vue").Vue, ...args: any[]) => any' is not assignable to type '(this: import("/{...}/node_modules/vue-property-decorator/node_modules/vue/types/vue").Vue, ...args: any[]) => any'.
                The 'this' types of each signature are incompatible.
                  Type 'Vue' is missing the following properties from type 'Vue': $router, $route, $storeVetur(2345)

Do you have any suggestions or ideas on what is going wrong here? Any tips on where to start debugging this issue?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
asbermudezcommented, Aug 26, 2019

You can use the ‘props’ property in the ‘Component’ decorator. Like:

@Component({ props: (whatever config based on official Vue documentation) });

This should solve the problem for now. The issue of that PR is that there are some libraries of Vue (even official) that extend the base type and the decorators don’t inherit from them but from the ‘core’, so then you get that error that you’re missing something.

Let me know if it works for you 😃

On Mon, Aug 26, 2019, 17:33 Simon Olsen notifications@github.com wrote:

I am not using a modified Vue type though, what is the supported type, and how can I make sure that I am on the supported version?

On Mon, 26 Aug 2019, 17:07 Aram Sabatés, notifications@github.com wrote:

@smholsen https://github.com/smholsen This PR solves the issue… #246 https://github.com/kaorun343/vue-property-decorator/pull/246

I hope that @kaorun343 https://github.com/kaorun343 checks it soon

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub < https://github.com/kaorun343/vue-property-decorator/issues/250?email_source=notifications&email_token=AANEIATXI3DJ7BG6LS6WYATQGPWS5A5CNFSM4IPQJTBKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5EVBAQ#issuecomment-524898434 , or mute the thread < https://github.com/notifications/unsubscribe-auth/AANEIAWAAO77SFZXHEGXMN3QGPWS5ANCNFSM4IPQJTBA

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kaorun343/vue-property-decorator/issues/250?email_source=notifications&email_token=ALAVF44WKRMKB5RRO6XO3NDQGPZT7A5CNFSM4IPQJTBKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5EXQRA#issuecomment-524908612, or mute the thread https://github.com/notifications/unsubscribe-auth/ALAVF452BMSLBKSZTC2QXJDQGPZT7ANCNFSM4IPQJTBA .

1reaction
asbermudezcommented, Aug 26, 2019

@smholsen This PR solves the issue… https://github.com/kaorun343/vue-property-decorator/pull/246

I hope that @kaorun343 checks it soon

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot use property decorator @Prop in vue - Stack Overflow
I think the problem is with your import statement. import Vue from 'vue'; import Component from 'vue-class-component'; import { Prop } from ...
Read more >
vue-property-decorator - npm
Start using vue-property-decorator in your project by running `npm ... It's not supported to define each default property like @Prop() prop ...
Read more >
Python Property Decorator - TutorialsTeacher
The @property decorator is a built-in decorator in Python for the property() function. Use @property decorator on any method in the class to...
Read more >
@prop | typegoose
Should act like the @index class decorator, but without options. Example: ... Set which class to use for Reference (this cannot be inferred...
Read more >
Start Implementing Your Own Typescript Property Decorators
A property decorator cannot be used in a declaration file, ... We want to censor some of the fields when someone is calling...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found