I have a function that acts as a wrapper for the dynamic import()
syntax:
async importWrapper(url) {
return await import(url);
}
Is there a way to make this function determine the return type based on the value of the url
parameter?
I attempted:
async function importWrapper<T extends string>(url: T) : Promise<typeof import(T)> {
return await import(url);
}
but encountered an error:
Promise<typeof import(T)>
// ^^^--- TS1141 String literal expected