[Typescript] 108. Easy - Nullable

Typescript has NonNullable<T>, let's build a Nullable<T>

type Nullable<T extends Record<PropertyKey, unknown>> = {
    [K in keyof T]: T[K] | null
}

type t = Nullable<{a: number, b: string}>

 

posted @ 2022-11-17 15:16  Zhentiw  阅读(42)  评论(0编辑  收藏  举报