mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 12:56:46 +08:00
generated limit functions don't care about types, but preserve the return type of the function that they are passed.
14 lines
297 B
TypeScript
14 lines
297 B
TypeScript
import pLimit = require('p-limit');
|
|
|
|
const limit = pLimit(1);
|
|
|
|
const input = [
|
|
limit(() => Promise.resolve('foo')),
|
|
limit(() => Promise.resolve('bar')),
|
|
limit(() => Promise.resolve(undefined)),
|
|
];
|
|
|
|
Promise.all(input).then(result => {
|
|
const str: string | undefined = result[0];
|
|
});
|