From a485c402541b14e7f8a00b50d4093e546be43db4 Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Tue, 16 Feb 2021 17:14:59 -0500 Subject: [PATCH] fix(index.d.ts): make `SchemaTypeOptions#type` optional again to allow alternative typeKeys Fix #9927 --- index.d.ts | 2 +- test/typescript/main.test.js | 2 +- test/typescript/schema.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/index.d.ts b/index.d.ts index d57c64706b9..4d4a6ee49a4 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1365,7 +1365,7 @@ declare module 'mongoose' { } interface SchemaTypeOptions { - type: T | SchemaDefinitionWithBuiltInClass; + type?: T | SchemaDefinitionWithBuiltInClass; /** Defines a virtual with the given name that gets/sets this path. */ alias?: string; diff --git a/test/typescript/main.test.js b/test/typescript/main.test.js index 2d6b1188074..7dd5e51bef9 100644 --- a/test/typescript/main.test.js +++ b/test/typescript/main.test.js @@ -180,7 +180,7 @@ describe('typescript syntax', function() { } assert.equal(errors.length, 1); const messageText = errors[0].messageText.messageText; - assert.ok(/Type 'StringConstructor' is not assignable to type.*number/.test(messageText), messageText); + assert.ok(/Type '.*StringConstructor.*' is not assignable to type.*number/.test(messageText), messageText); }); it('document', function() { diff --git a/test/typescript/schema.ts b/test/typescript/schema.ts index 4aed0505b31..43528dc4611 100644 --- a/test/typescript/schema.ts +++ b/test/typescript/schema.ts @@ -71,7 +71,7 @@ async function gh9857() { type UserModel = Model; const schemaDefinition: UserSchemaDefinition = { - name: String, + name: { type: String }, active: Boolean, points: Number };