Cannot use @Prop() Decorator
See original GitHub issueHi, 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:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top 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 >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
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:
@smholsen This PR solves the issue… https://github.com/kaorun343/vue-property-decorator/pull/246
I hope that @kaorun343 checks it soon