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
If you want to write the Awaited type today, you can only do it with indexed access type hacks
But it is ugly.
But people are writing this in Stack Overflow answers.
We even use the same trick for Array.prototype.flat()
When we started, we intentionally limited recursive conditional type by forcing eager evaluation.
But could still use indexed access type trick. In the last few years, we've been hardening the compiler against run-away recursion. In a sense, these wacky indexed access types gave us early feedback on how to implement conditional recursive types correctly.
So adding recursive conditional types is trivial - we more or less just stop eager evaluation of any given branch of a conditional type. We now we defer until instantiation time.
Awaited can be written as
typeAwaited<T>=Textendsnull|undefined ? T : // for non-strictNullChecksTextendsPromiseLike<infer U> ? Awaited<U> :
T
The thing about Awaited is that every method that passes the await-ed value ought to use Awaited - but that breaks a ton of stuff!
Let's get a PR out and get some community feedback!
///
Comments(10 minutes)
#39930
///
comments instead of/**
///
comment plugin supported since 2011./// <reference />
comments?/** @jsx */
?ts-check
is single line?WASM Imports
foo.wasm.d.ts
number
to JavaScript, and those numbers get coerced..d.ts
file that gets type-checked against.readFile
gets astring
. WASM is not astring
!readFileBuffer
😣#39784
Recursive Conditional Types
If you want to write the
Awaited
type today, you can only do it with indexed access type hacksBut it is ugly.
We even use the same trick for
Array.prototype.flat()
When we started, we intentionally limited recursive conditional type by forcing eager evaluation.
So adding recursive conditional types is trivial - we more or less just stop eager evaluation of any given branch of a conditional type. We now we defer until instantiation time.
Awaited
can be written asThe thing about
Awaited
is that every method that passes theawait
-ed value ought to useAwaited
- but that breaks a ton of stuff!Let's get a PR out and get some community feedback!
Remove Optionality for
Promise
'sresolve
callback#39817
The text was updated successfully, but these errors were encountered: