Skip to content

RequiredKeys

Overview

Type RequiredKeys

Returns the keys of T that are required.

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 { RequiredKeys } from 'scenerystack/phet-core';

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

Source Code

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