Skip to content

OptionalKeys

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/OptionalKeys.ts for the most up-to-date information.

Overview

Type OptionalKeys

Returns the keys of T that are optional.

See https://stackoverflow.com/questions/54520676/in-typescript-how-to-get-the-keys-of-an-object-type-whose-values-are-of-a-given and https://stackoverflow.com/questions/52984808/is-there-a-way-to-get-all-required-properties-of-a-typescript-object

@author Jonathan Olson <jonathan.olson@colorado.edu> @author Sam Reid (PhET Interactive Simulations)

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

{ [K in keyof T]-?: {} extends Pick<T, K> ? K : never }[keyof T]

Source Code

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