Skip to content

prop

prop<S>(): <K>(key) => Optional<S, NonNullable<S[K]>>

Defined in: Core/Optional.ts:61

Creates an Optional that focuses on an optional property of an object. Only keys whose type includes undefined (i.e. field?: T) are accepted. Call with the structure type first, then the key.

S

<K>(key): Optional<S, NonNullable<S[K]>>

K extends string | number | symbol

K

Optional<S, NonNullable<S[K]>>

type Profile = { username: string; bio?: string };
const bioOpt = Optional.prop<Profile>()("bio");