Ensure fetchScripts returns a typed Script array by specifying return type in map function

This commit is contained in:
Bram Suurd 2024-11-06 22:55:24 +01:00
parent 11197af3e1
commit 810d63ea4d

View File

@ -18,11 +18,11 @@ const fetchScripts = async (): Promise<Script[]> => {
); );
const files: { download_url: string }[] = await response.json(); const files: { download_url: string }[] = await response.json();
const scripts = await Promise.all( const scripts = await Promise.all(
files.map(async (file) => { files.map(async (file): Promise<Script> => {
const response = await fetch(file.download_url); const response = await fetch(file.download_url);
const script = await response.json(); const script = await response.json();
return script as Script; return script;
}) }),
); );
return scripts; return scripts;
}; };