-
-
Notifications
You must be signed in to change notification settings - Fork 594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Property 'xxx' does not exist on type 'CombinedVueInstance<Record<never, any> & Vue, object, object, object, Record<never, any>>' #2131
Comments
Same here. Big problem... |
Please provide reproducible case. |
If I don't have case, debugging is too hard. If yes, I think #1707 or vuejs/vue#8721 ? |
Yes in one project, no in another. Both of those issues relate to Typescript projects. Again, this is not Typescript, straight Javascript, so I cannot add type annotations. This is the error I'm getting for one particular component:
It's showing in the CombinedVueInstance my computed properties, my data properties and I assume my data properties, respectively. However, it looks like it's not recognizing the data properties ("object, object, object...") This component doesn't have any methods referenced in the HTML. Another component does have methods (click events, etc.) that are also not recognized. The CombinedVueInstance doesn't even seem to show an option for methods. |
@jtsom you need to add annotations in JS code too. Vetur will only be able to automatically infer types for trivial things like literals and others. Anything more complicated needs annotations. And yes, you can annotate stuff in JS - use JSDoc for that. if you are not doing that then don't expect things to work flawlessly. |
I just found this blog post that should explain it more: https://blog.usejournal.com/type-vue-without-typescript-b2b49210f0b Any non-trivial props, data options, computed values, methods, etc. need to be annotated. |
That document says "We have to provide @type annotations for properties which are impossible infer statically." Except, my data properties are all simple strings, so should not need types (see above). Also, in another small application, I am not seeing this error, and the data properties are also simple types: Not to mention, what changed in a .1 update that would cause this big change in functionality. |
You need to know that if you are missing some annotations in other places in the Vue file, that can break type checking in that file in general. So add all annotations where needed or simplify your file until it doesn't reproduce. If nothing helps then create a repro as we can't be guessing forever here. |
How would you annotate Vuex getters? on the getter itself in the store? on the ...mapGetters( .. ) call? |
It's a bug on upsteam. |
Well, for me, temporary solution is to downgrade to the previous version until this is fixed. |
I've downgraded to the |
You can't downgrade to fix it. |
If this work in v0.26.0? |
I downgraded to v0.26.0 and all of those errors went away. |
Yes, it is working on |
I think the problem is not what I think. |
Believe me, I am trying to. A simple app that is structured the same as my more complicated app won't show the error. Simple components in my large app has several errors, but a more complicated component has none. They have the same data, methods, computed sections, and make heavy use of Vuex getters. Here's the complicated component, and how the data() function is defined - it's composed of many properties - numbers, strings, arrays of various items, object with various items - and no @type information: and here is the simpler component with only 3 data items, all strings: note the simple one indicates; "data?: unknown" and the other shows "data: DataDef..." |
Here is a reproducible component. If you change the computed to return a string, the error will go away. As it is, it shows these errors:
Adding type annotations (assuming I'm doing it correct) does not help: |
This problem is #1707 and vuejs/vue#8721 |
Weird. Because v0.26.0 did not have that error, as as far as I know I did not have that option turned on. Either way, turning that option off did eliminate the error using v.0.26.1 Hopefully this will get fixed soon. (I assume by "template interpolation service" you mean like: {{ card.label }} ? or is that something else? ) |
I added Other issues are all upstream and there's nothing I can do from Vetur side. Either TS need to fix circularity or you need to type computed property manually. |
I study this case. I find the only way when typescript 3.9. =_= I will study when I have time. |
In case others arrive, here's a summary of the current problem, the minimal reproducible example, and what you can do to try and fix it: #1707 (comment) |
this worked for me |
set |
this solves everything. thanks |
Was wondering where this is set but found it: Go to Settings and search for Vetur Validation. |
Well, I am not sure, it does work for JS validations. |
Vetur still works well while using class-style components. Because of a smoother transition to Vue 3, we wanted to migrate to options/composition API and having the above mentioned issues. Interestingly - computed is fine, but adding |
If you use Vue3, there's no problem. |
I don't use TS. I'd love to have completion in templates. JSDoc doesn't seem to do anything. |
JSDoc can help you. |
@yoyo930021 can you guide me with the JSDoc? None of the annotations work and I still get the error. /** @returns { {filteredTags: object} } **/
data() {
return {
/** @type {object} **/
filteredTags: {
categories: new filterProperty(),
media: new filterProperty(),
orientation: new filterProperty(),
camera: new filterProperty(),
},
} |
@yoyo930021 @octref Cloned veturpack to get better idea what's going on and to fiddle around. The repo worked even when I copied parts of the code like props and template but not when I copied all of it. Seems like it works when I get rid of |
It appears even when I use |
|
Setting return types for all functions inside computed solved it for me. |
Sometimes I get the error even when I set return types. Disappears after I comment out props. |
I get below error: And also Solution: <script lang="ts">
import Vue from 'vue';
// Add below code sample to your component
declare module 'vue/types/vue' {
interface Vue {
fields: Field[];
doThisClick: () => void;
doThisInput: () => void;
}
}
export default Vue.extend({
name: 'form-builder',
data() {
return {
fields: [
{
name: 'name',
events: { click: this.doThisClick, input: this.doThisInput },
},
],
};
},
methods: {
doThisClick(field: Field): void {
console.log('click', field, event);
},
doThisInput(field: Field): void {
console.log('Input', field, event);
},
},
});
</script>
|
For anyone encountering this issue. I have seen it creep up a few times when using typescript. I'm not sure if it's an issue with Normally the issue would look something like this... TS2339: Property 'title' does not exist on type 'CombinedVueInstance<Vue, unknown, unknown, unknown, Readonly<Record<never, any>>>'. The solution is to define some types so that Vue is aware of what is being defined in the component and those corresponding return types. The issue happens when for some reason Vue can't figure it out automatically and needs some help. Example:interface IData {
title: string;
}
interface IProps {
}
interface IComputed {
}
interface IMethods {
} Define the componentexport default Vue.extend<IData, IMethods, IComputed, IProps>({
data() {
title: "Some title"
}
}); Please also note that the order in which you pass your type parameters is important. The order follows DMCP (Data, Methods, Computed, Props). Hope this helps. If anyone has any other specific questions, please email me. My email is on my Github profile. |
I fix it by adding this line in settings.json |
Please refer https://vuejs.github.io/vetur/guide/FAQ.html#property-xxx-does-not-exist-on-type-combinedvueinstance I will lock this issue. If you have a problem, please open a new issue with template. |
Info
Problem
Updating Vetur into the last release I get an error in each property in
html component
,computed
,methods
,events
, etc.This is my method:
Reproducible Case
Not reproducible by a project.
The text was updated successfully, but these errors were encountered: