@wix/sdk-types 1.13.7 → 1.13.8

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/build/index.d.mts CHANGED
@@ -223,6 +223,46 @@ Unfortunately, `Record<string, never>`, `Record<keyof any, never>` and `Record<n
223
223
  */
224
224
  type EmptyObject = {[emptyObjectSymbol]?: never};
225
225
 
226
+ /**
227
+ Extract all optional keys from the given type.
228
+
229
+ This is useful when you want to create a new type that contains different type values for the optional keys only.
230
+
231
+ @example
232
+ ```
233
+ import type {OptionalKeysOf, Except} from 'type-fest';
234
+
235
+ interface User {
236
+ name: string;
237
+ surname: string;
238
+
239
+ luckyNumber?: number;
240
+ }
241
+
242
+ const REMOVE_FIELD = Symbol('remove field symbol');
243
+ type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
244
+ [Key in OptionalKeysOf<Entity>]?: Entity[Key] | typeof REMOVE_FIELD;
245
+ };
246
+
247
+ const update1: UpdateOperation<User> = {
248
+ name: 'Alice'
249
+ };
250
+
251
+ const update2: UpdateOperation<User> = {
252
+ name: 'Bob',
253
+ luckyNumber: REMOVE_FIELD
254
+ };
255
+ ```
256
+
257
+ @category Utilities
258
+ */
259
+ type OptionalKeysOf<BaseType extends object> =
260
+ BaseType extends unknown // For distributing `BaseType`
261
+ ? (keyof {
262
+ [Key in keyof BaseType as BaseType extends Record<Key, BaseType[Key]> ? never : Key]: never
263
+ }) & (keyof BaseType) // Intersect with `keyof BaseType` to ensure result of `OptionalKeysOf<BaseType>` is always assignable to `keyof BaseType`
264
+ : never; // Should never happen
265
+
226
266
  /**
227
267
  Extract all required keys from the given type.
228
268
 
@@ -247,11 +287,10 @@ const validator2 = createValidation<User>('surname', value => value.length < 25)
247
287
 
248
288
  @category Utilities
249
289
  */
250
- type RequiredKeysOf<BaseType extends object> = Exclude<{
251
- [Key in keyof BaseType]: BaseType extends Record<Key, BaseType[Key]>
252
- ? Key
253
- : never
254
- }[keyof BaseType], undefined>;
290
+ type RequiredKeysOf<BaseType extends object> =
291
+ BaseType extends unknown // For distributing `BaseType`
292
+ ? Exclude<keyof BaseType, OptionalKeysOf<BaseType>>
293
+ : never; // Should never happen
255
294
 
256
295
  /**
257
296
  Returns a boolean for whether the given type is `never`.
@@ -659,45 +698,6 @@ type IfAny<T, TypeIfAny = true, TypeIfNotAny = false> = (
659
698
  IsAny<T> extends true ? TypeIfAny : TypeIfNotAny
660
699
  );
661
700
 
662
- /**
663
- Extract all optional keys from the given type.
664
-
665
- This is useful when you want to create a new type that contains different type values for the optional keys only.
666
-
667
- @example
668
- ```
669
- import type {OptionalKeysOf, Except} from 'type-fest';
670
-
671
- interface User {
672
- name: string;
673
- surname: string;
674
-
675
- luckyNumber?: number;
676
- }
677
-
678
- const REMOVE_FIELD = Symbol('remove field symbol');
679
- type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
680
- [Key in OptionalKeysOf<Entity>]?: Entity[Key] | typeof REMOVE_FIELD;
681
- };
682
-
683
- const update1: UpdateOperation<User> = {
684
- name: 'Alice'
685
- };
686
-
687
- const update2: UpdateOperation<User> = {
688
- name: 'Bob',
689
- luckyNumber: REMOVE_FIELD
690
- };
691
- ```
692
-
693
- @category Utilities
694
- */
695
- type OptionalKeysOf<BaseType extends object> = Exclude<{
696
- [Key in keyof BaseType]: BaseType extends Record<Key, BaseType[Key]>
697
- ? never
698
- : Key
699
- }[keyof BaseType], undefined>;
700
-
701
701
  /**
702
702
  Merges user specified options with default options.
703
703
 
@@ -759,7 +759,11 @@ type ApplyDefaultOptions<
759
759
  IfNever<SpecifiedOptions, Defaults,
760
760
  Simplify<Merge<Defaults, {
761
761
  [Key in keyof SpecifiedOptions
762
- as Key extends OptionalKeysOf<Options> ? undefined extends SpecifiedOptions[Key] ? never : Key : Key
762
+ as Key extends OptionalKeysOf<Options>
763
+ ? Extract<SpecifiedOptions[Key], undefined> extends never
764
+ ? Key
765
+ : never
766
+ : Key
763
767
  ]: SpecifiedOptions[Key]
764
768
  }> & Required<Options>> // `& Required<Options>` ensures that `ApplyDefaultOptions<SomeOption, ...>` is always assignable to `Required<SomeOption>`
765
769
  >>;
package/build/index.d.ts CHANGED
@@ -223,6 +223,46 @@ Unfortunately, `Record<string, never>`, `Record<keyof any, never>` and `Record<n
223
223
  */
224
224
  type EmptyObject = {[emptyObjectSymbol]?: never};
225
225
 
226
+ /**
227
+ Extract all optional keys from the given type.
228
+
229
+ This is useful when you want to create a new type that contains different type values for the optional keys only.
230
+
231
+ @example
232
+ ```
233
+ import type {OptionalKeysOf, Except} from 'type-fest';
234
+
235
+ interface User {
236
+ name: string;
237
+ surname: string;
238
+
239
+ luckyNumber?: number;
240
+ }
241
+
242
+ const REMOVE_FIELD = Symbol('remove field symbol');
243
+ type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
244
+ [Key in OptionalKeysOf<Entity>]?: Entity[Key] | typeof REMOVE_FIELD;
245
+ };
246
+
247
+ const update1: UpdateOperation<User> = {
248
+ name: 'Alice'
249
+ };
250
+
251
+ const update2: UpdateOperation<User> = {
252
+ name: 'Bob',
253
+ luckyNumber: REMOVE_FIELD
254
+ };
255
+ ```
256
+
257
+ @category Utilities
258
+ */
259
+ type OptionalKeysOf<BaseType extends object> =
260
+ BaseType extends unknown // For distributing `BaseType`
261
+ ? (keyof {
262
+ [Key in keyof BaseType as BaseType extends Record<Key, BaseType[Key]> ? never : Key]: never
263
+ }) & (keyof BaseType) // Intersect with `keyof BaseType` to ensure result of `OptionalKeysOf<BaseType>` is always assignable to `keyof BaseType`
264
+ : never; // Should never happen
265
+
226
266
  /**
227
267
  Extract all required keys from the given type.
228
268
 
@@ -247,11 +287,10 @@ const validator2 = createValidation<User>('surname', value => value.length < 25)
247
287
 
248
288
  @category Utilities
249
289
  */
250
- type RequiredKeysOf<BaseType extends object> = Exclude<{
251
- [Key in keyof BaseType]: BaseType extends Record<Key, BaseType[Key]>
252
- ? Key
253
- : never
254
- }[keyof BaseType], undefined>;
290
+ type RequiredKeysOf<BaseType extends object> =
291
+ BaseType extends unknown // For distributing `BaseType`
292
+ ? Exclude<keyof BaseType, OptionalKeysOf<BaseType>>
293
+ : never; // Should never happen
255
294
 
256
295
  /**
257
296
  Returns a boolean for whether the given type is `never`.
@@ -659,45 +698,6 @@ type IfAny<T, TypeIfAny = true, TypeIfNotAny = false> = (
659
698
  IsAny<T> extends true ? TypeIfAny : TypeIfNotAny
660
699
  );
661
700
 
662
- /**
663
- Extract all optional keys from the given type.
664
-
665
- This is useful when you want to create a new type that contains different type values for the optional keys only.
666
-
667
- @example
668
- ```
669
- import type {OptionalKeysOf, Except} from 'type-fest';
670
-
671
- interface User {
672
- name: string;
673
- surname: string;
674
-
675
- luckyNumber?: number;
676
- }
677
-
678
- const REMOVE_FIELD = Symbol('remove field symbol');
679
- type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
680
- [Key in OptionalKeysOf<Entity>]?: Entity[Key] | typeof REMOVE_FIELD;
681
- };
682
-
683
- const update1: UpdateOperation<User> = {
684
- name: 'Alice'
685
- };
686
-
687
- const update2: UpdateOperation<User> = {
688
- name: 'Bob',
689
- luckyNumber: REMOVE_FIELD
690
- };
691
- ```
692
-
693
- @category Utilities
694
- */
695
- type OptionalKeysOf<BaseType extends object> = Exclude<{
696
- [Key in keyof BaseType]: BaseType extends Record<Key, BaseType[Key]>
697
- ? never
698
- : Key
699
- }[keyof BaseType], undefined>;
700
-
701
701
  /**
702
702
  Merges user specified options with default options.
703
703
 
@@ -759,7 +759,11 @@ type ApplyDefaultOptions<
759
759
  IfNever<SpecifiedOptions, Defaults,
760
760
  Simplify<Merge<Defaults, {
761
761
  [Key in keyof SpecifiedOptions
762
- as Key extends OptionalKeysOf<Options> ? undefined extends SpecifiedOptions[Key] ? never : Key : Key
762
+ as Key extends OptionalKeysOf<Options>
763
+ ? Extract<SpecifiedOptions[Key], undefined> extends never
764
+ ? Key
765
+ : never
766
+ : Key
763
767
  ]: SpecifiedOptions[Key]
764
768
  }> & Required<Options>> // `& Required<Options>` ensures that `ApplyDefaultOptions<SomeOption, ...>` is always assignable to `Required<SomeOption>`
765
769
  >>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/sdk-types",
3
- "version": "1.13.7",
3
+ "version": "1.13.8",
4
4
  "license": "MIT",
5
5
  "author": {
6
6
  "name": "Ronny Ringel",
@@ -31,12 +31,12 @@
31
31
  "@wix/monitoring-types": "^0.9.0"
32
32
  },
33
33
  "devDependencies": {
34
- "@types/node": "^20.17.28",
34
+ "@types/node": "^20.17.30",
35
35
  "eslint": "^8.57.1",
36
36
  "eslint-config-sdk": "0.0.0",
37
37
  "tsup": "^7.3.0",
38
- "type-fest": "^4.38.0",
39
- "typescript": "^5.8.2"
38
+ "type-fest": "^4.39.1",
39
+ "typescript": "^5.8.3"
40
40
  },
41
41
  "eslintConfig": {
42
42
  "extends": "sdk"
@@ -58,5 +58,5 @@
58
58
  "wallaby": {
59
59
  "autoDetect": true
60
60
  },
61
- "falconPackageHash": "5688a2fb60ca00fdff1bb2246ee2332e1797a484df1b74e7181de008"
61
+ "falconPackageHash": "089e764b67ae85aef430b6bf869ffc0933fd9bf837ac28df2d83a8f5"
62
62
  }