Unsafe return of an any typed value
-
<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)
-
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
-
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
-
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!
-
Hi, this forum is dead. Please ask your questions on the Quasar github discussions forum instead.