Skip to content

Commit

Permalink
fix: correctly extract type of last passed argument
Browse files Browse the repository at this point in the history
  • Loading branch information
mesqueeb committed Nov 15, 2022
1 parent ce00d9d commit d0a1dc4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/merge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,9 @@ export function mergeAndConcat<T, Tn extends unknown[]>(
// const ba1: Barguments = { key: 'value1' }
// const ba2: Barguments = { key: 'value2' }
// const ba = merge(ba1, ba2)

// interface Carguments {
// key: string
// }
// const ca = merge<Carguments, Carguments[]>({ key: 'value1' }, { key: 'value2' })
// type P = Pop<Carguments[]>
8 changes: 5 additions & 3 deletions src/typeUtils/List.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ export type Length<L extends List> = L['length']
* ```
*/
export type Pop<L extends List> = L extends readonly []
? L
: L extends readonly [...any, infer Last]
? never
: L extends [...unknown[], infer Last]
? Last
: L
: L extends (infer T)[]
? T
: never

0 comments on commit d0a1dc4

Please sign in to comment.