Skip to content

Commit

Permalink
add explicity type for CreateEquationNodeFunction, #80
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Mar 2, 2023
1 parent 6c938e5 commit 8f9dc43
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions js/molecules/view/MoleculesScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@
import Dimension2 from '../../../../dot/js/Dimension2.js';
import { combineOptions } from '../../../../phet-core/js/optionize.js';
import Tandem from '../../../../tandem/js/Tandem.js';
import Reaction from '../../common/model/Reaction.js';
import RPALConstants from '../../common/RPALConstants.js';
import BeforeAfterNode, { BeforeAfterNodeOptions } from '../../common/view/BeforeAfterNode.js';
import MoleculesEquationNode from '../../common/view/MoleculesEquationNode.js';
import RPALScreenView, { CreateBeforeAfterNodeFunction } from '../../common/view/RPALScreenView.js';
import reactantsProductsAndLeftovers from '../../reactantsProductsAndLeftovers.js';
import MoleculesModel from '../model/MoleculesModel.js';
import { CreateEquationNodeFunction } from '../../common/view/ReactionBarNode.js';

export default class MoleculesScreenView extends RPALScreenView {

public constructor( model: MoleculesModel, tandem: Tandem ) {

// Creates an equation for a specified reaction.
const createEquationNode = ( reaction: Reaction ) => new MoleculesEquationNode( reaction );
const createEquationNode: CreateEquationNodeFunction = reaction => new MoleculesEquationNode( reaction );

// Creates the Before/After interface for a specified reaction.
const createBeforeAfterNode: CreateBeforeAfterNodeFunction =
Expand Down
8 changes: 4 additions & 4 deletions js/sandwiches/view/SandwichesScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import ReactantsProductsAndLeftoversStrings from '../../ReactantsProductsAndLeft
import SandwichesModel from '../model/SandwichesModel.js';
import SandwichesEquationNode from './SandwichesEquationNode.js';
import SandwichNode from './SandwichNode.js';
import SandwichRecipe from '../model/SandwichRecipe.js';
import { combineOptions } from '../../../../phet-core/js/optionize.js';
import { CreateEquationNodeFunction } from '../../common/view/ReactionBarNode.js';

export default class SandwichesScreenView extends RPALScreenView {

Expand All @@ -29,7 +29,9 @@ export default class SandwichesScreenView extends RPALScreenView {
const maxSandwichSize = new Dimension2( maxSandwich.width, maxSandwich.height );

// Creates an equation for a specified reaction.
const createEquationNode = ( reaction: SandwichRecipe ) => new SandwichesEquationNode( reaction, maxSandwichSize );
//TODO https://github.com/phetsims/reactants-products-and-leftovers/issues/80 TS2345: Argument of type 'Reaction' is not assignable to parameter of type 'SandwichRecipe'.
// @ts-expect-error
const createEquationNode: CreateEquationNodeFunction = reaction => new SandwichesEquationNode( reaction, maxSandwichSize );

// Creates the Before/After interface for a specified reaction.
const createBeforeAfterNode: CreateBeforeAfterNodeFunction =
Expand All @@ -44,8 +46,6 @@ export default class SandwichesScreenView extends RPALScreenView {
boxYMargin: 8 // large enough to accommodate the biggest sandwich
}, options ) );

//TODO https://github.com/phetsims/reactants-products-and-leftovers/issues/80 createEquationNode argument
// @ts-expect-error
super( model, createEquationNode, createBeforeAfterNode, tandem );
}
}
Expand Down

0 comments on commit 8f9dc43

Please sign in to comment.