作为背景,我正在浏览“Flock of Functions”并尽我所能将这些 Javascript 示例转换为类型化的 Typescript。请参阅https://github.com/glebec/lambda-talk/blob/master/src/index.js#L152以供参考。True 函数返回第一个 curried 参数,并忽略第二个。
考虑以下 Typescript 代码:
interface ElsFn<T> {
(els: unknown): T;
}
interface True extends Function {
<T>(thn: T): ElsFn<T>;
}
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
const T: True = (thn) => (_els) => thn;
console.log(T('true')('false'));
假设我想保留“显式函数返回类型”规则,我如何摆脱 ESLint 禁用注释?换句话说,我想正确键入 True 函数。
我的编辑告诉我问题(_els) => thn
出在代码部分。它需要以某种方式输入。
我可以做些什么来设置返回类型或以其他方式正确输入这个东西,这样我就不需要禁用 ESLint 规则?