Why am I encountering this TS warning?
Type 'unknown' is not assignable to type 'PokemonList'.ts(2322)
This issue is on line: "return e"
Here is the code snippet:
export interface PokemonList {
count: number;
next: string;
previous?: any;
results: {
name: string;
url: string;
}[]
};
const PokeApi = async (): Promise<PokemonList> => {
try {
const res = await fetch('https://pokeapi.co/api/v2/pokemon?limit=10');
return res.json()
} catch(e) {
return e;
}
};
After making this change:
( Promise<PokemonList> | unknown )
I receive this new error message:
The return type of an async function or method must be the global Promise<T> type. Did you mean to write 'Promise<unknown>'?ts(