TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
F
will still end up having never
in the param and will break ReturnType<>
=x
Function
as the top type for functions
interface Mx {
v: string;
}
const promiseTuple = async <T1, T2>(t1: T1, t2: Promise<T2>): Promise<[T1, T2]> =>
[t1, await t2];
const doThings = async (): Promise<Array<[string, Mx[]]>> => Promise.all([
promiseTuple('hello', Promise.resolve([{ v: 'sunshine' }])),
promiseTuple('world', await [{ v: 'peace' }])
]);
doThings().then(r => r.forEach(console.log));
async
part is the problem here
async
is in my code
async
, but nope: async
is there
(await 1)
is an expression of type Promise<number>
takesNumberOnly
would not work
await
in the inner fn