helpertypes
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -0,1 +1,10 @@ | ||
## [0.0.7](https://github.com/wessberg/helpertypes/compare/v0.0.6...v0.0.7) (2021-09-02) | ||
### Features | ||
* add 'ObjectLookupTuple' helper type ([5263180](https://github.com/wessberg/helpertypes/commit/5263180332d55d628a8b6afc4daa3dcb79941a01)) | ||
## [0.0.6](https://github.com/wessberg/helpertypes/compare/v0.0.5...v0.0.6) (2021-09-02) | ||
@@ -2,0 +11,0 @@ |
@@ -38,2 +38,11 @@ /** | ||
/** | ||
* Builds up a lookup path into a record via tuple elements. For example, for the record `{ a: {b: {c: string}}}`, a valid value could be `["a", "b", "c"]` | ||
* It takes as the second optional type argument the maximum depth it can recursively descent into the target object (default: 10). | ||
* It takes as the third optional type argument whether or not to walk into arrays and allow looking up members of their records as part of the lookup path. For | ||
* example, for the record `{a: {foo: string}[]}`, a value of true would allow for values like `["a", "foo"]`, even though 'foo' is part of a record within an arary | ||
*/ | ||
export declare type ObjectLookupTuple<T, MaxDepth extends number = 10, LookupRecordsInsideArrays extends boolean = false, CurrentDepth extends number = 0> = { | ||
[Key in keyof T]: CurrentDepth extends MaxDepth ? [Key] : T[Key] extends IgnoredLookupValue ? [Key] : T[Key] extends (infer El)[] | readonly (infer El)[] ? LookupRecordsInsideArrays extends false ? [Key] : [Key] | [Key, ...ObjectLookupTuple<El, MaxDepth, LookupRecordsInsideArrays, Next<CurrentDepth>>] : [Key] | [Key, ...ObjectLookupTuple<T[Key], MaxDepth, LookupRecordsInsideArrays, Next<CurrentDepth>>]; | ||
}[keyof T]; | ||
/** | ||
* A variant of Partial that is deep. | ||
@@ -44,3 +53,3 @@ * This means that every value is a partial recursively | ||
export declare type PartialDeep<T> = { | ||
[P in keyof T]?: T[P] extends (infer ArrayElement)[] ? PartialDeep<ArrayElement>[] : T[P] extends readonly (infer ReadonlyArrayElement)[] ? PartialDeep<ReadonlyArrayElement>[] : T[P] extends string | number | bigint | symbol | boolean | undefined | null | Date | RegExp | Set<unknown> | WeakSet<never> | Map<unknown, unknown> | WeakMap<never, unknown> ? T[P] : PartialDeep<T[P]>; | ||
[P in keyof T]?: T[P] extends (infer ArrayElement)[] ? PartialDeep<ArrayElement>[] : T[P] extends readonly (infer ReadonlyArrayElement)[] ? PartialDeep<ReadonlyArrayElement>[] : T[P] extends IgnoredLookupValue ? T[P] : PartialDeep<T[P]>; | ||
}; | ||
@@ -310,2 +319,6 @@ /** | ||
][T]; | ||
/** | ||
* A type indicating something that shouldn't be traversed into when mapping over objects, lists, or other similar data structures | ||
*/ | ||
export declare type IgnoredLookupValue = string | number | bigint | symbol | boolean | undefined | null | Date | RegExp | Set<unknown> | WeakSet<never> | Map<unknown, unknown> | WeakMap<never, unknown>; | ||
//# sourceMappingURL=index.d.ts.map |
{ | ||
"name": "helpertypes", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "A collection of TypeScript helper types", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25263
322