diff --git a/package.json b/package.json index c503294..57ed666 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "@types/ioredis": "^4.0.18", "@types/moment-precise-range-plugin": "^0.2.0", "@types/mongoose": "^5.5.20", + "@types/node": "^13.9.1", "@types/nodemailer": "^6.2.1", "@types/signale": "^1.2.1", "@types/uuid": "^3.4.5", diff --git a/types/global.d.ts b/types/global.d.ts new file mode 100644 index 0000000..04a9dd5 --- /dev/null +++ b/types/global.d.ts @@ -0,0 +1,31 @@ + +interface PromiseFulfilledResult { + status: 'fulfilled'; + value: T; +} + +interface PromiseRejectedResult { + status: 'rejected'; + reason: any; +} + +type PromiseSettledResult = PromiseFulfilledResult | PromiseRejectedResult; + +interface PromiseConstructor { + /** + * Creates a Promise that is resolved with an array of results when all + * of the provided Promises resolve or reject. + * @param values An array of Promises. + * @returns A new Promise. + */ + allSettled(values: T): + Promise<{ -readonly [P in keyof T]: PromiseSettledResult ? U : T[P]> }>; + + /** + * Creates a Promise that is resolved with an array of results when all + * of the provided Promises resolve or reject. + * @param values An array of Promises. + * @returns A new Promise. + */ + allSettled(values: Iterable): Promise ? U : T>[]>; +}