Skip to content

Instantly share code, notes, and snippets.

View anztrax's full-sized avatar
🎯
Focusing

andrew ananta gondo anztrax

🎯
Focusing
View GitHub Profile
@anztrax
anztrax / Pop.ts
Created December 1, 2025 04:16
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']>>,
@anztrax
anztrax / last.ts
Created December 1, 2025 04:12
Simple implementation of Last type in Typescript
type Last<T extends any[]> = T extends [...any, infer B] ? B: never;
@anztrax
anztrax / TupleToUnion.ts
Created December 1, 2025 04:07
Simple implementation of Tuple To Union in Typescript Type
type TupleToUnion<T extends unknown[]> = T[number];
@anztrax
anztrax / DeepReadOnly.ts
Created December 1, 2025 03:55
Create Simple implementation of DeepReadOnly in typescript
type DeepReadonly<T> = {
readonly [K in keyof T]:
T[K] extends Function
? T[K]
: T[K] extends { [K in string] : any}
? DeepReadonly<T[K]>: T[K]
}
@anztrax
anztrax / MyOmit.ts
Created December 1, 2025 03:43
Simple implementation of Omit in typescript
type MyOmit<T, K extends keyof T> = {
[P in keyof T as P extends K ? never: P] :T[P]
}
@anztrax
anztrax / MyParameter.ts
Created December 1, 2025 03:32
Simple implementation of Parameter Utils in typescript
type MyParameters<T extends (...args: any[]) => any> = T extends (...any:infer S) => any ? S: any
@anztrax
anztrax / Unshift.ts
Created December 1, 2025 03:17
Simple implementation of Unshift Array in Typescript
type Unshift<T extends unknown[], U> = [U, ...T]
@anztrax
anztrax / Push.ts
Created December 1, 2025 03:11
Simple implementation of Push 2 generics in TS
type Push<T extends unknown[], U> = [...T, U]
@anztrax
anztrax / Include.ts
Created December 1, 2025 03:06
Simple implementation of Includes in Typesscript
type Includes<T extends readonly any[], U> =
T extends [infer First, ...infer Rest]
? (
Equal<First, U> extends true
? true
: Includes<Rest, U>
)
: false
/* _____________ Test Cases _____________ */
@anztrax
anztrax / Concat.ts
Created December 1, 2025 02:55
Simple implementation of concat 2 array in TS type
type Concat<T extends readonly unknown[], U extends readonly unknown[]> = [...T, ...U]