Skip to content

Commit

Permalink
convert to TypeScript, #80
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Mar 1, 2023
1 parent 4e41768 commit 3ce0588
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 23 deletions.
22 changes: 12 additions & 10 deletions js/dev/DevGameControls.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// Copyright 2014-2023, University of Colorado Boulder

// @ts-nocheck
/**
* Developer controls for the 'Game' screen. i18n not required.
*
* @author Chris Malley (PixelZoom, Inc.)
*/

import merge from '../../../phet-core/js/merge.js';
import optionize, { EmptySelfOptions } from '../../../phet-core/js/optionize.js';
import PhetFont from '../../../scenery-phet/js/PhetFont.js';
import { HBox } from '../../../scenery/js/imports.js';
import { HBox, HBoxOptions, NodeTranslationOptions } from '../../../scenery/js/imports.js';
import TextPushButton from '../../../sun/js/buttons/TextPushButton.js';
import GameModel from '../game/model/GameModel.js';
import reactantsProductsAndLeftovers from '../reactantsProductsAndLeftovers.js';

// constants
Expand All @@ -20,17 +20,19 @@ const BUTTON_OPTIONS = {
textFill: 'white'
};

type SelfOptions = EmptySelfOptions;

type DevGameControlsOptions = SelfOptions & NodeTranslationOptions;

export default class DevGameControls extends HBox {

/**
* @param {GameModel} model
* @param {Object} [options]
*/
constructor( model, options ) {
public constructor( model: GameModel, providedOptions?: DevGameControlsOptions ) {

const options = optionize<DevGameControlsOptions, SelfOptions, HBoxOptions>()( {

options = merge( {
// HBoxOptions
spacing: 5
}, options );
}, providedOptions );

// replays the current challenge
const replayButton = new TextPushButton( '<', BUTTON_OPTIONS );
Expand Down
17 changes: 4 additions & 13 deletions js/dev/DevStringUtils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2014-2021, University of Colorado Boulder

// @ts-nocheck
/**
* Collection of static string utilities used for development.
* Some of this began its life as toString functions associated with various types.
Expand All @@ -9,17 +8,15 @@
* @author Chris Malley (PixelZoom, Inc.)
*/

import Reaction from '../common/model/Reaction.js';
import reactantsProductsAndLeftovers from '../reactantsProductsAndLeftovers.js';

const DevStringUtils = {

/**
* String representation of a reaction equation, with HTML stripped out.
* @param {Reaction} reaction
* @returns {string}
* @static
*/
equationString: function( reaction ) {
equationString( reaction: Reaction ): string {
let s = '';
// reactants
for ( let i = 0; i < reaction.reactants.length; i++ ) {
Expand All @@ -42,11 +39,8 @@ const DevStringUtils = {
/**
* String representation of quantities for reactants, products and leftovers.
* Example: 4,1 -> 1,2,2,0
* @param {Reaction} reaction
* @returns {string}
* @static
*/
quantitiesString: function( reaction ) {
quantitiesString( reaction: Reaction ): string {
let s = '';
let i = 0;
// reactants
Expand All @@ -72,11 +66,8 @@ const DevStringUtils = {
/**
* String representation of a reaction, including quantities.
* Example: 2H2 + 1O2 -> 2H2O : 2,2 -> 2,0,1
* @param {Reaction} reaction
* @returns {string}
* @static
*/
reactionString: function( reaction ) {
reactionString( reaction: Reaction ): string {
return `${DevStringUtils.equationString( reaction )} : ${DevStringUtils.quantitiesString( reaction )}`;
}
};
Expand Down

0 comments on commit 3ce0588

Please sign in to comment.