phetsims / circuit-construction-kit-common

"Circuit Construction Kit: Basics" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
10 stars 10 forks source link

TypeScript problem with ResistorIO.toStateObject #904

Closed pixelzoom closed 1 year ago

pixelzoom commented 1 year ago

https://github.com/phetsims/circuit-construction-kit-common/commit/d52735d70ed7d9211eae16c5f078d6ab0127b99c for https://github.com/phetsims/tandem/issues/278 exposed a problem with ResistorIO toStateObject. I added some @ts-ignore comments that need to be addressed at some point. Here's the relevant code in Resistor.ts:

    toStateObject: ( resistor: Resistor ): ResistorState => {
      const stateObject = CircuitElement.CircuitElementIO.toStateObject( resistor );
      // @ts-ignore stateObject has type CircuitElement, which does not have field resistorType
      stateObject.resistorType = EnumerationIO( ResistorType ).toStateObject( resistor.resistorType );
      // @ts-ignore stateObject has type CircuitElement
      return stateObject;
    },
samreid commented 1 year ago

Thanks! Fixed and closing.