Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

Optional

Optional

@example
type Props = {
     name: string;
     age: number;
     visible: boolean;
   };

   // Expect: { name?: string; age?: number; visible?: boolean; }
   type Props = Optional<Props>;

   // Expect: { name: string; age?: number; visible?: boolean; }
   type Props = Optional<Props, 'age' | 'visible'>;
type Optional<T extends object, K extends keyof T = keyof T> = Omit<T, K> & Partial<Pick<T, K>>;

§Type Parameters

§
T extends object
[src]
§
K extends keyof T = keyof T
[src]

§Type

§
Omit<T, K> & Partial<Pick<T, K>>
[src]