Skip to content

Commit

Permalink
feat(lib/es2021): Add type parameter to FinalizationRegistry
Browse files Browse the repository at this point in the history
  • Loading branch information
ExE-Boss committed Feb 7, 2021
1 parent 7de5d0b commit 4fc566f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/lib/esnext.weakref.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ interface WeakRefConstructor {
* 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>;
new<T extends object>(target: T): WeakRef<T>;
}

declare var WeakRef: WeakRefConstructor;

interface FinalizationRegistry {
interface FinalizationRegistry<T> {
readonly [Symbol.toStringTag]: "FinalizationRegistry";

/**
Expand All @@ -32,7 +32,7 @@ interface FinalizationRegistry {
* 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;
register(target: object, heldValue: T, unregisterToken?: object): void;

/**
* Unregisters an object from the registry.
Expand All @@ -43,13 +43,13 @@ interface FinalizationRegistry {
}

interface FinalizationRegistryConstructor {
readonly prototype: FinalizationRegistry;
readonly prototype: FinalizationRegistry<any>;

/**
* 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;
new<T>(cleanupCallback: (heldValue: T) => void): FinalizationRegistry<T>;
}

declare var FinalizationRegistry: FinalizationRegistryConstructor;

0 comments on commit 4fc566f

Please sign in to comment.