I had a web service giving me CSV results that needed to be downloaded in a TypeScript environment as a CSV file, here is how I did it (using FileSaver js):

const file = new File([data], "test.csv", { type: "text/csv;charset=utf-8" }); 
saveAs(file);

 

 

Saved you some valuable time?

Buy me a drink 🍺