forked from mongodb-js/compass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
51 lines (46 loc) · 975 Bytes
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import type {
ObjectId,
MinKey,
MaxKey,
Long,
Double,
Int32,
Decimal128,
Binary,
BSONRegExp,
Code,
BSONSymbol,
Timestamp
} from 'bson';
export type TypeCastMap = {
Array: unknown[];
Binary: Binary;
Boolean: boolean;
Code: Code;
Date: Date;
Decimal128: Decimal128;
Double: Double;
Int32: Int32;
Int64: Long;
MaxKey: MaxKey;
MinKey: MinKey;
Null: null;
Object: Record<string, unknown>;
ObjectId: ObjectId;
BSONRegExp: BSONRegExp;
String: string;
BSONSymbol: BSONSymbol;
Timestamp: Timestamp;
Undefined: undefined;
};
export type TypeCastTypes = keyof TypeCastMap;
declare class TypeChecker {
cast<O = unknown, T extends string = string>(
object: O,
type: T
): T extends TypeCastTypes ? TypeCastMap[T] : O;
type(object: unknown): TypeCastTypes;
castableTypes(highPrecisionSupport?: boolean): TypeCastTypes[];
}
declare const typeCheckerInstance: TypeChecker;
export default typeCheckerInstance;