From 70673ab0f769ad59a30c99a828a6c84f82743714 Mon Sep 17 00:00:00 2001 From: Sam Reid Date: Tue, 7 May 2024 05:29:32 -0600 Subject: [PATCH] Add FieldStateObject type, see https://github.com/phetsims/projectile-data-lab/issues/325 --- js/common/model/Field.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/js/common/model/Field.ts b/js/common/model/Field.ts index 6079123..1898c71 100644 --- a/js/common/model/Field.ts +++ b/js/common/model/Field.ts @@ -357,7 +357,7 @@ export default abstract class Field extends PhetioObject { } } - private toStateObject(): object { + private toStateObject(): FieldStateObject { return { airborneProjectiles: this.airborneProjectiles.map( projectile => Projectile.ProjectileIO.toStateObject( projectile ) ), landedProjectiles: this.landedProjectiles.map( projectile => Projectile.ProjectileIO.toStateObject( projectile ) ) @@ -380,7 +380,7 @@ export default abstract class Field extends PhetioObject { landedProjectiles: ArrayIO( Projectile.ProjectileIO ) }, toStateObject: field => field.toStateObject(), - applyState: ( field: Field, stateObject ) => { + applyState: ( field: Field, stateObject: FieldStateObject ) => { field.airborneProjectiles.length = 0; field.landedProjectiles.length = 0; @@ -396,4 +396,9 @@ export default abstract class Field extends PhetioObject { } ); } +type FieldStateObject = { + airborneProjectiles: ProjectileStateObject[]; + landedProjectiles: ProjectileStateObject[]; +}; + projectileDataLab.register( 'Field', Field ); \ No newline at end of file