p-defer/index.test-d.ts

10 lines
317 B
TypeScript

import {expectType} from 'tsd-check';
import pDefer, {DeferredPromise} from '.';
expectType<DeferredPromise<unknown>>(pDefer());
expectType<DeferredPromise<string>>(pDefer<string>());
pDefer<string>().resolve('foo');
pDefer<string>().reject(new Error('foo'));
expectType<Promise<string>>(pDefer<string>().promise);