if I import mongoose
import mongoose, { Types } from 'mongoose';
and try to create objected
const fact = new Types.ObjectId(req.u.fact);
It appears error that Types is undefined
so I have to use:
const fact = req.u.fact as Types.ObjectId;
If I remove import mongoose:
import { Types } from 'mongoose';
everything working correct.
Do you understand how to fix it?
I'm not sure is it rigth or not, but now I use 'as'
const fact = req.u.fact as mongoose.Types.ObjectId;