diff --git a/.changeset/fluffy-files-flash.md b/.changeset/fluffy-files-flash.md new file mode 100644 index 0000000000..8ab755eee0 --- /dev/null +++ b/.changeset/fluffy-files-flash.md @@ -0,0 +1,5 @@ +--- +"type-plus": patch +--- + +optimize `SplitAt` by moving never check of `DeleteCount` to top. diff --git a/type-plus/ts/array/array_index.ts b/type-plus/ts/array/array_index.ts index 1a15330098..54c2addde5 100644 --- a/type-plus/ts/array/array_index.ts +++ b/type-plus/ts/array/array_index.ts @@ -9,6 +9,9 @@ import type { Integer } from '../numeric/integer.js' import type { Negative } from '../numeric/negative.js' /** + * + * 🦴 *utilities* + * * Gets the normalized index to access the element of an array or tuple. * * ```ts diff --git a/type-plus/ts/array/array_plus.split_at.ts b/type-plus/ts/array/array_plus.split_at.ts index ac5e89c375..53add78d9e 100644 --- a/type-plus/ts/array/array_plus.split_at.ts +++ b/type-plus/ts/array/array_plus.split_at.ts @@ -49,7 +49,10 @@ export namespace SplitAt { > = 0 extends A['length'] ? IsTuple : (Index extends B['length'] - ? _D + ? NeverType< + DeleteCount, + [B, A], + _D> : (A extends [infer Head, ...infer Tail] ? _ : 'unexpected: A does not extends [Head, ...Tail]')) @@ -60,15 +63,12 @@ export namespace SplitAt { C extends unknown[], DeleteCount, Insert extends unknown[], - > = NeverType< - DeleteCount, - [B, A], - DeleteCount extends C['length'] + > = DeleteCount extends C['length'] ? IsTuple : (A extends [infer Head, ...infer Tail] ? _D : IsTuple ) - > + }