-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add definitions for WeakRef and FinalizationRegistry #38232
Changes from all commits
0ae7ab6
a5ce6c2
6548776
b6c29c7
3c0ed5f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,55 @@ | ||||||
interface WeakRef<T extends object> { | ||||||
readonly [Symbol.toStringTag]: "WeakRef"; | ||||||
|
||||||
/** | ||||||
* Returns the WeakRef instance's target object, or undefined if the target object has been | ||||||
* reclaimed. | ||||||
*/ | ||||||
deref(): T | undefined; | ||||||
} | ||||||
|
||||||
interface WeakRefConstructor { | ||||||
readonly prototype: WeakRef<any>; | ||||||
|
||||||
/** | ||||||
* Creates a WeakRef instance for the given target object. | ||||||
* @param target The target object for the WeakRef instance. | ||||||
*/ | ||||||
new<T extends object>(target?: T): WeakRef<T>; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It’s invalid to call
Suggested change
I’m fixing this in #42274. |
||||||
} | ||||||
|
||||||
declare var WeakRef: WeakRefConstructor; | ||||||
|
||||||
interface FinalizationRegistry { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
readonly [Symbol.toStringTag]: "FinalizationRegistry"; | ||||||
|
||||||
/** | ||||||
* Registers an object with the registry. | ||||||
* @param target The target object to register. | ||||||
* @param heldValue The value to pass to the finalizer for this object. This cannot be the | ||||||
* target object. | ||||||
* @param unregisterToken The token to pass to the unregister method to unregister the target | ||||||
* object. If provided (and not undefined), this must be an object. If not provided, the target | ||||||
* cannot be unregistered. | ||||||
*/ | ||||||
register(target: object, heldValue: any, unregisterToken?: object): void; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
/** | ||||||
* Unregisters an object from the registry. | ||||||
* @param unregisterToken The token that was used as the unregisterToken argument when calling | ||||||
* register to register the target object. | ||||||
*/ | ||||||
unregister(unregisterToken: object): void; | ||||||
} | ||||||
|
||||||
interface FinalizationRegistryConstructor { | ||||||
readonly prototype: FinalizationRegistry; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
/** | ||||||
* Creates a finalization registry with an associated cleanup callback | ||||||
* @param cleanupCallback The callback to call after an object in the registry has been reclaimed. | ||||||
*/ | ||||||
new(cleanupCallback: (heldValue: any) => void): FinalizationRegistry; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
|
||||||
declare var FinalizationRegistry: FinalizationRegistryConstructor; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, any chance to expedite this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it got lost in my email, but I think it's good to go after I re-run the github CI.