Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Apr 20, 2022
1 parent 3b27fad commit 8cc71f0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions js/optionize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ type OptionizeDefaults<SelfOptions = {}, ParentOptions = {}, KeysUsedInSubclassC

// TODO: "Limitation (I)" How can we indicate that a required parameter (for ParentOptions) will come in through defaults and/or providedOptions? Note: required parameters for S will not come from defaults. See https://github.com/phetsims/chipper/issues/1128

// Factor out the merge arrow closure to avoid heap/cpu at runtime
const merge3 = ( a: any, b?: any, c?: any ) => merge( a, b, c );

// ProvidedOptions = The type of this class's public API (type of the providedOptions parameter in the constructor)
// SelfOptions = Options that are defined by "this" class. Anything optional in this block must have a default provided in "defaults"
// ParentOptions = The public API for parent options, this will be exported by the parent class, like "NodeOptions"
Expand All @@ -65,7 +68,7 @@ export default function optionize<ProvidedOptions,
defaults: HalfOptions<SelfOptions, ParentOptions>,
providedOptions?: ProvidedOptions
) => HalfOptions<SelfOptions, ParentOptions> & ProvidedOptions & Required<Pick<ParentOptions, KeysUsedInSubclassConstructor>> {
return ( a: any, b?: any, c?: any ) => merge( a, b, c );
return merge3;
}

export function optionize3<ProvidedOptions,
Expand All @@ -76,7 +79,7 @@ export function optionize3<ProvidedOptions,
defaults: HalfOptions<SelfOptions, ParentOptions>,
providedOptions?: ProvidedOptions
) => HalfOptions<SelfOptions, ParentOptions> & ProvidedOptions & Required<Pick<ParentOptions, KeysUsedInSubclassConstructor>> {
return ( a: any, b?: any, c?: any ) => merge( a, b, c );
return merge3;
}

// function optionize<ProvidedOptions, // eslint-disable-line no-redeclare
Expand Down

0 comments on commit 8cc71f0

Please sign in to comment.