@waiting/shared-types
Advanced tools
Comparing version 23.17.0 to 23.18.0
@@ -35,3 +35,15 @@ /** Get the first element */ | ||
}[Tuple extends [] ? 1 : 0]; | ||
export type FlattenNestedTuple<T extends (readonly any[])> = { | ||
[K in keyof T]: FlattenTuple<T[K]>; | ||
}; | ||
/** | ||
* Convert const type to type const input = [1, 2] as const | ||
* @example ```ts | ||
* const input = [1, [2, 3]] as const // note the `as const` | ||
* type Result = FlattenTuple<typeof input> // [1, 2 | 3] | ||
* ``` | ||
* | ||
*/ | ||
type FlattenTuple<T> = T extends readonly (infer U)[] ? U extends ((any)[]) ? TupleToUnion<U> : U : T; | ||
export {}; | ||
//# sourceMappingURL=tuple.d.ts.map |
{ | ||
"name": "@waiting/shared-types", | ||
"author": "waiting", | ||
"version": "23.17.0", | ||
"version": "23.18.0", | ||
"description": "shared typescript types", | ||
@@ -70,3 +70,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "aa31a7a6971b1cabbd7e0d93a04956721fdac759" | ||
"gitHead": "d924f37d896368b0c2caa2a592afbb9b7df0b806" | ||
} |
@@ -63,1 +63,21 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
export type FlattenNestedTuple<T extends (readonly any[])> = { | ||
[K in keyof T]: FlattenTuple<T[K]> | ||
} | ||
/** | ||
* Convert const type to type const input = [1, 2] as const | ||
* @example ```ts | ||
* const input = [1, [2, 3]] as const // note the `as const` | ||
* type Result = FlattenTuple<typeof input> // [1, 2 | 3] | ||
* ``` | ||
* | ||
*/ | ||
type FlattenTuple<T> = T extends readonly (infer U)[] | ||
? U extends ((any)[]) | ||
? TupleToUnion<U> | ||
// ? U extends ((infer V)[]) | ||
// ? FlattenTuple<U> | FlattenTuple<V> | ||
: U | ||
: T |
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
77948
1365