Sharing typescript interfaces between client and server mongoose model
You can declare _id
as optional:
export interface User { _id?: string; firstName: string; lastName: string; email: string;}
Or you can have another interface for a user with id:
export interface PersistedUser extends User { _id: string;}
And cast to it whenever needed.