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
constvoidPromiseFn=async()=>{}constvoidFn=()=>{};constunknownPromiseFn=async(): Promise<unknown>=>void0;constunknownFn=(): unknown=>void0;consttakesVoidPromiseFn=(fn: typeofvoidPromiseFn)=>{};consttakesVoidFn=(fn: typeofvoidFn)=>{};// This workstakesVoidFn(voidFn);// This workstakesVoidFn(unknownFn);// This workstakesVoidPromiseFn(voidPromiseFn);// This does NOT worktakesVoidPromiseFn(unknownPromiseFn);consttakesVoidPromise=(fn: Promise<void>)=>{};// This workstakesVoidPromise(newPromise<void>(()=>{}));// This does NOT worktakesVoidPromise(newPromise<unknown>(()=>{}));
🙁 Actual behavior
A function that returns Promise<unknown> (() => Promise<unknown>) could not be passed as a function argument with the type () => Promise<void>. Contradictory, a function that returns unknown (() => unknown) can be passed to a function argument with the type () => void.
🙂 Expected behavior
I would expect that passing a () => Promise<unknown> to a function argument that accepts () => Promise<void> to be allowed.
The text was updated successfully, but these errors were encountered:
Bug Report
Currently
unknown
is assignable tovoid
. However,Promise<unknown>
is NOT assignable toPromise<void>
.🔎 Search Terms
promise, type compatibility, assignment
🕗 Version & Regression Information
This is the behavior in every version I tried, and I reviewed the FAQ
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
A function that returns
Promise<unknown>
(() => Promise<unknown>
) could not be passed as a function argument with the type() => Promise<void>
. Contradictory, a function that returnsunknown
(() => unknown
) can be passed to a function argument with the type() => void
.🙂 Expected behavior
I would expect that passing a
() => Promise<unknown>
to a function argument that accepts() => Promise<void>
to be allowed.The text was updated successfully, but these errors were encountered: