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
When a generic type uses the expensive keyword, it marks it to be cached by the compiler.
The compiler will hash the type alias (generics unresolved) and the passed type parameters, and use that to memoize the resulting type.
Suggestions for hashing the types:
For referenced external type aliases, hash the definition recursively
For unique symbol types and classes with private properties, it also hashes the relevant name & source file path
For type parameters & infers, it labels them T0, T1, etc. (as they appear), and hashes them as such
Object types & interface types hash their properties in a specific order
Search Terms
cache types
Suggestion
(WIP; syntax bikeshed-able)
A new keyword
expensive, used as belowWhen a generic type uses the
expensivekeyword, it marks it to be cached by the compiler.The compiler will hash the type alias (generics unresolved) and the passed type parameters, and use that to memoize the resulting type.
Suggestions for hashing the types:
unique symboltypes and classes with private properties, it also hashes the relevant name & source file pathinfers, it labels themT0,T1, etc. (as they appear), and hashes them as suchDocumentedUtility Type #41165)Use Cases
With complex utility types, perf can often be sluggish as "semantic information produced from type computation is recomputed fresh on each edit"
Suggestion adapted from a comment on #41254
Examples
Checklist
My suggestion meets these guidelines: