matheus-rodrigues00 / utils

✨ Library to commonly used cross-projects utilities methods ✨
17 stars 11 forks source link

feat: add deepPick method #48

Closed nullsploit01 closed 1 year ago

nullsploit01 commented 1 year ago

Scope of change: added deepPick method that receives an object with nested properties and an array of keys and returns a new object with only the keys specified.

Key File: objects.ts

Notes This closes #34

matheus-rodrigues00 commented 1 year ago

Awesome code, @NullSploit01 !!

// mind-blowing type 🤯
type DeepKeys<T> = T extends object
  ? T extends infer O
    ? { [K in keyof O]: K | `${K & string}.${DeepKeys<O[K]>}` }[keyof O]
    : never
  : never;