From 7c839b959e25a08ce61a94221e52a77536d4e3db Mon Sep 17 00:00:00 2001 From: pixelzoom Date: Fri, 3 May 2024 17:56:24 -0600 Subject: [PATCH] fix valueType in IOTypes for Particle subclasses, https://github.com/phetsims/gas-properties/issues/231 --- js/common/model/HeavyParticle.ts | 2 +- js/common/model/LightParticle.ts | 2 +- js/diffusion/model/DiffusionParticle1.ts | 8 +++++--- js/diffusion/model/DiffusionParticle2.ts | 8 +++++--- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/js/common/model/HeavyParticle.ts b/js/common/model/HeavyParticle.ts index 2e2bfa48..756b9c49 100644 --- a/js/common/model/HeavyParticle.ts +++ b/js/common/model/HeavyParticle.ts @@ -52,7 +52,7 @@ export default class HeavyParticle extends Particle { } public static readonly HeavyParticleIO = new IOType( 'HeavyParticleIO', { - valueType: Particle, + valueType: HeavyParticle, stateSchema: Particle.STATE_SCHEMA, fromStateObject: HeavyParticle.fromStateObject } ); diff --git a/js/common/model/LightParticle.ts b/js/common/model/LightParticle.ts index 825b8638..c5712266 100644 --- a/js/common/model/LightParticle.ts +++ b/js/common/model/LightParticle.ts @@ -52,7 +52,7 @@ export default class LightParticle extends Particle { } public static readonly LightParticleIO = new IOType( 'LightParticleIO', { - valueType: Particle, + valueType: LightParticle, stateSchema: Particle.STATE_SCHEMA, fromStateObject: LightParticle.fromStateObject } ); diff --git a/js/diffusion/model/DiffusionParticle1.ts b/js/diffusion/model/DiffusionParticle1.ts index d7acdae8..fd3425c9 100644 --- a/js/diffusion/model/DiffusionParticle1.ts +++ b/js/diffusion/model/DiffusionParticle1.ts @@ -21,6 +21,8 @@ type SelfOptions = EmptySelfOptions; export type DiffusionParticle1Options = SelfOptions & StrictOmit; +export type DiffusionParticle1StateObject = ParticleStateObject; + export default class DiffusionParticle1 extends DiffusionParticle { public constructor( providedOptions?: DiffusionParticle1Options ) { @@ -35,7 +37,7 @@ export default class DiffusionParticle1 extends DiffusionParticle { /** * Deserializes an instance of DiffusionParticle1. */ - private static fromStateObject( stateObject: ParticleStateObject ): DiffusionParticle1 { + private static fromStateObject( stateObject: DiffusionParticle1StateObject ): DiffusionParticle1 { return new DiffusionParticle1( { x: stateObject.x, y: stateObject.y, @@ -46,8 +48,8 @@ export default class DiffusionParticle1 extends DiffusionParticle { } ); } - public static readonly DiffusionParticle1IO = new IOType( 'DiffusionParticle1IO', { - valueType: Particle, + public static readonly DiffusionParticle1IO = new IOType( 'DiffusionParticle1IO', { + valueType: DiffusionParticle1, stateSchema: Particle.STATE_SCHEMA, fromStateObject: DiffusionParticle1.fromStateObject } ); diff --git a/js/diffusion/model/DiffusionParticle2.ts b/js/diffusion/model/DiffusionParticle2.ts index cb38e580..59aa165d 100644 --- a/js/diffusion/model/DiffusionParticle2.ts +++ b/js/diffusion/model/DiffusionParticle2.ts @@ -21,6 +21,8 @@ type SelfOptions = EmptySelfOptions; export type DiffusionParticle2Options = SelfOptions & StrictOmit; +export type DiffusionParticle2StateObject = ParticleStateObject; + export default class DiffusionParticle2 extends DiffusionParticle { public constructor( providedOptions?: DiffusionParticle2Options ) { @@ -35,7 +37,7 @@ export default class DiffusionParticle2 extends DiffusionParticle { /** * Deserializes an instance of DiffusionParticle1. */ - private static fromStateObject( stateObject: ParticleStateObject ): DiffusionParticle2 { + private static fromStateObject( stateObject: DiffusionParticle2StateObject ): DiffusionParticle2 { return new DiffusionParticle2( { x: stateObject.x, y: stateObject.y, @@ -46,8 +48,8 @@ export default class DiffusionParticle2 extends DiffusionParticle { } ); } - public static readonly DiffusionParticle2IO = new IOType( 'DiffusionParticle2IO', { - valueType: Particle, + public static readonly DiffusionParticle2IO = new IOType( 'DiffusionParticle2IO', { + valueType: DiffusionParticle2, stateSchema: Particle.STATE_SCHEMA, fromStateObject: DiffusionParticle2.fromStateObject } );