import {expectType} from 'tsd-check'; import pTimeout, {TimeoutError} from '.'; const delayedPromise: () => Promise = () => new Promise(resolve => setTimeout(() => resolve('foo'), 200)); pTimeout(delayedPromise(), 50).then(() => 'foo'); pTimeout(delayedPromise(), 50, () => { return pTimeout(delayedPromise(), 300); }); pTimeout(delayedPromise(), 50).then(value => expectType(value)); pTimeout(delayedPromise(), 50, 'error').then(value => expectType(value) ); pTimeout(delayedPromise(), 50, new Error('error')).then(value => expectType(value) ); pTimeout(delayedPromise(), 50, async () => 10).then(value => { expectType(value); }); pTimeout(delayedPromise(), 50, () => 10).then(value => { expectType(value); }); expectType(TimeoutError);