Skip to content

Commit 9ec7583

Browse files
committed
[types] use WeakKey instead of object
1 parent 7655eb0 commit 9ec7583

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
declare function isWeakRef<T extends object>(value: unknown): value is WeakRef<T>;
1+
declare function isWeakRef<T extends WeakKey>(value: unknown): value is WeakRef<T>;
22

33
export = isWeakRef;

index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
var callBound = require('call-bound');
44

5-
var $deref = callBound('WeakRef.prototype.deref', true);
5+
// eslint-disable-next-line no-extra-parens
6+
var $deref = /** @type {<T extends WeakKey>(thisArg: WeakRef<T>) => T | undefined} */ (callBound('WeakRef.prototype.deref', true));
67

78
/** @type {import('.')} */
89
module.exports = typeof WeakRef === 'undefined'
@@ -14,6 +15,7 @@ module.exports = typeof WeakRef === 'undefined'
1415
return false;
1516
}
1617
try {
18+
// @ts-expect-error
1719
$deref(value);
1820
return true;
1921
} catch (e) {

0 commit comments

Comments
 (0)