【发布时间】:2021-01-06 08:17:51
【问题描述】:
什么是 h*ll?为什么 err 是 typecipt 的错误?有这样的问题:
ESLint:不安全的成员访问 .response 对任何 值。(@typescript-eslint/no-unsafe-member-access)
这是问题代码的主要部分:
} catch (err) {
// Here is problem
if (!err.response) {
throw err;
}
return rejectWithValue(err);
}
这里是完整的代码:
export const actionFetchDataUser = createAsyncThunk(
'data/user',
async (formVal: TformVal, { rejectWithValue }) => {
try {
const GoogleAuth = window.gapi.auth2.getAuthInstance();
const profileMail = await GoogleAuth.signIn({
scope: 'profile email',
});
const googleEmail = profileMail.getBasicProfile().getEmail();
if (googleEmail !== formVal.email) {
throw Error('There is NO email');
}
return {
name: profileMail.getBasicProfile().getName(),
ava: profileMail.getBasicProfile().getImageUrl(),
};
} catch (err) {
// Here is problem
if (!err.response) {
throw err;
}
return rejectWithValue(err);
}
},
);
【问题讨论】:
标签: reactjs typescript redux-toolkit