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

[vti] handle component with async setup #2050

Closed
3 tasks done
cexbrayat opened this issue Jul 23, 2020 · 5 comments
Closed
3 tasks done

[vti] handle component with async setup #2050

cexbrayat opened this issue Jul 23, 2020 · 5 comments

Comments

@cexbrayat
Copy link
Member

cexbrayat commented Jul 23, 2020

  • I have searched through existing issues
  • I have read through docs
  • I have read FAQ

Info

  • Platform: macOS
  • VTI version: v0.0.4

Problem

When a component uses an async setup, then vti thinks the returned variable in setup are not available.

Reproducible Case

Repo: https://github.com/cexbrayat/vti-async

yarn
yarn dev
npx vti@0.0.4 diagnostics

Basic component:

<template>
  <div>{{ users }}</div>
</template>

<script lang="ts">
import { defineComponent, ref } from 'vue';

export default defineComponent({
  name: 'App',

  async setup() {
    const users = ref<Array<string>>(await Promise.resolve(['Cédric']);
    return { users };
  }
});
</script>

Error thrown:

File : /Users/ced-pro/Code/vue/vti-async/src/components/HelloWorld.vue
Error: Property 'users' does not exist on type 'ComponentPublicInstance<{}, Promise<{ users: Ref<string[]>; }>, {}, {}, {}, Record<string, any>, VNodeProps & AllowedComponentProps & ComponentCustomProps, ComponentOptionsBase<...>>'.
@yoyo930021
Copy link
Member

@ktsn
I think we need to unwrap Promise type,
Or modify upstream type definition?

@ktsn
Copy link
Member

ktsn commented Jul 24, 2020

It looks like an upstream type declaration issue.

@cexbrayat
Copy link
Member Author

The issue is till here with latest Vue 3.0.0-rc.10 and latest vti 0.0.10
@ktsn when you refer to an upstream issue, do you mean a core vue-next issue? Should we open an issue there?

@yoyo930021
Copy link
Member

The issue is till here with latest Vue 3.0.0-rc.10 and latest vti 0.0.10
@ktsn when you refer to an upstream issue, do you mean a core vue-next issue? Should we open an issue there?

I open a issue in vue-next.

@cexbrayat
Copy link
Member Author

Closing, as this has been fixed upstream

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants