toStateObject: property => {
assert && assert( parameterType.toStateObject, `toStateObject doesn't exist for ${parameterType.typeName}` );
const stateObject: ReadOnlyPropertyState<StateType> = {
value: parameterType.toStateObject( property.value ),
// Only include validValues if specified, so they only show up in PhET-iO Studio when supplied.
validValues: property.validValues ? property.validValues.map( v => {
return parameterType.toStateObject( v );
} ) : null,
units: NullableIO( StringIO ).toStateObject( property.units )
};
return stateObject;
},
Note that the comment no longer matches the code. We changed the implementation so the state schema is accurate. This means we can also simplify the implementation. I will do so shortly and request review from @zepumph
Discovered in https://github.com/phetsims/phet-io-wrappers/issues/581, ReadOnlyProperty toStateObject for validValues needs refinement. It currently looks like this:
Note that the comment no longer matches the code. We changed the implementation so the state schema is accurate. This means we can also simplify the implementation. I will do so shortly and request review from @zepumph