Bug Report
🔎 Search Terms
🕗 Version & Regression Information
- This is a crash
- This changed between versions Version 4.6.2__ and _______
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
- I was unable to test this on prior versions because _______
⏯ Playground Link
Playground link with relevant code
💻 Code
async function reproduce3<
T extends (...args: any[]) => Promise<any>
>(fn: T) {
const ret: Awaited<ReturnType<T>> = await fn(1, 2, 3);
return ret;
}
🙁 Actual behavior
/**
* const x3: any
*/
const x3 = await reproduce3(async () => 123 as const);
🙂 Expected behavior
/**
* const x3: 123
*/
const x3 = await reproduce3(async () => 123 as const);
Other OK examples as comparison
Wrap into object
async function reproduce<T extends (...args: any[]) => Promise<any>>(fn: T) {
const ret: {
val: Awaited<ReturnType<T>>;
} = { val: await fn(1, 2, 3) };
return ret;
}
/**
* const x: { val: 123 }
*/
const x = await reproduce(async () => 123 as const);
Explict
async function reproduce2<T extends (...args: any[]) => Promise<any>>(
fn: T
): Promise<Awaited<ReturnType<T>>> {
const ret = await fn(1, 2, 3);
return ret;
}
/**
* const x2: 123
*/
const x2 = await reproduce2(async () => 123 as const);
Bug Report
🔎 Search Terms
🕗 Version & Regression Information
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
🙂 Expected behavior
Other OK examples as comparison
Wrap into object
Explict