Skip to content

Commit

Permalink
doc: improve code comment
Browse files Browse the repository at this point in the history
  • Loading branch information
som-sm committed Jan 2, 2025
1 parent 723173f commit d97191d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion source/set-required.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ type SetArrayRequired<
Counter extends any[] = [],
Accumulator extends UnknownArray = [],
> = TArray extends unknown // For distributing `TArray` when it's a union
? keyof TArray & `${number}` extends never // Exit if there are no non-rest elements preceding the rest element (e.g., `[...string[]]` or `[...string[], string]`).
? keyof TArray & `${number}` extends never
// Exit if `TArray` is empty (e.g., []), or
// `TArray` contains no non-rest elements preceding the rest element (e.g., `[...string[]]` or `[...string[], string]`).
? [...Accumulator, ...TArray]
: TArray extends readonly [(infer First)?, ...infer Rest]
? '0' extends OptionalKeysOf<TArray> // If the first element of `TArray` is optional
Expand Down

0 comments on commit d97191d

Please sign in to comment.