Skip to content

Instantly share code, notes, and snippets.

@anztrax
Created December 1, 2025 04:16
Show Gist options
  • Select an option

  • Save anztrax/da5422442384d40174962d9a5817eb9f to your computer and use it in GitHub Desktop.

Select an option

Save anztrax/da5422442384d40174962d9a5817eb9f to your computer and use it in GitHub Desktop.
Implement Pop utils in Typescript
/* _____________ Your Code Here _____________ */
type Pop<T extends any[]> = T extends [...infer P, any] ? P: [];
/* _____________ Test Cases _____________ */
import type { Equal, Expect } from '@type-challenges/utils'
type cases = [
Expect<Equal<Pop<[3, 2, 1]>, [3, 2]>>,
Expect<Equal<Pop<['a', 'b', 'c', 'd']>, ['a', 'b', 'c']>>,
Expect<Equal<Pop<[]>, []>>,
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment