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

Completions broken in setup function return object literal for vue #43612

Open
yoyo930021 opened this issue Apr 9, 2021 · 3 comments
Open

Completions broken in setup function return object literal for vue #43612

yoyo930021 opened this issue Apr 9, 2021 · 3 comments
Labels
Domain: Completion Lists The issue relates to showing completion lists in an editor Experience Enhancement Noncontroversial enhancements Experimentation Needed Someone needs to try this out to see what happens Suggestion An idea for TypeScript
Milestone

Comments

@yoyo930021
Copy link

yoyo930021 commented Apr 9, 2021

Bug Report

🔎 Search Terms

completions return 'object literal shorthands'

🕗 Version & Regression Information

  • This changed between versions 4.2.0 and 4.2.3

⏯ Playground Link

Playground link with relevant code

💻 Code

import { defineComponent } from '@vue/runtime-core'

export default defineComponent({
  name: 'App',
  setup () {
    const waitingForAutocomplete = true;

    const a = {
      wait // get `waitingForAutocomplete`
    }

    return {
      wait // don't get any completion
    }
  }
})

🙁 Actual behavior

We can't get any completion for object literal shorthand in setup return.

🙂 Expected behavior

Like common object literal shorthand.

Ref: #41259 #41539
From: vuejs/vetur#2544

@andrewbranch
Copy link
Member

It’s because setup gets a contextual return type of Promise<RawBindings> | RawBindings | RenderFunction | void from defineComponent. RawBindings is actually inferred from that position itself, so it doesn’t contribute, but the Promise itself is contributing:

image

We should probably carve out a rule to not give object literal member completions for members of the global Promise type, which might be enough to fix this one... but in general, these shorthand property completions aren’t going to work anywhere there’s a contextual type.

@andrewbranch andrewbranch self-assigned this Apr 9, 2021
@andrewbranch andrewbranch added Domain: Completion Lists The issue relates to showing completion lists in an editor Needs Investigation This issue needs a team member to investigate its status. labels Apr 9, 2021
@andrewbranch andrewbranch removed their assignment Apr 9, 2021
@andrewbranch andrewbranch added Experimentation Needed Someone needs to try this out to see what happens Experience Enhancement Noncontroversial enhancements Suggestion An idea for TypeScript and removed Needs Investigation This issue needs a team member to investigate its status. labels Apr 9, 2021
@andrewbranch andrewbranch added this to the Backlog milestone Apr 9, 2021
@Zenthae
Copy link

Zenthae commented May 12, 2021

any news on this ?

@Andarist
Copy link
Contributor

these shorthand property completions aren’t going to work anywhere there’s a contextual type.

Couldn't those things be concatenated with contextual type members being prioritized?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Domain: Completion Lists The issue relates to showing completion lists in an editor Experience Enhancement Noncontroversial enhancements Experimentation Needed Someone needs to try this out to see what happens Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

4 participants