async function fetchMpdData(mpdUrl: string): Promise<MPDFileContainer> {
const data = await fetch(mpdUrl)
.then((response): Promise<string> => response.text())
.catch(
(error): void => {
throw new FetchError(`Error fetching file ${mpdUrl}: ${error}`);
},
);
return parseStringMpd(data);
}
parseStringMpd
takes a string. The data
passed to parseStringMpd
is failing with:
Argument of type 'string | void' is not assignable to parameter of type 'string'.
There are a few other questions on SO that talk about how if the promise fails the catch block will cause the data
property to be void. But in my case the catch block is throwing an error. So the data that is being complained about will never be reached.
Is the typescript parser just not able to handle this?