Hex Core JS
    Preparing search index...

    Type Alias NullablePick<T, K>

    NullablePick:
        | Pick<Exclude<T, null | undefined>, K>
        | (T extends null ? null : never)
        | (T extends undefined ? undefined : never)

    Constructs a new type from T by picking K from the non-null and non-undefined type of T and preserves null and undefined as union types if they were part of the original union.

    Type Parameters

    • T
    • K extends keyof Exclude<T, null | undefined>
    type User = {
    id: string;
    name: string;
    }

    type Post = {
    title: string;
    body: string;
    author: User | null;
    }

    NullablePick<Post["author"], "id">; // Pick<User, "id"> | null