2019-04-03 05:19:13 +00:00
|
|
|
import {expectType} from 'tsd';
|
|
|
|
import pDefer = require('.');
|
|
|
|
import {DeferredPromise} from '.';
|
2019-03-17 12:21:07 +00:00
|
|
|
|
|
|
|
expectType<DeferredPromise<unknown>>(pDefer());
|
|
|
|
expectType<DeferredPromise<string>>(pDefer<string>());
|
|
|
|
|
2019-03-23 08:53:14 +00:00
|
|
|
pDefer<void>().resolve();
|
2019-03-17 12:21:07 +00:00
|
|
|
pDefer<string>().resolve('foo');
|
2019-03-23 08:53:14 +00:00
|
|
|
pDefer<void>().reject();
|
2019-03-17 12:21:07 +00:00
|
|
|
pDefer<string>().reject(new Error('foo'));
|
|
|
|
expectType<Promise<string>>(pDefer<string>().promise);
|