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

Cannot use data properties in script when using Vue.extend #82

Closed
Cy-Tek opened this issue Aug 22, 2019 · 2 comments
Closed

Cannot use data properties in script when using Vue.extend #82

Cy-Tek opened this issue Aug 22, 2019 · 2 comments

Comments

@Cy-Tek
Copy link

Cy-Tek commented Aug 22, 2019

Describe the bug
When I have a template that is not using the class style of component, the parser complains about accessing data from either methods or computed properties. It does not complain when I convert the template to using vue-property-decorator

To Reproduce
Steps to reproduce the behavior:

  1. Make a component with a script section like
    <script lang="ts">
    import Vue from 'vue'
    
    export default Vue.extend({
      name: 'Test',
      data() {
        return {
          str: 'Hello world'
        }
      },
      computed: {
        getStr(): string {
          return this.str
        }
      }
    })
    </script>
  2. Run nuxt-ts dev
  3. See error

Expected behavior
I should be able to access the properties on data from either the computed or methods properties without using vue-property-decorator

Screenshots
Example:
image

@kevinmarrec
Copy link
Contributor

kevinmarrec commented Aug 23, 2019

@Cy-Tek This issue may happen when you have a computed property that has implicit return type, making other return types buggy.

Minimal component following your code
image

Issue happenning cause return type of authors is implicit

Fixed by providing the correct return type (IAuthor[]):
image

I suspect that your component code contains somewhere an implicit typing that make the issue happens.

@kevinmarrec
Copy link
Contributor

@Cy-Tek Can I close ?

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

2 participants