Skip to content

Commit

Permalink
test: repro #11117
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Dec 30, 2021
1 parent 1141ec4 commit 210ab50
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/typescript/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,32 @@ function testRequiredId(): void {
const createFoo = async(foo: FooInput): Promise<FooOutput> => {
return await Foo.create(foo);
};
}

async function gh11117(): Promise<void> {
interface Foo {
someDate: Date;
someId: Types.ObjectId;
someNumber: number;
someString: string;
}
const fooSchema = new Schema<Foo, Model<Foo>>({
someDate: { required: true, type: Date },
someId: { required: true, type: Schema.Types.ObjectId },
someNumber: { required: true, type: Number },
someString: { required: true, type: String }
});

const fooModel = model('foos', fooSchema);

const items = await fooModel.create<Foo>([
{
someId: new Types.ObjectId(),
someDate: new Date(),
someNumber: 5,
someString: 'test'
}
]);
const json = items[0].toJSON();
const someDate: Date = json.someDate;
}

0 comments on commit 210ab50

Please sign in to comment.