Skip to content
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

Use typescript info for interpolation completion #1446

Merged
merged 22 commits into from
Mar 4, 2020

Conversation

ktsn
Copy link
Member

@ktsn ktsn commented Oct 1, 2019

fix #1129

To use ts.LanguageService#getCompletionsAtPosition to get completion list for interpolation expression. It also combines previous completion info so that the behavior should be backward compatible.

There is a known issue when an interpolation expression is invalid. Our source map cannot handle expression position, then provides wrong completion in that case. We need to think how we handle invalid expression in the future.
-> Fixed via #1448

<template>
  <div>{{ obj. }}</div> <!-- Cannot provide `obj.value` completion -->
</template>

<script lang="ts">
import Vue from 'vue'

export default Vue.extend({
  data() {
    return {
      obj: { value: '' }
    }
  }
})
</script>

@sabifa
Copy link

sabifa commented Mar 2, 2020

I would love to see that feature! Could we get a small update about it, please? 😄

@octref
Copy link
Member

octref commented Mar 4, 2020

I got completion resolve as well:

image

@octref
Copy link
Member

octref commented Mar 4, 2020

Still need to fix the empty completion case {{ | }} but this is much better now.

Copy link
Member

@octref octref left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those are the only things I'm not haapy about. Other than that this seems good so I'm merging.

@@ -35,7 +35,7 @@ export default {
* My count
*/
count () {
return this.$store.state.count
return 42;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to change this because otherwise the typing would be wrong and cause the whole this to have any type...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably because of the return type annotation problem... 😢
https://vuejs.org/v2/guide/typescript.html#Annotating-Return-Types

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JSDocs return type doesn't work either. Sad..

@@ -26,7 +26,7 @@ export default {
},
computed: {
count () {
return this.$store.state.count
return 42;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to change this because otherwise the typing would be wrong and cause the whole this to have any type...

@octref octref merged commit 4b153d2 into master Mar 4, 2020
@octref octref added this to the February 2020 milestone Mar 4, 2020
@octref octref deleted the template-interpolation-completion branch March 5, 2020 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Template interpolation completion doesn't work with object's props
3 participants