No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Unsafe return of an any typed value

    Help
    4
    5
    6355
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • E
      Eaglorn last edited by

      <script lang="ts">
      import { defineComponent, ref, computed } from '@vue/composition-api';
      
      import { Store } from 'vuex';
      import { UserStateInterface } from '../store/user/state';
      
      export default defineComponent({
        name: 'MyLayout',
        setup(props, context) {
          let store = context.root.$store;
          let drawer = ref(false);
          let miniState = ref(true);
      
          console.log(store);
      
          let auth = computed(() => {
            return store.state.user;
          });
      
          function exit() {
            store.dispatch('user/exit');
          }
      
          return { auth, drawer, miniState };
        }
      });
      </script>
      
      let store: Store<any>
      Unsafe return of an any typed valueeslint@typescript-eslint/no-unsafe-return
      Unsafe member access .user on an any value.eslint@typescript-eslint/no-unsafe-member-access)
      
      dobbel 1 Reply Last reply Reply Quote 0
      • dobbel
        dobbel @Eaglorn last edited by dobbel

        @Eaglorn

        Isn’t that Vue3 code? Don’t think you will get support for that yet here. Anyways I saw this video that implements vuex 4 vue3 and typescript.

        https://www.youtube.com/watch?v=fh0VboqAc8k

        btw it’s a eslint error so you could comment that part of the code out to not be linted.

        https://stackoverflow.com/questions/27732209/turning-off-eslint-rule-for-a-specific-line

        1 Reply Last reply Reply Quote 0
        • D
          daniel last edited by

          I’ve the same problem. I am not using vue3! I created a Quasar project with typescript support. But when I am trying to access the store, I’ll get the same error.
          My current workaround is casting the state to the interface created in the index.ts file in the store folder. In your case the cast would look like this:

          (<StateInterface> this.$store.state).user
          
          1 Reply Last reply Reply Quote 1
          • M
            michael123 last edited by michael123

            When I try this my eslinter complains “This assertion is unnecessary since it does not change the type of the expression.” and prettier rewrites code to remove the assertion. Any suggestions?

            I’m converting a Quasar 1 JavaScript project to Quasar 2 Typescript. I’m getting a bunch of eslint errors “no-unsafe-member-access” and no-unsafe-call around this.$store.

            Did you get it to work?

            Thanks!

            1 Reply Last reply Reply Quote 0
            • dobbel
              dobbel last edited by

              @michael123

              Hi, this forum is dead. Please ask your questions on the Quasar github discussions forum instead.

              https://github.com/quasarframework/quasar/discussions

              1 Reply Last reply Reply Quote 0
              • First post
                Last post