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 / vue-async-computed Property 'foo' does not exist on type 'CombinedVueInstance<Vue, {...} #100

Open
DGollings opened this issue Jul 17, 2020 · 2 comments

Comments

@DGollings
Copy link

Note that I don't use the vue/typescript class decoration style, so didn't have much luck with the examples in #25

No matter what I do, spent the entire afternoon on this because I really like vue-async-computed ;), I get the error Property 'foo' does not exist on type 'CombinedVueInstance.

'Annoyingly', everything works just fine, it's just an error.

console.log(this), I can see the computed property there. Can interact with it, recompute, etc.. Like I said, things work.

Installed using npm, using version 3.8.2, initialized centrally using

import AsyncComputed from "vue-async-computed";
Vue.use(AsyncComputed)

(possibly relevant, I also import import "regenerator-runtime/runtime")

used in a .vue file like this:
(note: adding default or lazy:true changed nothing)

asyncComputed: {
    async foo(): Promise<something> {
      try {
        return Promise.resolve("bar");
      } catch (err) {
            return Promise.reject(err);
      }
    },
  },

The whole async/try/catch is the reason for importing regenerator-runtime/runtime. Removing async and just returning "bar" doesnt help.

And any reference to this.foo elsewhere results in that error, again, it'll work, but with an error.

For now I've added

      // @ts-ignore
      // prettier-ignore

but would

I've been able to 'break' the typescript support, resulting in an error that 'asyncComputed' itself is unknown when it comes the Vue object. So something is working.

Any idea what could be the cause?

@doits
Copy link

doits commented Oct 8, 2020

I think there is no automatic solution. You can duplicate the definitions like this #25 (comment) though, then it will be picked up.

@relief-melone
Copy link

I think this should be possible. It has been done with mixins before
https://github.com/ktsn/vue-typed-mixins/blob/master/src/index.ts

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

No branches or pull requests

3 participants