Skip to content

PickOptional

Under Construction

This documentation is auto-generated, and is a work in progress. Please see the source code at https://github.com/phetsims/phet-core/blob/main/js/types/PickOptional.ts for the most up-to-date information.

Overview

Type PickOptional

Use PickOptional to pick properties of a type T and make them optional. This is useful when picking superclass options that you want to expose in a subclass API. (Careful if you pick a required superclass option and make it optional - you'll need to provide a default!) It makes life a little easier because you have to fiddle with fewer '<' and '>' characters, and PickOptional makes a little more sense than Pick<Partial> in the context of options.

Example: type MyClassOptions = PickOptional<PathOptions, 'stroke', 'lineWidth'>; Result:

@author Chris Malley (PixelZoom, Inc.)

import type { PickOptional } from 'scenerystack/phet-core';

Pick<Partial<T>, list>

Source Code

See the source for PickOptional.ts in the phet-core repository.