1new Promise<boolean>((res, rej) => {
2 res(true);
3})
4.then(res => {
5 console.log(res);
6 return false;
7})
8 .then(res => {
9 console.log(res);
10 return true;
11})
12 .then(res => {
13 console.log(res);
14})
15 .catch(error => {
16 console.log('ERROR:', error.message);
17});
1type AsyncReturnType<T extends (...args: any) => any> =
2 T extends (...args: any) => Promise<infer U> ? U :
3 T extends (...args: any) => infer U ? U :
4 any