phetsims / axon

Axon provides powerful and concise models for interactive simulations, based on observable Properties and related patterns.
MIT License
10 stars 8 forks source link

DerivedProperty options not flagging excess properties #406

Closed samreid closed 1 year ago

samreid commented 1 year ago

@marlitas and I observed this code was not failing the type check:

    // map() does not preserve a property of .length required for DerivedProperty
    this.meanProperty = new DerivedProperty( dependencies,
      () => calculateMean( this.getActive3DCups().map( waterCup3D => waterCup3D.waterLevelProperty.value ) ),
      {
        tandem: options.tandem.createTandem( 'meanProperty' ),
        phetioDocumentation: 'The ground truth water level mean.',
        phetioReadOnly: true,
        phetioType: DerivedProperty.DerivedPropertyIO( NumberIO ),
        range: new Range( MeanShareAndBalanceConstants.CUP_RANGE_MIN, 0.8 ),
        hello: 'true',
        thusanthousnatoheusnt: true
      } );

Despite the excess properties at the bottom. Perhaps something about the overloaded DerivedProperty constructor is confusing it.

samreid commented 1 year ago

I found this is not a problem in some cases:

image
samreid commented 1 year ago

I sampled several new DerivedProperty instantiation sites with options, and could not trigger this problem. I think it was due to the inconsistent callback signature, but that has been corrected in MSB by using deriveAny. Closing.