If you wish to specify Mongoose ObjectId as a type for a TypeScript interface property, then you should use Types.ObjectId as type. For example:
import { Types } from 'mongoose';
interface User {
id: Types.ObjectId;
name: string;
// ...
}
const userSchema = new Schema<User>({
// ...
});
Please note that this is different from how you would specify ObjectId as a type in a Mongoose schema definition.