1
- interface WeakRef < T extends object > {
1
+ interface WeakRef < T extends WeakKey > {
2
2
readonly [ Symbol . toStringTag ] : "WeakRef" ;
3
3
4
4
/**
5
- * Returns the WeakRef instance's target object , or undefined if the target object has been
5
+ * Returns the WeakRef instance's target value , or undefined if the target value has been
6
6
* reclaimed.
7
+ * In es2023 the value can be either a symbol or an object, in previous versions only object is permissible.
7
8
*/
8
9
deref ( ) : T | undefined ;
9
10
}
@@ -12,10 +13,11 @@ interface WeakRefConstructor {
12
13
readonly prototype : WeakRef < any > ;
13
14
14
15
/**
15
- * Creates a WeakRef instance for the given target object.
16
- * @param target The target object for the WeakRef instance.
16
+ * Creates a WeakRef instance for the given target value.
17
+ * In es2023 the value can be either a symbol or an object, in previous versions only object is permissible.
18
+ * @param target The target value for the WeakRef instance.
17
19
*/
18
- new < T extends object > ( target : T ) : WeakRef < T > ;
20
+ new < T extends WeakKey > ( target : T ) : WeakRef < T > ;
19
21
}
20
22
21
23
declare var WeakRef : WeakRefConstructor ;
@@ -24,30 +26,31 @@ interface FinalizationRegistry<T> {
24
26
readonly [ Symbol . toStringTag ] : "FinalizationRegistry" ;
25
27
26
28
/**
27
- * Registers an object with the registry.
28
- * @param target The target object to register.
29
- * @param heldValue The value to pass to the finalizer for this object. This cannot be the
30
- * target object.
29
+ * Registers a value with the registry.
30
+ * In es2023 the value can be either a symbol or an object, in previous versions only object is permissible.
31
+ * @param target The target value to register.
32
+ * @param heldValue The value to pass to the finalizer for this value. This cannot be the
33
+ * target value.
31
34
* @param unregisterToken The token to pass to the unregister method to unregister the target
32
- * object. If provided (and not undefined), this must be an object. If not provided, the target
33
- * cannot be unregistered.
35
+ * value. If not provided, the target cannot be unregistered.
34
36
*/
35
- register ( target : object , heldValue : T , unregisterToken ?: object ) : void ;
37
+ register ( target : WeakKey , heldValue : T , unregisterToken ?: WeakKey ) : void ;
36
38
37
39
/**
38
- * Unregisters an object from the registry.
40
+ * Unregisters a value from the registry.
41
+ * In es2023 the value can be either a symbol or an object, in previous versions only object is permissible.
39
42
* @param unregisterToken The token that was used as the unregisterToken argument when calling
40
- * register to register the target object .
43
+ * register to register the target value .
41
44
*/
42
- unregister ( unregisterToken : object ) : void ;
45
+ unregister ( unregisterToken : WeakKey ) : void ;
43
46
}
44
47
45
48
interface FinalizationRegistryConstructor {
46
49
readonly prototype : FinalizationRegistry < any > ;
47
50
48
51
/**
49
52
* Creates a finalization registry with an associated cleanup callback
50
- * @param cleanupCallback The callback to call after an object in the registry has been reclaimed.
53
+ * @param cleanupCallback The callback to call after a value in the registry has been reclaimed.
51
54
*/
52
55
new < T > ( cleanupCallback : ( heldValue : T ) => void ) : FinalizationRegistry < T > ;
53
56
}
0 commit comments