mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-05 07:17:04 +00:00
react-native: Fix the return type of queryCache (#35681)
* Fix the return type of queryCache Ref: https://github.com/facebook/react-native/pull/23602 * fix * lint * Add queryCache test to Image
This commit is contained in:
Vendored
+2
-2
@@ -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<Map<string, "memory" | "disk">>;
|
||||
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<Map<string, "memory" | "disk">>;
|
||||
queryCache?(urls: string[]): Promise<{[url: string]: "memory" | "disk" | "disk/memory"}>;
|
||||
}
|
||||
|
||||
export interface ViewToken {
|
||||
|
||||
@@ -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<ImageLoadEventData>) => {
|
||||
|
||||
Reference in New Issue
Block a user