You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
typeFetcherFunction=(identifier: number)=>Promise<string>;//fixed 'string' not tied to parameter types is part of simplification for exampletypedemoFine1=ReturnType<FetcherFunction>;// Promise<string>typedemoFine2=Awaited<ReturnType<FetcherFunction>>;//stringasyncfunctiongetterDemo<FextendsFetcherFunction=FetcherFunction>(fetcherFn: F,identifier: number,) : Promise<Awaited<ReturnType<F>>>{letdemo3: F;letresult=awaitfetcherFn(identifier);//result is a stringreturnresult;//ERROR TS2322: Type 'string' is not assignable to type 'Awaited<ReturnType<F>>'//In the motivating example, lots more is done with the result and the return type is a type derived from it,//but the simpler example seems like it shouldn't be throwing an error: whether Awaited<ReturnType<F> is a//simple string or something more complex, that is what the promise returned by this async function resolves to.}
🙁 Actual behavior
Error as noted.
🙂 Expected behavior
No TS2322 error; the above code works fine. The awaited return type of fetcherFn should be assignable to the return (resolve) value, which is the awaited return type of that function type.
The text was updated successfully, but these errors were encountered:
Bug Report
🔎 Search Terms
generic function parameter 2322 return type
🕗 Version & Regression Information
Awaited
keyword didn't exist.⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
Error as noted.
🙂 Expected behavior
No TS2322 error; the above code works fine. The awaited return type of fetcherFn should be assignable to the return (resolve) value, which is the awaited return type of that function type.
The text was updated successfully, but these errors were encountered: