@@ -4,11 +4,11 @@ import { MongoInvalidArgumentError } from './error';
4
4
const kPromise = Symbol ( 'promise' ) ;
5
5
6
6
interface PromiseStore {
7
- [ kPromise ] ? : PromiseConstructor ;
7
+ [ kPromise ] : PromiseConstructor | null ;
8
8
}
9
9
10
10
const store : PromiseStore = {
11
- [ kPromise ] : undefined
11
+ [ kPromise ] : null
12
12
} ;
13
13
14
14
/**
@@ -31,7 +31,14 @@ export class PromiseProvider {
31
31
* Sets the promise library
32
32
* @deprecated Setting a custom promise library is deprecated the next major version will use the global Promise constructor only.
33
33
*/
34
- static set ( lib : PromiseConstructor ) : void {
34
+ static set ( lib : PromiseConstructor | null ) : void {
35
+ // eslint-disable-next-line no-restricted-syntax
36
+ if ( lib === null ) {
37
+ // Check explicitly against null since `.set()` (no args) should fall through to validate
38
+ store [ kPromise ] = null ;
39
+ return ;
40
+ }
41
+
35
42
if ( ! PromiseProvider . validate ( lib ) ) {
36
43
// validate
37
44
return ;
@@ -43,9 +50,7 @@ export class PromiseProvider {
43
50
* Get the stored promise library, or resolves passed in
44
51
* @deprecated Setting a custom promise library is deprecated the next major version will use the global Promise constructor only.
45
52
*/
46
- static get ( ) : PromiseConstructor {
47
- return store [ kPromise ] as PromiseConstructor ;
53
+ static get ( ) : PromiseConstructor | null {
54
+ return store [ kPromise ] ;
48
55
}
49
56
}
50
-
51
- PromiseProvider . set ( global . Promise ) ;
0 commit comments