so im trying to build the photo-gallery sample project for ionic and im stuck on this error. not sure what i means really. i tried downgrading npm package. didnt work. all the other questions kinda just confuse me more lol so here is the full error:
error TS2345: Argument of type '{ filepath: string; webviewPath: string; }' is not assignable to parameter of type 'Photo'. [ng] Object literal may only specify known properties, and 'filepath' does not exist in type 'Photo'.
I believe they made a mistake in the tutorial. They give the interface the same name as the Photo import from '@capacitor/camera'. Instead, give the interface the name 'UserPhoto'.
My source is looking at the ionic repository for this project on GitHub: https://github.com/ionic-team/tutorial-photo-gallery-angular
You need to change the following in the photo.service.ts file:
export interface UserPhoto {
filepath: string;
webviewPath: string;
}
This is at the bottom of the file, outside of the PhotoService class definition.
You also need to define an array of type UserPhoto, not Photo in your PhotoService method. This looks like this:
export class PhotoService {
public photos: UserPhoto[] = [];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With