You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|T|(Dimensionextends0 ? never : DimensionArray<T,Decrement<Dimension>>))[]/** * for some reason the ts toolbelt Tail causes a recursion error in the {@link EveryCombination} * types so i made this one instead */// TODO: figure out what's up with the ts-toolbelt Tail type, should i just export and use this one everywhere instead?typeTail2<Textendsunknown[]>=numberextendsT['length'] ? never : Splice<T,0,1>typeInsertIntoEachIndexInArray<Textendsunknown[],ToAdd,Countextendsnumber,>=numberextendsT['length']
? never
: [Splice<T,Count,0,[ToAdd]>,
...(CountextendsT['length'] ? [] : InsertIntoEachIndexInArray<T,ToAdd,Add<Count,1>>),]typeAddToCombinations<Textendsunknown[][],ToAdd>=Textends[]
? []
: [
...InsertIntoEachIndexInArray<T[0],ToAdd,0>,
...(Tail2<T>extends infer Narrowedextendsunknown[][]
? AddToCombinations<Narrowed,ToAdd>
: never),]type_EveryCombination<Textendsunknown[],Resultextendsunknown[][]=[[T[0]]]>=Textends[]
? []
: Textends[unknown]
? Result
: AddToCombinations<Result,T[1]>extends infer Narrowedextendsunknown[][]
? _EveryCombination<Tail2<T>,Narrowed>
: never/** * creates a union type of every possible combination of values in the `T` array type, excluding * duplicates. * * if you want to allow duplicates, do something like `TupleOf<T[number], T['length']>` */exporttypeEveryCombination<Textendsunknown[]>=_EveryCombination<T>extends infer Result
? Result[number&keyofResult]
: never
The text was updated successfully, but these errors were encountered:
https://api.github.com/DetachHead/ts-helpers/blob/bb1ecf7d44ac379a45cb1f9dbf1ebe2977ba3863/src/types/Array.ts#L280
The text was updated successfully, but these errors were encountered: