From 818763fa2cc1241c0d49e995ea3de0105f7628f8 Mon Sep 17 00:00:00 2001 From: Michael Kauzmann Date: Thu, 22 Feb 2024 14:54:13 -0700 Subject: [PATCH] TinyForwardingProperty.targetProperty is TReadOnlyProperty, https://github.com/phetsims/axon/issues/449 Signed-off-by: Michael Kauzmann --- js/TinyForwardingProperty.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/js/TinyForwardingProperty.ts b/js/TinyForwardingProperty.ts index a5449e46..4f23aaf8 100644 --- a/js/TinyForwardingProperty.ts +++ b/js/TinyForwardingProperty.ts @@ -23,14 +23,14 @@ import TProperty from './TProperty.js'; import TReadOnlyProperty, { isTReadOnlyProperty, PropertyLazyLinkListener } from './TReadOnlyProperty.js'; type NodeLike = { - updateLinkedElementForProperty: ( tandemName: string, oldProperty?: TProperty | null, newProperty?: TProperty | null ) => void; + updateLinkedElementForProperty: ( tandemName: string, oldProperty?: TReadOnlyProperty | null, newProperty?: TReadOnlyProperty | null ) => void; isPhetioInstrumented: () => boolean; }; export default class TinyForwardingProperty extends TinyProperty { // Set in setTargetProperty(). - private targetProperty?: TProperty | null; + private targetProperty?: TReadOnlyProperty | null; // Set lazily in setTargetProperty() protected forwardingListener?: PropertyLazyLinkListener; @@ -93,11 +93,11 @@ export default class TinyForwardingProperty extends TinyProperty( newTargetProperty: TProperty | null, - node: NodeParam = null as NodeParam, - tandemName: string | null = null ): NodeParam { + public setTargetProperty( + newTargetProperty: TReadOnlyProperty | null, + node: NodeParam = null as NodeParam, + tandemName: string | null = null + ): NodeParam { assert && node && tandemName === null && this.targetPropertyInstrumented && assert( !node.isPhetioInstrumented(), 'tandemName must be provided for instrumented Nodes' ); // no-op if we are already forwarding to that property OR if we still aren't forwarding @@ -173,7 +173,7 @@ export default class TinyForwardingProperty extends TinyProperty ).set( value ); } else { super.set( value ); @@ -229,7 +229,7 @@ export default class TinyForwardingProperty extends TinyProperty | null { + public getTargetProperty(): TReadOnlyProperty | null { return this.targetProperty || null; }