Effect CommunityEC
Effect Community14mo ago
4 replies
jasonkuhrt

Question about TypeScript memoization for repeated type utility usage

Hey, does anyone know if TS would memoize SuperCostlyTypeUtility<X> in the following type? Or would it be paid for twice?

type Foo = <X>(x:X) =>
  (
    & SuperCostlyTypeUtility<X>
    & DoSomething<Y, AndMore<SuperCostlyTypeUtility<X>>>
  )


I'm trying to get TS to "simplify" (compute) the return type and I am limited in what I can do because DoSomething could return
null
so simple & {} doesn't work here. I did find a solution, but it currently requires a double use of SuperCostlyTypeUtility
Was this page helpful?