-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.ts
71 lines (63 loc) · 2.13 KB
/
types.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
export type Format = 'RFC1738' | 'RFC3986';
export type DefaultEncoder = (str: any, defaultEncoder?: any, charset?: string) => string;
export type DefaultDecoder = (str: string, decoder?: any, charset?: string) => string;
export type BooleanOptional = boolean | undefined;
export type StringifyBaseOptions = {
delimiter?: string;
allowDots?: boolean;
encodeDotInKeys?: boolean;
strictNullHandling?: boolean;
skipNulls?: boolean;
encode?: boolean;
encoder?: (
str: any,
defaultEncoder: DefaultEncoder,
charset: string,
type: 'key' | 'value',
format?: Format,
) => string;
filter?: Array<PropertyKey> | ((prefix: PropertyKey, value: any) => any);
arrayFormat?: 'indices' | 'brackets' | 'repeat' | 'comma';
indices?: boolean;
sort?: ((a: PropertyKey, b: PropertyKey) => number) | null;
serializeDate?: (d: Date) => string;
format?: 'RFC1738' | 'RFC3986';
formatter?: (str: PropertyKey) => string;
encodeValuesOnly?: boolean;
addQueryPrefix?: boolean;
charset?: 'utf-8' | 'iso-8859-1';
charsetSentinel?: boolean;
allowEmptyArrays?: boolean;
commaRoundTrip?: boolean;
};
export type StringifyOptions = StringifyBaseOptions;
export type ParseBaseOptions = {
comma?: boolean;
delimiter?: string | RegExp;
depth?: number | false;
decoder?: (str: string, defaultDecoder: DefaultDecoder, charset: string, type: 'key' | 'value') => any;
arrayLimit?: number;
parseArrays?: boolean;
plainObjects?: boolean;
allowPrototypes?: boolean;
allowSparse?: boolean;
parameterLimit?: number;
strictDepth?: boolean;
strictNullHandling?: boolean;
ignoreQueryPrefix?: boolean;
charset?: 'utf-8' | 'iso-8859-1';
charsetSentinel?: boolean;
interpretNumericEntities?: boolean;
allowEmptyArrays?: boolean;
duplicates?: 'combine' | 'first' | 'last';
allowDots?: boolean;
decodeDotInKeys?: boolean;
};
export type ParseOptions = ParseBaseOptions;
export type ParsedQs = {
[key: string]: undefined | string | string[] | ParsedQs | ParsedQs[];
};
// Type to remove null or undefined union from each property
export type NonNullableProperties<T> = {
[K in keyof T]-?: Exclude<T[K], undefined | null>;
};