diff --git a/types/mongoose/index.d.ts b/types/mongoose/index.d.ts index 3cf4e4ca2a..cb8ca38408 100644 --- a/types/mongoose/index.d.ts +++ b/types/mongoose/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Mongoose 5.0.1 // Project: http://mongoosejs.com/ -// Definitions by: simonxca , horiuchi , sindrenm , lukasz-zak , Alorel +// Definitions by: simonxca , horiuchi , sindrenm , lukasz-zak , Alorel , jendrikw // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -722,7 +722,7 @@ declare module "mongoose" { /** defaults to null */ shardKey?: boolean; /** defaults to true */ - strict?: boolean; + strict?: boolean | 'throw'; /** no default */ toJSON?: DocumentToObjectOptions; /** no default */ diff --git a/types/mongoose/mongoose-tests.ts b/types/mongoose/mongoose-tests.ts index e63a0e612d..80050dad33 100644 --- a/types/mongoose/mongoose-tests.ts +++ b/types/mongoose/mongoose-tests.ts @@ -432,6 +432,8 @@ new mongoose.Schema({ } }); +new mongoose.Schema({foo: String}, {strict: 'throw'}); + export default function(schema: mongoose.Schema) { schema.pre('init', function(this: mongoose.Document, next: (err?: Error) => void): void { console.log('success!');