Papooch / nestjs-cls

A continuation-local storage (async context) module compatible with NestJS's dependency injection.

Home Page:https://papooch.github.io/nestjs-cls/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot set complex objects with type inference

rafagldev opened this issue · comments

When trying to set a complex object (e.g. a database connection object) the following error appears:
Type instantiation is excessively deep and possibly infinite.ts(2589)

I could set this object with type inference, but it is a feature to nice to be lost.

Maybe there is other way to define the type of object without defining all possible fields in the tree structure. Could a type just be defined as the type itself, without any nesting?

Please see this section of the docs.

In your case, define the store property as:

interface ClsStore {
 connection: Terminal<Connection>
}

Oh thank you! I must've skipped that section of the docs. Next time I'll read more thoroughly. 👍