This piece of code is Vue3 with TypeScript-based.
export interface TenantDto {
uuid: string;
name: string;
}
export const useTenantStore = defineStore('tenant', {
state: () => ({
tenants: [],
}),
actions: {
setMyTenants: (payload: TenantDto[]) => {
this.tenants = payload;
},
}
);
When compiling the code in production, an error occurs on the following line:
this.tenants = payload;
The error indicates that the object is possibly 'undefined'.
How can I resolve this issue?