I have a function that works a bit like a wrapper for dynamic import() syntax:
async importWrapper(url) {
return await import(url);
}
Is there a way I can make this function use a return type based on the value of the url parameter?
I tried:
async function importWrapper<T extends string>(url: T) : Promise<typeof import(T)> {
return await import(url);
}
but this gives an error:
Promise<typeof import(T)>
// ^^^--- TS1141 String literal expected