typescript - ts(2769) אין התאמה של אוברלוד לקריאה הזו בעת שימוש ב-$patch על Ref באחסון Pinia
אני תקוע בבעיה עם TypeScript. הקוד באמת עובד, זה רק שגיאת IDE שמוצגת לי כשאני מנסה להשתמש בפונקציה $patch מ-Pinia.
הנה החנות שלי:
import { AuthenticationResult } from '@azure/msal-browser'
import { defineStore } from 'pinia'
import { ref } from 'vue'
const useAuthStore = defineStore('auth', () => {
const details = ref<AuthenticationResult>()
return { details }
})
export default useAuthStore
הנה הקוד שלי שמנסה לתקן את מאפיין ה-details:
const tokenResponse: AuthenticationResult = await instance.acquireTokenSilent(loginRedirectRequest)
const authStore = useAuthStore()
authStore.$patch({
details: tokenResponse
})
השגיאה שאני מקבל מוצגת למטה:
No overload matches this call.
Overload 1 of 2, '(partialState: _DeepPartial<{ details: { authority: string; uniqueId: string; tenantId: string; scopes: string[]; account: { homeAccountId: string; environment: string; tenantId: string; username: string; localAccountId: string; name?: string | undefined; idTokenClaims?: { ...; } | undefined; nativeAccountId?: string | undefined; } | null; ... 13 more ...; fromNativeBroker?: boolean | undefined; } | undefined; }>): void', gave the following error.
Overload 2 of 2, '(stateMutator: (state: { details: { authority: string; uniqueId: string; tenantId: string; scopes: string[]; account: { homeAccountId: string; environment: string; tenantId: string; username: string; localAccountId: string; name?: string | undefined; idTokenClaims?: { ...; } | undefined; nativeAccountId?: string | undefined; } | null; ... 13 more ...; fromNativeBroker?: boolean | undefined; } | undefined; }) => any): void', gave the following error.ts(2769)
useAuthStore.ts(8, 12): The expected type comes from property 'details' which is declared here on type '_DeepPartial<{ details: { authority: string; uniqueId: string; tenantId: string; scopes: string[]; account: { homeAccountId: string; environment: string; tenantId: string; username: string; localAccountId: string; name?: string | undefined; idTokenClaims?: { ...; } | undefined; nativeAccountId?: string | undefined; ...'
