In typescript writing definitions for manually curried functions. They work when the final return value is a non-promise, but fail when it is a promise. For example, this works:
function test (
a: number,
): (
b: number,
) => number
function test (
a: number,
b: number,
): number
function test (a, b?) {
if (b === undefined)
return function (b: number) { test(a, b) }
return a + b
}
While this fails:
function asynctest (
a: number,
): (
b: number,
) => Promise<number>
function asynctest (
a: number,
b: number,
): Promise<number>
async function asynctest (a, b?) {
if (b === undefined)
return function (b: number) { return asynctest(a, b) }
return await a + b
}
VSCode's built in type inspector suggests that the type returned by asynctest when provided 1 argument is (b: number) => Promise<number> as expected.