@halospv3/hce.shared-config
Version:
Automate commit message quality, changelogs, and CI/CD releases. Its `main` entry point is a Semantic Release config. Functions and classes are exposed for customization. An ESLint config, a Commitlint config, and addl. resources for .NET projects are als
15 lines • 1.08 kB
text/typescript
//#region src/utils/GracefulRecursion.d.ts
// #region https://dev.to/adrien2p/mastering-recursive-types-in-typescript-handling-depth-limitations-gracefully-5f4o#a-more-robust-solution-tuplebased-increment-and-decrement-types
type Length<T extends unknown[]> = (T extends {
length: number;
} ? T['length'] : never) & number;
type TupleOf<N extends number, T extends unknown[] = []> = Length<T> extends N ? T : TupleOf<N, [...T, unknown]>;
type Pop<T extends unknown[]> = T extends [...infer U, unknown] ? U : never;
// Increment adds an element to a tuple, effectively creating N + 1
type Increment<N extends number> = Length<[1, ...TupleOf<N>]>;
// Decrement removes an element from a tuple, effectively creating N - 1
type Decrement<N extends number> = Length<Pop<TupleOf<N>>>;
// #endregion https://dev.to/adrien2p/mastering-recursive-types-in-typescript-handling-depth-limitations-gracefully-5f4o#a-more-robust-solution-tuplebased-increment-and-decrement-types
//#endregion
export { Decrement, Increment, Length, Pop, TupleOf };
//# sourceMappingURL=GracefulRecursion.d.mts.map