From 35bfe10f2a7ccbc09afaf9ac4b130fa9cbb431fe Mon Sep 17 00:00:00 2001 From: AgustinVallejo Date: Fri, 26 Jul 2024 14:20:42 -0500 Subject: [PATCH] Optionizing valid values, see https://github.com/phetsims/density-buoyancy-common/issues/270 --- js/common/model/MappedWrappedProperty.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/js/common/model/MappedWrappedProperty.ts b/js/common/model/MappedWrappedProperty.ts index f9b94187..9f03e4e0 100644 --- a/js/common/model/MappedWrappedProperty.ts +++ b/js/common/model/MappedWrappedProperty.ts @@ -15,26 +15,26 @@ import Property, { PropertyOptions } from '../../../../axon/js/Property.js'; import DynamicProperty from '../../../../axon/js/DynamicProperty.js'; import densityBuoyancyCommon from '../../densityBuoyancyCommon.js'; import TReadOnlyProperty from '../../../../axon/js/TReadOnlyProperty.js'; +import optionize, { EmptySelfOptions } from '../../../../phet-core/js/optionize.js'; export type HasValueProperty = { valueProperty: Property; }; +type MappedWrappedPropertyOptions = PropertyOptions; + export default abstract class MappedWrappedProperty extends Property { protected readonly dynamicValueProperty: TReadOnlyProperty; public readonly customValue: T; public readonly availableValues: T[]; - protected constructor( initialValue: T, customValue: T, availableValues: T[], providedOptions: PropertyOptions ) { - - // TODO AV: Is this still needed? https://github.com/phetsims/density-buoyancy-common/issues/270 - if ( availableValues.length > 0 ) { + protected constructor( initialValue: T, customValue: T, availableValues: T[], providedOptions: MappedWrappedPropertyOptions ) { - // TODO AV: https://github.com/phetsims/density-buoyancy-common/issues/270 optionize please - providedOptions.validValues = availableValues; - } + const options = optionize, EmptySelfOptions, PropertyOptions>()( { + validValues: availableValues + }, providedOptions ); - super( initialValue, providedOptions ); + super( initialValue, options ); this.dynamicValueProperty = new DynamicProperty( this, { bidirectional: false,