For background, I am going through the "Flock of Functions" and doing my best to convert these Javascript examples to typed Typescript. See https://github.com/glebec/lambda-talk/blob/master/src/index.js#L152 for reference. The True function returns the first curried argument, and ignores the second.
Consider the following Typescript code:
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'));
Assuming I want to keep the "explicit-function-return-type" rule, how do I get rid of the ESLint disable comment? In other words, I want to properly type the True function.
My editor tells me the problem is with the (_els) => thn
portion of the code. It needs to be typeed somehow.
What can I do to set the return type or otherwise get this thing properly typed so that I don't need to disable the ESLint rule?
You still need to specify generic arguments and return types: