-
Type: Bug
-
Resolution: Duplicate
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
What problem are you facing?
TypeScript processing (type checking and transpilation) is severely slowed down when types with high count of unique key names, enum values, type unions, and recursion are passed to MongoDB collection methods.
TypeScript processing ultimately fails with the following errors most prevalent:
error TS2589: Type instantiation is excessively deep and possibly infinite.
error TS2615: Type of property 'prop49' circularly references itself in mapped type
What driver and relevant dependency versions are you using?
bson: ~4.7.0 mongodb: ~4.9.0 typescript: ~4.8.2
Steps to reproduce?
Please consult minimal reproduction repository:
https://github.com/thinkalpha/node-mongodb-typechecking-performance
Install dependencies ( npm i ) and run npm exec tsc --incremental false to reproduce the issue. Consult class.ts for Driver call sites and the individual model types for additional detail. The "circular" reference example is minimal, while the "slow" example is an anonymized real-world data model. Both employ recursive types.