From d39db26c264d3054139b79fd3cc35b3453b71135 Mon Sep 17 00:00:00 2001 From: Jendrik Date: Mon, 12 Feb 2018 15:14:24 +0100 Subject: [PATCH] add 'throw' to the strict option for schemas --- types/mongoose/index.d.ts | 4 ++-- types/mongoose/mongoose-tests.ts | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) 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!');