store action this[key] = value. error tips: Type 'any' is not assignable to type 'never' #1511
Answered
by
posva
coderyqy
asked this question in
Help and Questions
-
error tips: Type 'any' is not assignable to type 'never' import { defineStore } from "pinia";
type InfoName =
| "nickname"
| "phone"
| "avatar"
| "bg"
| "introduce"
| "city"
export const useUserStore = defineStore("userInfo", {
state: () => ({
avatar: "",
bg: "",
city: "",
introduce: "",
nickname: "",
username: "",
}),
actions: {
updataUserInfo(infoName: InfoName, value: any) {
// Type 'any' is not assignable to type 'never'
this[infoName] = value;
},
},
}); |
Beta Was this translation helpful? Give feedback.
Answered by
posva
Aug 3, 2022
Replies: 1 comment
-
It's because of the |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
posva
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's because of the
phone
value: