If you come across this and need to categorize it for TypeScript, here's how I approached it:
export type ReportGenerationFormat = 'PPT' | 'WORD' | 'PDF';
interface ReportFileType {
extension: string;
mimeType: string;
}
/**
* List of file name extensions with their corresponding MIME Types.
* PPT is a closed format used before PowerPoint 2007.
* PPTX is an open format introduced since PowerPoint 2007.
* PDF is universally known as Portable Document Format.
* DOC refers to Microsoft document format pre-Word 2007.
* DOCX represents newer versions of Microsoft Word documents.
*/
export const ReportFileTypes: Record<string, ReportFileType> = {
PPT: { extension: '.ppt', mimeType: 'application/vnd.ms-powerpoint' },
PPTX: { extension: '.pptx', mimeType: 'application/vnd.openxmlformats-officedocument.presentationml.presentation' },
PDF: { extension: '.pdf', mimeType: 'application/pdf' },
DOC: { extension: '.doc', mimeType: 'application/msword' },
DOCX: { extension: '.docx', mimeType: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' },
};
Simply import the constant and leverage it using the fileType parameter, such as:
ReportFileTypes[fileType].mimeType