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

Typescript issue with @vue/composition-api > beta.6 #74

Closed
blocka opened this issue Aug 28, 2020 · 6 comments · Fixed by #115
Closed

Typescript issue with @vue/composition-api > beta.6 #74

blocka opened this issue Aug 28, 2020 · 6 comments · Fixed by #115
Labels
enhancement New feature or request

Comments

@blocka
Copy link

blocka commented Aug 28, 2020

After upgrading composition api, I'm getting the following issue:

<template>
<div v-if="data">
   {{data.foo}} <!-- Property 'foo' does not exist on type 'Ref<{ foo: string; } | undefined> -->
</template>

I traced it down to the definition of IResponse

interface IResponse {
    data?: Ref......
}

removing the ? makes it work again.

it most likely has to do with vuejs/core#1682 which was implemented in beta.7

I couldn't see that any of the examples given fit this one, but perhaps this is another breaking example

@darrenjennings
Copy link
Collaborator

Need to test compat with 1.x of composition api, we're only testing up to 0.6 right now. https://github.com/Kong/swrv/blob/master/tests/test-compat-all.sh#L6

@darrenjennings darrenjennings added the enhancement New feature or request label Aug 28, 2020
@darrenjennings
Copy link
Collaborator

@blocka do you still have this issue? Do we need to return data without the ??

@blocka
Copy link
Author

blocka commented Nov 8, 2020

I have to first remember which project we had this issue on :)

@travis-r6s
Copy link

I still get this issue - "swrv": "^0.8.1"

@darrenjennings
Copy link
Collaborator

@blocka @thetre97 maybe you could tell me how I could reproduce here since I am not sure how to get the same error: https://github.com/darrenjennings/swrv-playground

image

@travis-r6s
Copy link

travis-r6s commented Nov 14, 2020

Apologies, I should have said that I am actually using Nuxt + '@nuxtjs/composition-api'... So may be something to do with that. I can get the proper typings by doing something like return { data, error } as { data: Ref<PaginatedCollection> } instead (although accessing data inside setup does show the correct type).

If it's completely unrelated, I will remove my comments...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants