Description
So, I am not quite sure if there is already a way around this behaviour or if this is a feature request.
My code makes heavy use of type computations via recursive conditional types and mapped types. These types generate stuff like
// VSCode shows that Generated resolves to { a: { b1: { c: 42 }, b2: { d: { e: 42}}}}
type Generated = ComplicatedTransformation<SomeType>
This works until I make use of these generated types by transforming them even further. E.g., there is
type OmitNever<T> = Omit<T, SelectKeys<T, never>>;
As soon as I feed the generated type Generated
to OmitNever
the compiler shows the infamous error message Type instantiation is excessively deep and possibly infinite (#31619).
Now I was wondering why the compiler does not use the concrete type that VSCode shows when the cursor hovers over Generated
. Instead it seems to recalculate the whole (or part) of ComplicatedTransformation
.
Is there a way to tell the compiler "use the generated type as is and just forget how this type was generated"? If not, would that be a useful addition (in my eyes it looks like that, but maybe I am missing something crucial)?