From 4bf0e3eec34fba697afb966879fffe33fd903de1 Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 28 Sep 2016 18:07:02 -0400 Subject: [PATCH 1/2] set document id property to be optional --- mongoose/mongoose.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mongoose/mongoose.d.ts b/mongoose/mongoose.d.ts index 24664cc350..631e9c9581 100644 --- a/mongoose/mongoose.d.ts +++ b/mongoose/mongoose.d.ts @@ -871,7 +871,7 @@ declare module "mongoose" { /** Hash containing current validation errors. */ errors: Object; /** The string version of this documents _id. */ - id: string; + id?: string; /** This documents _id. */ _id: any; /** Boolean flag specifying if the document is new. */ From f3c98e74a04b199ca4c6acc6ceeec5691dc2cb70 Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 29 Sep 2016 08:59:12 -0400 Subject: [PATCH 2/2] add interface for mongoose document optional properties --- mongoose/mongoose.d.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mongoose/mongoose.d.ts b/mongoose/mongoose.d.ts index 631e9c9581..9e5600e696 100644 --- a/mongoose/mongoose.d.ts +++ b/mongoose/mongoose.d.ts @@ -715,7 +715,7 @@ declare module "mongoose" { * section document.js * http://mongoosejs.com/docs/api.html#document-js */ - class MongooseDocument { + class MongooseDocument implements MongooseDocumentOptionals { /** Checks if a path is set to its default. */ $isDefault(path?: string): boolean; @@ -870,8 +870,6 @@ declare module "mongoose" { /** Hash containing current validation errors. */ errors: Object; - /** The string version of this documents _id. */ - id?: string; /** This documents _id. */ _id: any; /** Boolean flag specifying if the document is new. */ @@ -880,6 +878,11 @@ declare module "mongoose" { schema: Schema; } + interface MongooseDocumentOptionals { + /** The string version of this documents _id. */ + id?: string; + } + interface DocumentToObjectOptions { /** apply all getters (path and virtual getters) */ getters?: boolean;