Skip to content

Commit 3a4ba27

Browse files
committed
fix(types): correct references to Buffer for @types/node >= 16.0.0 < 16.6.0
Fix #11963
1 parent 4f89f23 commit 3a4ba27

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

types/inferschematype.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ type ResolvePathType<PathValueType, Options extends SchemaTypeOptions<PathValueT
142142
PathValueType extends StringConstructor | 'string' | 'String' | typeof Schema.Types.String ? PathEnumOrString<Options['enum']> :
143143
PathValueType extends NumberConstructor | 'number' | 'Number' | typeof Schema.Types.Number ? number :
144144
PathValueType extends DateConstructor | 'date' | 'Date' | typeof Schema.Types.Date ? Date :
145-
PathValueType extends BufferConstructor | 'buffer' | 'Buffer' | typeof Schema.Types.Buffer ? Buffer :
145+
PathValueType extends typeof Buffer | 'buffer' | 'Buffer' | typeof Schema.Types.Buffer ? Buffer :
146146
PathValueType extends BooleanConstructor | 'boolean' | 'Boolean' | typeof Schema.Types.Boolean ? boolean :
147147
PathValueType extends 'objectId' | 'ObjectId' | typeof Schema.Types.ObjectId ? Schema.Types.ObjectId :
148148
PathValueType extends 'decimal128' | 'Decimal128' | typeof Schema.Types.Decimal128 ? Schema.Types.Decimal128 :

types/types.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
declare module 'mongoose' {
33
import mongodb = require('mongodb');
44

5+
class NativeBuffer extends Buffer {}
6+
57
namespace Types {
68
class Array<T> extends global.Array<T> {
79
/** Pops the array atomically at most one time per document `save()`. */
@@ -47,7 +49,7 @@ declare module 'mongoose' {
4749
unshift(...args: any[]): number;
4850
}
4951

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

0 commit comments

Comments
 (0)