Skip to content

Commit

Permalink
chore: clean up some inconsistencies with mongodbs new TS types
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Feb 2, 2021
1 parent 26f25c1 commit baf3938
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1740,8 +1740,9 @@ declare module 'mongoose' {
toObject(options?: ToObjectOptions & { flattenMaps?: boolean }): any;
}

// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface ObjectId extends mongodb.ObjectId { }
class ObjectId extends mongodb.ObjectId {
_id: this;
}

class Subdocument extends Document {
$isSingleNested: true;
Expand Down Expand Up @@ -2218,12 +2219,14 @@ declare module 'mongoose' {
};

type ReadonlyPartial<TSchema> = {
readonly [key in keyof TSchema]?: TSchema[key];
readonly [key in keyof TSchema]?: TSchema[key];
};

type MatchKeysAndValues<TSchema> = ReadonlyPartial<TSchema> & DotAndArrayNotation<any>;

type Condition<T> = T | QuerySelector<T>;
type AllowRegexpForStrings<T> = T extends string ? T | RegExp : T;

type Condition<T> = AllowRegexpForStrings<T> | QuerySelector<T>;

type _FilterQuery<T> = {
[P in keyof T]?: P extends '_id'
Expand Down
2 changes: 1 addition & 1 deletion test/typescript/objectid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ const oid = new Types.ObjectId();
oid.toHexString();
oid._id;

Types.ObjectId().toHexString();
(new Types.ObjectId()).toHexString();

0 comments on commit baf3938

Please sign in to comment.