L
L
Little Vasya2020-08-17 17:35:01
typescript
Little Vasya, 2020-08-17 17:35:01

How to track the type parameter of a function from mapAction?

There is a method updatePhotothat is taken from the store through macActions
. It contains the type of parameter FormData
actions.ts

async updatePhoto(data: FormData): Promise<void> {
    try {
      await userHttpService.uploadPhoto(data);
    } catch (ex) {
      throw new Error(ex);
    }
  }


at the component level, I implement this action, so I have to re-give it a type
public updatePhoto;

  public async uploadPhoto(file) {
    try {
      const formData = new FormData();
      formData.append('avatar', file);
      await this.updatePhoto(formData);
    } catch (e) {
      console.log(e);
    }
  }


how to track type from store? because I can put anything in it

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question