Back to Type Challenges

README

questions/29785-medium-deep-omit/README.md

latest1.6 KB
Original Source
<!--info-header-start--><h1>Deep Omit </h1><blockquote><p>by bowen <a href="https://github.com/jiaowoxiaobala" target="_blank">@jiaowoxiaobala</a></p></blockquote><p><a href="https://tsch.js.org/29785/play" target="_blank"></a> </p><!--info-header-end-->

Implement a typeDeepOmit, Like Utility types Omit, A type takes two arguments.

For example:

ts
type obj = {
  person: {
    name: string;
    age: {
      value: number
    }
  }
}

type test1 = DeepOmit<obj, 'person'>    // {}
type test2 = DeepOmit<obj, 'person.name'> // { person: { age: { value: number } } }
type test3 = DeepOmit<obj, 'name'> // { person: { name: string; age: { value: number } } }
type test4 = DeepOmit<obj, 'person.age.value'> // { person: { name: string; age: {} } }
<!--info-footer-start-->

<a href="../../README.md" target="_blank"></a> <a href="https://tsch.js.org/29785/answer" target="_blank"></a> <a href="https://tsch.js.org/29785/solutions" target="_blank"></a> <!--info-footer-end-->