Skip to content

Latest commit

 

History

History
14 lines (9 loc) · 1.35 KB

File metadata and controls

14 lines (9 loc) · 1.35 KB

IsRequiredKey hard #utils

by jiangshan @jiangshanmeta

Take the Challenge

Implement a generic IsRequiredKey<T, K> that return whether K are required keys of T .

For example

type A = IsRequiredKey<{ a: number, b?: string },'a'> // true
type B = IsRequiredKey<{ a: number, b?: string },'b'> // false
type C = IsRequiredKey<{ a: number, b?: string },'b' | 'a'> // false

Back Share your Solutions Check out Solutions