1- interface WeakRef < T extends object > {
1+ interface WeakRef < T extends WeakKey > {
22 readonly [ Symbol . toStringTag ] : "WeakRef" ;
33
44 /**
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
66 * reclaimed.
7+ * In es2023 the value can be either a symbol or an object, in previous versions only object is permissible.
78 */
89 deref ( ) : T | undefined ;
910}
@@ -12,10 +13,11 @@ interface WeakRefConstructor {
1213 readonly prototype : WeakRef < any > ;
1314
1415 /**
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.
1719 */
18- new < T extends object > ( target : T ) : WeakRef < T > ;
20+ new < T extends WeakKey > ( target : T ) : WeakRef < T > ;
1921}
2022
2123declare var WeakRef : WeakRefConstructor ;
@@ -24,30 +26,31 @@ interface FinalizationRegistry<T> {
2426 readonly [ Symbol . toStringTag ] : "FinalizationRegistry" ;
2527
2628 /**
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.
3134 * @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.
3436 */
35- register ( target : object , heldValue : T , unregisterToken ?: object ) : void ;
37+ register ( target : WeakKey , heldValue : T , unregisterToken ?: WeakKey ) : void ;
3638
3739 /**
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.
3942 * @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 .
4144 */
42- unregister ( unregisterToken : object ) : void ;
45+ unregister ( unregisterToken : WeakKey ) : void ;
4346}
4447
4548interface FinalizationRegistryConstructor {
4649 readonly prototype : FinalizationRegistry < any > ;
4750
4851 /**
4952 * 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.
5154 */
5255 new < T > ( cleanupCallback : ( heldValue : T ) => void ) : FinalizationRegistry < T > ;
5356}
0 commit comments