Skip to content

Latest commit

 

History

History
30 lines (22 loc) · 1.59 KB

File metadata and controls

30 lines (22 loc) · 1.59 KB

DeepPick hard #deep

by hiroya iizuka @hiroyaiizuka

Take the Challenge

Implement a type DeepPick, that extends Utility types Pick. A type takes two arguments.

For example:

type obj = {
  name: 'hoge', 
  age: 20,
  friend: {
    name: 'fuga',
    age: 30,
    family: {
      name: 'baz',  
      age: 1 
    }
  }
}

type T1 = DeepPick<obj, 'name'>   // { name : 'hoge' }
type T2 = DeepPick<obj, 'name' | 'friend.name'>  // { name : 'hoge' } & { friend: { name: 'fuga' }}
type T3 = DeepPick<obj, 'name' | 'friend.name' |  'friend.family.name'>  // { name : 'hoge' } &  { friend: { name: 'fuga' }} & { friend: { family: { name: 'baz' }}}

Back Share your Solutions Check out Solutions