iti icon indicating copy to clipboard operation
iti copied to clipboard

If you add to much dependencies it gives "Type instantiation is excessively deep and possibly infinite"

Open Vardan-bg opened this issue 1 year ago • 8 comments

If you add too much dependencies it gives "Type instantiation is excessively deep and possibly infinite" When I added last dependency which just and empty object (to avoid circular dependency case) it gives ts error. image

https://stackblitz.com/edit/typescript-s5bnzn?file=index.ts

Vardan-bg avatar May 15 '23 13:05 Vardan-bg

Hi there! Yes, I am aware of this TS limitation :/ https://itijs.org/docs/patterns-and-tips#ts2589-type-instantiation-is-excessively-deep-and-possibly-infinite

molszanski avatar May 15 '23 14:05 molszanski

Maybe those suggestions can help you for now? I am trying a new version that could trigger internal typescript type caching to circumvent this and another problem like that. But no luck so far.

molszanski avatar May 15 '23 14:05 molszanski

Let me know if any of the suggested solutions work for you :)

molszanski avatar May 15 '23 14:05 molszanski

Could opting for some typescript library types help? for example, the export type UnPromisify<T> = T extends Promise<infer U> ? U : T Could be potentially replaced with Awaited<T> Since Awaited<T> is nested,

export type UnpromisifyObject<T> = {
  [K in keyof T]: UnPromisify<T[K]>
}

Could be replaced in favor of Awaited<T>, where T extends {}

jacoobes avatar May 15 '23 16:05 jacoobes

Thanks @jacoobes, will check it out! 🚀

molszanski avatar May 15 '23 17:05 molszanski

Hi there! Yes, I am aware of this TS limitation :/ https://itijs.org/docs/patterns-and-tips#ts2589-type-instantiation-is-excessively-deep-and-possibly-infinite

thanks grouping helped)

Vardan-bg avatar May 15 '23 20:05 Vardan-bg

5.1 typescript

https://github.com/microsoft/TypeScript/pull/53246

👀 you might want to see if this optimization can happen

jacoobes avatar May 20 '23 21:05 jacoobes

@jacoobes lovely!

molszanski avatar May 23 '23 09:05 molszanski