Open Grsz opened 1 month ago
This is expected behavior because name
can be added via a plugin or Schema.prototype.add()
later.
The big issue with making this change would be timestamps:
type Item = {
_id: string;
createdAt: Date;
updatedAt: Date
}
// Valid, schema gets `createdAt` and `updatedAt` properties from `timestamps`
new Schema<Item>({
_id: String
}, { timestamps: true })
Any suggestions for how to make this work better with TypeScript?
Prerequisites
🚀 Feature Proposal
In
instead of just forcing the possible keys (as
path in keyof T
), let them be required (remove?
at[path in keyof T]?:
), or at least provide an option to toggle it being strict or not.Motivation
At the moment when defining a
Schema
, and supplying the first generic to it (RawDocType
), it doesn't complain if I miss some keys from the defined type, which is not ideal.Example