Make resolve and reject values optional in the TypeScript definition (#3)
This commit is contained in:
parent
897315f950
commit
f84a36653e
|
@ -4,14 +4,14 @@ export interface DeferredPromise<ValueType> {
|
|||
|
||||
@param value - The value to resolve the promise with.
|
||||
*/
|
||||
resolve(value: ValueType | PromiseLike<ValueType>): void;
|
||||
resolve(value?: ValueType | PromiseLike<ValueType>): void;
|
||||
|
||||
/**
|
||||
Reject the promise with a provided reason or error.
|
||||
|
||||
@param reason - The reason or error to reject the promise with.
|
||||
*/
|
||||
reject(reason: unknown): void;
|
||||
reject(reason?: unknown): void;
|
||||
|
||||
/**
|
||||
The deferred promise.
|
||||
|
|
|
@ -4,6 +4,8 @@ import pDefer, {DeferredPromise} from '.';
|
|||
expectType<DeferredPromise<unknown>>(pDefer());
|
||||
expectType<DeferredPromise<string>>(pDefer<string>());
|
||||
|
||||
pDefer<void>().resolve();
|
||||
pDefer<string>().resolve('foo');
|
||||
pDefer<void>().reject();
|
||||
pDefer<string>().reject(new Error('foo'));
|
||||
expectType<Promise<string>>(pDefer<string>().promise);
|
||||
|
|
Loading…
Reference in New Issue