Skip to content

Commit

Permalink
fix(index.d.ts): make SchemaTypeOptions#type optional again to allo…
Browse files Browse the repository at this point in the history
…w alternative typeKeys

Fix #9927
  • Loading branch information
vkarpov15 committed Feb 16, 2021
1 parent 94a2a7f commit a485c40
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1365,7 +1365,7 @@ declare module 'mongoose' {
}

interface SchemaTypeOptions<T> {
type: T | SchemaDefinitionWithBuiltInClass<T>;
type?: T | SchemaDefinitionWithBuiltInClass<T>;

/** Defines a virtual with the given name that gets/sets this path. */
alias?: string;
Expand Down
2 changes: 1 addition & 1 deletion test/typescript/main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion test/typescript/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ async function gh9857() {
type UserModel = Model<UserDocument>;

const schemaDefinition: UserSchemaDefinition = {
name: String,
name: { type: String },
active: Boolean,
points: Number
};
Expand Down

0 comments on commit a485c40

Please sign in to comment.