-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
312a066
commit 598fdd6
Showing
2 changed files
with
11 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,10 @@ | ||
// string | ||
export function init(list: string): string; | ||
export function init<T>(list: readonly T[]): T[]; | ||
// empty tuple - purposefully `never, They literally have no init | ||
export function tail(list: readonly []): never; | ||
// length=1 tuples also return `never`. They literally have no init | ||
export function init<T>(list: readonly [T]): never; | ||
// non-empty tuples and array | ||
// `infer Init` only works on types like `readonly [1, '2', 3]` where you will get back `['2', 3]` | ||
// else, if the type is `string[]`, you'll get back `string[]` | ||
export function init<T extends readonly [...any]>(list: T): T extends readonly [...infer Init, any] ? Init : T; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters