Skip to content

Commit

Permalink
Fix Tail behaviour on issue #1
Browse files Browse the repository at this point in the history
  • Loading branch information
webNeat committed Mar 21, 2022
1 parent ab9d807 commit f438878
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Tail.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import {Equal, Is} from './Is'

export type Tail<List extends any[]> = List extends [infer _, ...infer Rest] ? Rest : []
export type Tail<List extends any[]> = ((...args: List) => any) extends (arg: any, ...rest: infer Rest) => any
? Rest
: never

type Tests = [
Is<Equal<Tail<[]>, []>>,
Is<Equal<Tail<['a']>, []>>,
Is<Equal<Tail<['a', 'b']>, ['b']>>,
Is<Equal<Tail<['a', 'b', 'c', 'd']>, ['b', 'c', 'd']>>
]
type Test_Join<T extends string[]> = T extends [infer X, ...string[]]
? `${X extends string ? X : ''}${Test_Join<Tail<T>>}`
: ''

0 comments on commit f438878

Please sign in to comment.