ts-type-forge
    Preparing search index...

    Type Alias StrictPick<T, K>

    StrictPick: { [P in K]: T[P] }

    Creates a type by picking a set of properties from T whose keys are in union K. This is a stricter version that requires K to extend keyof T.

    Type Parameters

    • T

      The object type to pick from.

    • K extends keyof T

      The union of keys to pick, must extend keyof T.

    An object type with only the specified properties.

    type Person = { name: string; age: number; email: string };
    type BasicInfo = StrictPick<Person, 'name' | 'age'>; // { name: string; age: number }
    // type Invalid = StrictPick<Person, 'name' | 'invalid'>; // Error: 'invalid' is not a key of Person