TypeScript download file

export function downloadFile(title: string, data: any, type: string = 'text/csv') {
  const element = document.createElement('a');
  const blob = new Blob([data], {type: type});
  element.href = URL.createObjectURL(blob);
  element.style.display = 'none';
  element.download = title;
  element.click();
}