object-shape-tester - v6.9.2
    Preparing search index...

    Function pickShape

    • Creates a shape by picking specific keys off of another object shape.

      Type Parameters

      Parameters

      • originalShape: OriginalShape
      • selection: Selection & Readonly<
            {
                [Key in string
                | number
                | symbol]: Key extends NoInfer<keyof ShapeInitType<OriginalShape>>
                    ? NoInfer<Selection>[Key<Key>]
                    : never
            },
        >

      Returns Shape<
          TPick<
              ShapeInitSchema<OriginalShape>,
              (
                  keyof {
                      [Key in string
                      | number
                      | symbol as Selection[Key] extends true
                          ? Key
                          : true extends Selection[Key] ? Key : never]: Key
                  }
              )[],
          >,
      >

      import {pickShape, checkValidShape} from 'object-shape-tester';

      const myShape = pickShape(
      {
      hi: '',
      bye: -1,
      },
      {
      hi: true,
      },
      );

      checkValidShape(
      {
      hi: 'some value',
      },
      myShape,
      ); // `true`
      checkValidShape(
      {
      hi: 'some value',
      bye: 100,
      },
      myShape,
      ); // `false`