I
I
Ilya Famin2021-03-14 16:38:32
typescript
Ilya Famin, 2021-03-14 16:38:32

How to change type to any?

The whole point is that the code is supposed to work, but when run it gives the following error:

'yield' expression implicitly results in an 'any' type because its containing generator lacks a return-type annotation.  TS7057

The code of the part with which the error is associated:
function* fetchTweetsRequest(){
    try {
        const items = yield call(TweetsApi.fetchTweets);
        yield put(setTweets(items));
    } catch (error) {
        yield put(setLoadingState(LoadingState.ERROR));
    }
}

An axios request was made in the TweetsApi function and its sub-functions using this link https://trycode.pw/c/GYSNI.json
TweetsApi element code if necessary:
export const TweetsApi = {
    fetchTweets(): Promise<TweetsState['items']> {
        return axios.get('https://trycode.pw/c/GYSNI.json').then(({ data }) => data)
    },
};

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Belyaev, 2021-03-14
@bingo347

https://www.typescriptlang.org/docs/handbook/relea...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question