Skip to content

Commit

Permalink
Better typing for Deferred (#923)
Browse files Browse the repository at this point in the history
  • Loading branch information
TwitchBronBron committed Sep 29, 2023
1 parent 83668b6 commit 3b45aa6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/deferred.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export class Deferred<T = void> {
export class Deferred<T = void, TReject = any> {
constructor() {
this._promise = new Promise<T>((resolve, reject) => {
this._resolve = resolve;
Expand Down Expand Up @@ -50,13 +50,13 @@ export class Deferred<T = void> {
/**
* Reject the promise
*/
public reject(value: T) {
public reject(value: TReject) {
if (this._isCompleted) {
throw new Error('Already completed.');
}
this._isCompleted = true;
this._isRejected = true;
this._reject(value);
}
private _reject: (value: T) => void;
private _reject: (value: TReject) => void;
}

0 comments on commit 3b45aa6

Please sign in to comment.