diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index 2c2bd1e21d..879fad3047 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -3992,7 +3992,7 @@ export class Image extends ImageBase { static getSize(uri: string, success: (width: number, height: number) => void, failure: (error: any) => void): any; static prefetch(url: string): any; static abortPrefetch?(requestId: number): void; - static queryCache?(urls: string[]): Promise>; + static queryCache?(urls: string[]): Promise<{[url: string]: "memory" | "disk" | "disk/memory"}>; /** * @see https://facebook.github.io/react-native/docs/image.html#resolveassetsource @@ -4013,7 +4013,7 @@ export class ImageBackground extends ImageBackgroundBase { getSize(uri: string, success: (width: number, height: number) => void, failure: (error: any) => void): any; prefetch(url: string): any; abortPrefetch?(requestId: number): void; - queryCache?(urls: string[]): Promise>; + queryCache?(urls: string[]): Promise<{[url: string]: "memory" | "disk" | "disk/memory"}>; } export interface ViewToken { diff --git a/types/react-native/test/index.tsx b/types/react-native/test/index.tsx index a1ca78f84b..b9e9912e27 100644 --- a/types/react-native/test/index.tsx +++ b/types/react-native/test/index.tsx @@ -701,10 +701,17 @@ class WebViewTest extends React.Component { export class ImageTest extends React.Component { componentDidMount(): void { - const image: ImageResolvedAssetSource = Image.resolveAssetSource({ - uri: "https://seeklogo.com/images/T/typescript-logo-B29A3F462D-seeklogo.com.png", - }); + const uri = "https://seeklogo.com/images/T/typescript-logo-B29A3F462D-seeklogo.com.png"; + const image: ImageResolvedAssetSource = Image.resolveAssetSource({ uri }); console.log(image.width, image.height, image.scale, image.uri); + + Image.queryCache([uri]).then(({ [uri]: status }) => { + if (status === undefined) { + console.log("Image is not in cache"); + } else { + console.log(`Image is in ${status} cache`); + } + }) } handleOnLoad = (e: NativeSyntheticEvent) => {