Appearance
题目
实现高级工具类型 GetRequired<T>,该类型保留所有必需的属性
GetRequired<T>
例如
type I = GetRequired<{ foo: number; bar?: string }>; // expected to be { foo: number }
解答
type GetRequired<T> = { [P in keyof T as T[P] extends Required<T>[P] ? P : never]: T[P]; };