【发布时间】:2020-04-13 10:00:35
【问题描述】:
我不确定我在这里遗漏了什么,下面是我从 Typescript 中的 esLint 得到的错误截图:
代码本身在下面,这是整个文件,我做错了什么吗?这应该是某些 redux 的操作,但我可能对 typescript 语法了解得不够多,无法弄清楚它为什么给我这个警告,或者如何在不执行@ts-ignore 的情况下绕过它,但这似乎是个警察出去。这里关于我发现的 TS1005 错误的所有其他问题并不真正适用于我所看到的这种情况。
这是完整的代码:
interface ISignIn {
(credentials: {email: string, password: string}): (dispatch: Function, getState: Function, getFirebase: any)
};
export const SignIn: ISignIn = (credentials) => {
return (dispatch, getState, { getFirebase }) => {
const firebase = getFirebase();
firebase.auth().signInWithEmailAndPassword(
credentials.email,
credentials.password
).then(() => {
dispatch({ type: 'LOGIN_SUCCESS' });
}).catch((error: any) => {
dispatch({ type: 'LOGIN_ERROR', error });
});
}
}
我错过了什么?
【问题讨论】:
-
应该是
type,而不是interface。之后,复制与实际函数中相同的箭头函数语法
标签: reactjs typescript redux interface react-redux