I'm currently developing an application and I have a query regarding dynamically exporting a type.
My API call retrieves a list of categories.
const getCategories = async () => {
const fetchedCategories = await axios.get(uri)
// Expected output: ["fruits", "clothes", "shoes", "groceries", ...]
}
// Looking to create a unique export type Category containing only strings from the retrieved categories.
export type Category = "fruits" | "clothes" | "shoes" | "groceries" | ...
Can this be achieved in TypeScript? If not, I would appreciate alternative suggestions.
Thank you for your assistance!