Last active
November 11, 2020 19:49
-
-
Save jonsmithers/2dd45399fafdc03f1e2cab8e8039e815 to your computer and use it in GitHub Desktop.
WeakRef type definition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* WeakRef is supported by major browsers but doesn't appear to be available in | |
* Typescript 4.0.5. Here is a temporary type definition until TypeScript adds | |
* native support. | |
* | |
* See https://github.com/microsoft/TypeScript/issues/32393 | |
*/ | |
interface WeakRef<V> { | |
deref(): V | undefined; | |
} | |
interface WeakRefConstructor { | |
new <V = any>(v: V): WeakRef<V>; | |
readonly prototype: WeakRef<any>; | |
} | |
/* eslint-disable-next-line @typescript-eslint/no-redeclare */ | |
declare var WeakRef: WeakRefConstructor; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment