@digitraffic/common 2023.4.3-1 → 2023.4.4-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/types/nullable.d.ts +23 -0
- package/dist/types/nullable.js +3 -0
- package/package.json +1 -1
- package/src/types/nullable.ts +19 -0
package/README.md
CHANGED
@@ -15,7 +15,7 @@ In package.json dependencies:
|
|
15
15
|
In code:
|
16
16
|
|
17
17
|
```
|
18
|
-
import {DigitrafficStack, StackConfiguration} from "@digitraffic/common/aws/infra/stack/stack";
|
18
|
+
import {DigitrafficStack, StackConfiguration} from "@digitraffic/common/dist/aws/infra/stack/stack";
|
19
19
|
```
|
20
20
|
|
21
21
|
### DigitrafficStack
|
@@ -0,0 +1,23 @@
|
|
1
|
+
/**
|
2
|
+
* Adds `null` as an accepted type to all properties in given type.
|
3
|
+
*/
|
4
|
+
export type Nullable<Obj> = {
|
5
|
+
[Key in keyof Obj]: Obj[Key] | null;
|
6
|
+
};
|
7
|
+
type RequiredKeys<Obj> = {
|
8
|
+
[Key in keyof Obj]-?: object extends {
|
9
|
+
[K in Key]: Obj[Key];
|
10
|
+
} ? never : Key;
|
11
|
+
}[keyof Obj];
|
12
|
+
type OptionalKeys<Obj> = {
|
13
|
+
[Key in keyof Obj]-?: object extends {
|
14
|
+
[K in Key]: Obj[Key];
|
15
|
+
} ? Key : never;
|
16
|
+
}[keyof Obj];
|
17
|
+
type RequiredProperties<Obj> = Pick<Obj, RequiredKeys<Obj>>;
|
18
|
+
type OptionalProperties<Obj> = Pick<Obj, OptionalKeys<Obj>>;
|
19
|
+
/**
|
20
|
+
* Adds `null` as an accepted type to all optional properties in given type. Required properties remain unchanged.
|
21
|
+
*/
|
22
|
+
export type NullableOptional<Obj> = RequiredProperties<Obj> & Nullable<OptionalProperties<Obj>>;
|
23
|
+
export {};
|
package/package.json
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
/**
|
2
|
+
* Adds `null` as an accepted type to all properties in given type.
|
3
|
+
*/
|
4
|
+
export type Nullable<Obj> = { [Key in keyof Obj]: Obj[Key] | null };
|
5
|
+
|
6
|
+
type RequiredKeys<Obj> = {
|
7
|
+
[Key in keyof Obj]-?: object extends { [K in Key]: Obj[Key] } ? never : Key;
|
8
|
+
}[keyof Obj];
|
9
|
+
type OptionalKeys<Obj> = {
|
10
|
+
[Key in keyof Obj]-?: object extends { [K in Key]: Obj[Key] } ? Key : never;
|
11
|
+
}[keyof Obj];
|
12
|
+
type RequiredProperties<Obj> = Pick<Obj, RequiredKeys<Obj>>;
|
13
|
+
type OptionalProperties<Obj> = Pick<Obj, OptionalKeys<Obj>>;
|
14
|
+
|
15
|
+
/**
|
16
|
+
* Adds `null` as an accepted type to all optional properties in given type. Required properties remain unchanged.
|
17
|
+
*/
|
18
|
+
export type NullableOptional<Obj> = RequiredProperties<Obj> &
|
19
|
+
Nullable<OptionalProperties<Obj>>;
|