Skip to content

feat(typescript): specify "this" type for "watchLoading" #360

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

Merged
merged 1 commit into from
Aug 30, 2018

Conversation

Kocal
Copy link
Contributor

@Kocal Kocal commented Aug 17, 2018

Hi,

I'm currently migrating my Vue components from basic syntax to decorated syntax by using vue-class-component and vue-property-decorator, and I faced a problem.

<template>
  <div>...</div>
</template>

<script lang="ts">
import gql from 'graphql-tag';
import { Component, Vue } from 'vue-property-decorator';

@Component({
  apollo: {
    language: {
      query: gql`{ ... }`,
      variables() {
        return {
          language: this.language,
        };
      },
      error() {
        this.error = true;
      },
      watchLoading(isLoading) {
        this.loading = isLoading;
      },
    },
  },
})
export default class HelloWorld extends Vue {
  language = 'fr';
  error = false;
  loading = false;
}
</script>

When compiling this code, I have the following error Property 'loading' does not exist on type 'Vue'. (see Travis).
I first thought it was a problem of decorators or of TypeScript itself, but I had no errors for this.language and this.error. 🤔

Adding this: ApolloVueThisType<V> makes everything works ✨

@Kocal
Copy link
Contributor Author

Kocal commented Aug 17, 2018

Hum, I'm having the same problem with result() method but I'm not able to fix it this time... 😅

Kocal/vue-class-components-with-this-usage-in-decorators@55592cc and https://travis-ci.com/Kocal/vue-class-components-with-this-usage-in-decorators/builds/82144890#L455, thanks!

@Akryum Akryum merged commit 986d590 into vuejs:master Aug 30, 2018
@Kocal Kocal deleted the feat/watch-loading-this branch October 7, 2018 17:49
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.

2 participants