Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. type Dissoc0<
  2. D extends string,
  3. O extends Record<D, any>
  4. > = {[K in keyof O]: (Record<D, never> & Record<string, K>)[K]}
  5.  
  6. type Dissoc<
  7. D extends string,
  8. O extends Record<D, any>,
  9. // issue 16018
  10. Foo extends Dissoc0<D, O> = Dissoc0<D, O>
  11. > = {[K in Foo[keyof O] & keyof O]: O[K]}
  12.  
  13. // example
  14. type Input = { X: 1, Y: 2, Z: 3 }
  15. type Expected = { Y: 2, Z: 3 }
  16. type Output = Dissoc<'X', Input>
  17. type Check<
  18. To extends Output = Expected,
  19. From extends Expected = Output
  20. > = never
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement