Hello! I'm currently developing a NestJS module aimed at storing notifications of various kinds within the same table by utilizing discriminators. Despite eliminating the use of TypeScript's as keyword to keep things straightforward and rely on type inference, I'm encountering difficulties in achieving the desired type narrowing and inference with Mongoose's functionality.
Although Mongoose's functionality seems well-designed for typing, I'm facing challenges in making type inference work as expected. I'm hoping to receive some guidance on how to effectively manage discriminator types in my code.
I'll provide the content of the file along with links to StackBlitz and GitHub - notification.service.ts for reference. Any insights or solutions would be greatly appreciated!