React-native typescript error: Type 'Generator<any, any, unknown>' is missing the following properties from type

Viewed 15

I have a function to return an object named UploadToGetId that I defined myself and it worked in runtime, but I got an error in compile time

 Type 'Generator<any, any, unknown>' is missing the following properties from type 'UploadToGetID': imageId, imageThumbId

This is my code:

type UploadToGetID = {
  imageId: string | undefined;
  imageThumbId: string | undefined;
};

function* uploadImageOrVideoToGetId(
  image: Image | undefined,
  imageThumb: ImageThumb | undefined,
): UploadToGetID {
  const uploadId: UploadToGetID = {
    imageId: undefined,
    imageThumbId: undefined,
  };
  try {
    if (image) {
      const token = yield Helper.getDataStored(JWT_KEY);
      let newImage: ImageResizerResponse = yield call(
        ImageResizer.createResizedImage,
        imageThumb!.url!,
        5000,
        5000,
        'JPEG',
        100,
      );

      let file = newImage.uri;
      if (Platform.OS === 'android') {
        file = newImage.uri.replace('file://', '');
      }
     ...
  } catch (error) {
    Alert.alert('Upload image fail! ' + error);
    return uploadId;
  }
}

Help me if you know how to fix it

0 Answers
Related