Skip to content

Commit

Permalink
feat: add other common apis
Browse files Browse the repository at this point in the history
  • Loading branch information
nbbeeken committed Jan 12, 2023
1 parent 3860c8c commit b7c0e01
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/bson_value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ export abstract class BSONValue {
get [Symbol.for('@@mdb.bson.version')](): BSON_MAJOR_VERSION {
return BSON_MAJOR_VERSION;
}

abstract inspect(): string;
abstract toExtendedJSON(): unknown;
}
1 change: 0 additions & 1 deletion src/symbol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export class BSONSymbol extends BSONValue {
return this.value;
}

/** @internal */
inspect(): string {
return `new BSONSymbol("${this.value}")`;
}
Expand Down
8 changes: 7 additions & 1 deletion test/types/bson.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import {
UUID,
DBRefLike,
Document,
Decimal128Extended
Decimal128Extended,
BSONValue
} from '../../bson'; // import from generated bson.d.ts

expectType<() => UUID>(Binary.prototype.toUUID);
Expand Down Expand Up @@ -70,3 +71,8 @@ expectType<'MaxKey'>(MaxKey.prototype._bsontype)
expectType<'MinKey'>(MinKey.prototype._bsontype)
expectType<'BSONRegExp'>(BSONRegExp.prototype._bsontype)
expectType<'Binary'>(UUID.prototype._bsontype)

// Common BSONValue interface
declare const bsonValue: BSONValue;
expectType<string>(bsonValue._bsontype);
expectType<() => string>(bsonValue.inspect);

0 comments on commit b7c0e01

Please sign in to comment.