Skip to content

Commit

Permalink
fix(types): correct references to Buffer for @types/node >= 16.0.0 …
Browse files Browse the repository at this point in the history
…< 16.6.0

Fix #11963
  • Loading branch information
vkarpov15 committed Jun 25, 2022
1 parent 4f89f23 commit 3a4ba27
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion types/inferschematype.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ type ResolvePathType<PathValueType, Options extends SchemaTypeOptions<PathValueT
PathValueType extends StringConstructor | 'string' | 'String' | typeof Schema.Types.String ? PathEnumOrString<Options['enum']> :
PathValueType extends NumberConstructor | 'number' | 'Number' | typeof Schema.Types.Number ? number :
PathValueType extends DateConstructor | 'date' | 'Date' | typeof Schema.Types.Date ? Date :
PathValueType extends BufferConstructor | 'buffer' | 'Buffer' | typeof Schema.Types.Buffer ? Buffer :
PathValueType extends typeof Buffer | 'buffer' | 'Buffer' | typeof Schema.Types.Buffer ? Buffer :
PathValueType extends BooleanConstructor | 'boolean' | 'Boolean' | typeof Schema.Types.Boolean ? boolean :
PathValueType extends 'objectId' | 'ObjectId' | typeof Schema.Types.ObjectId ? Schema.Types.ObjectId :
PathValueType extends 'decimal128' | 'Decimal128' | typeof Schema.Types.Decimal128 ? Schema.Types.Decimal128 :
Expand Down
4 changes: 3 additions & 1 deletion types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
declare module 'mongoose' {
import mongodb = require('mongodb');

class NativeBuffer extends Buffer {}

namespace Types {
class Array<T> extends global.Array<T> {
/** Pops the array atomically at most one time per document `save()`. */
Expand Down Expand Up @@ -47,7 +49,7 @@ declare module 'mongoose' {
unshift(...args: any[]): number;
}

class Buffer extends global.Buffer {
class Buffer extends NativeBuffer {
/** Sets the subtype option and marks the buffer modified. */
subtype(subtype: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 128 | ToObjectOptions): void;

Expand Down

0 comments on commit 3a4ba27

Please sign in to comment.