-
-
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
Intellisense not always working in computed properties #1707
Comments
I reproduce this bug on |
It's connected with this https://vuejs.org/v2/guide/typescript.html#Annotating-Return-Types Even if you don't use TS, Vetur does and not annotating return type of computed kind of breaks |
@cerino-ligutom when the And we go into recursive loop.... |
Then how come that's not the case in |
I actually don't know. I never thought about it, but it's probably because |
@F0rsaken And how is it connecting to |
@Soresu props are also deeply nested in generics and mapped with index signatures. I'm only guessing, but you aren't not using But actually, props don't use this.... so maybe it's something different.... |
If |
I have been fighting with similar issue last few days. My problem was slightly different. When i defined props inside of SFC, intellisense just stopped working. Using |
Duplicate of #1509 |
Writing this once for all. The bug is that when you have TS upstream issue, and it seems TS wouldn't fix it: microsoft/TypeScript#30854 (comment) Your solutions:
But I'm not using TS! Why should I care?Vetur uses TypeScript to figure out the type of your Vue component and provide all kinds of language features (completion, diagnostic error), even for Vue+JS components. Of course you can turn off the diagnostic error, but in return you will not get many of the features brought to you by TypeScript. |
It's not very discoverable at the end of some random issue. As I said elsewhere, it would be good to make this prominent. Either by having a pinned issue or including in documentation. |
I created a PR for adding this in the FAQ: #2250 |
This seems related but I'm using ts so I'm not sure what todo at this point. If it's unrelated please let me know and I'll open a seperate issue.
The last suggestion doesn't seem to help, or maybe I'm doing it wrong? I tried both ways I know of returning a type and neither seems to fix the Vetur issue yet it does show the type in intellisense. I have |
I'm having the same problem as @OmgImAlexis |
But how do I annotate computed with setter? computed: {
/** @returns {array} */
fullItems () {
return this.items.concat(this.selected);
},
open: {
get() {
return this.value;
},
set(val) {
this.$emit('input', val);
}
}
} I tried adding JSDoc above |
Haven't tried but I would guess something like this: computed: {
/** @returns {array} */
fullItems () {
return this.items.concat(this.selected);
},
open: {
/** @return {string} *//
get() {
return this.value;
},
/** @param {string} val *//
set(val) {
this.$emit('input', val);
}
}
} |
Ah I see, so I have to add JSDoc to the setter as well. Thank you |
we now have auto completion and type checking in all components now see vuejs/vetur#1707
if the computed attribute contains the mapState of vuex,How to add jsdoc? |
...for any property change. Disables ts-ignore rule as a workaround for vuejs/vetur#1707 (comment)
* feat: make chart update automatically... ...for any property change. Disables ts-ignore rule as a workaround for vuejs/vetur#1707 (comment) * chore: update wrapper for zchart * Format code with prettier * chore: skip ts-ignore check * Format code with prettier --------- Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
Info
Problem
Intellisense is not working when the computed property returns a reference from this, and the component has props, even its empty. I belive this is the same as #1509 , but the return part is not visible in the picture.
Reproducible Case
You can check the example repo, I've changed Counter.vue file
The text was updated successfully, but these errors were encountered: