Skip to content

Commit

Permalink
tighten up ToggleNode Typeing, phetsims/sun#846
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed May 19, 2023
1 parent 163394e commit 3d970ff
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions js/variability/view/RangeIconNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ export default class RangeIconNode extends Node {
value: PlotType.DOT_PLOT,

// Allow spacing
createNode: tandem => new Circle( viewRadius * 0.93, options )
createNode: () => new Circle( viewRadius * 0.93, options )
}, {
value: PlotType.LINE_PLOT,
createNode: tandem => new Path( timesSolidShape, combineOptions<PathOptions>( options, {
createNode: () => new Path( timesSolidShape, combineOptions<PathOptions>( options, {

// Allow spacing between the items
maxWidth: viewRadius * 2 * 0.9
Expand Down
5 changes: 2 additions & 3 deletions js/variability/view/VariabilityAccordionBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import VariabilityMeasureCheckbox from './VariabilityMeasureCheckbox.js';

export default class VariabilityAccordionBox extends CAVAccordionBox {

private plotToggleNode: ToggleNode<CAVSceneModel, VariabilityPlotNode>;
private readonly plotToggleNode: ToggleNode<CAVSceneModel, VariabilityPlotNode>;

public constructor( model: VariabilityModel, layoutBounds: Bounds2, tandem: Tandem, top: number ) {

Expand Down Expand Up @@ -116,8 +116,7 @@ export default class VariabilityAccordionBox extends CAVAccordionBox {
const madValueProperty = deriveValueProperty( vsm => vsm.madValueProperty );
const meanValueProperty = deriveValueProperty( vsm => vsm.meanValueProperty );

// TODO: Why can't this infer the type parameter? See https://github.com/phetsims/center-and-variability/issues/201
const readoutsToggleNode = new ToggleNode<VariabilityMeasure>( model.selectedVariabilityMeasureProperty, [ {
const readoutsToggleNode = new ToggleNode( model.selectedVariabilityMeasureProperty, [ {
value: VariabilityMeasure.RANGE,
tandemName: 'rangeReadoutToggleNode',
createNode: tandem => {
Expand Down
2 changes: 1 addition & 1 deletion js/variability/view/VariabilityPlotNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default class VariabilityPlotNode extends Node {
public constructor( model: VariabilityModel, sceneModel: VariabilitySceneModel, providedOptions: CAVPlotOptions ) {
super( providedOptions );

// TODO: Why can't it infer reasonable types here? See https://github.com/phetsims/center-and-variability/issues/201
// We need to specify CAVPlotNode manually because otherwise TypeScript will infer all Nodes as the first element (RangeNode), see https://github.com/phetsims/sun/issues/846
const toggleNode = new ToggleNode<VariabilityMeasure, CAVPlotNode>( model.selectedVariabilityMeasureProperty, [ {
createNode: tandem => new RangeNode( model, sceneModel, {
parentContext: 'accordion',
Expand Down

0 comments on commit 3d970ff

Please sign in to comment.