Skip to content

Commit

Permalink
ts-ignore and "as any" workarounds, #404
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Oct 21, 2021
1 parent a488ed6 commit 6afc279
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 10 deletions.
2 changes: 1 addition & 1 deletion js/common/view/BothHandsPDOMNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class BothHandsPDOMNode extends Node {

// This "object response" is meant to act more like aria-valuetext than a traditional, polite alert. We want
// this to cut off any other alert. This fixes alert-build-up described in https://github.com/phetsims/ratio-and-proportion/issues/214
ariaLivePriority: AriaLiveAnnouncer.AriaLive.ASSERTIVE
ariaLivePriority: ( AriaLiveAnnouncer.AriaLive as any ).ASSERTIVE
}
} );

Expand Down
2 changes: 1 addition & 1 deletion js/common/view/RAPKeyboardHelpContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class RAPKeyboardHelpContent extends TwoColumnKeyboardHelpContent {
sliderString: ratioAndProportionStrings.leftOrRightHand,
maximumString: ratioAndProportionStrings.top,
minimumString: ratioAndProportionStrings.bottom,
arrowKeyIconDisplay: SliderKeyboardHelpSection.ArrowKeyIconDisplay.UP_DOWN // on cue up/down arrows, not left/right also.
arrowKeyIconDisplay: ( SliderKeyboardHelpSection.ArrowKeyIconDisplay as any ).UP_DOWN // on cue up/down arrows, not left/right also.
} );

const generalNavigationHelpSection = new GeneralKeyboardHelpSection( {
Expand Down
2 changes: 1 addition & 1 deletion js/common/view/RAPTickMarkLabelsNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class RAPTickMarkLabelsNode extends Node {
private heightOfText: number | null;
private tickMarkViewProperty: Property<TickMarkViewType>;
private tickMarkRangeProperty: Property<number>;
private colorProperty: Property<Color>;
private colorProperty: Property<Color | string>;

/**
* @param {Property.<TickMarkView>} tickMarkViewProperty
Expand Down
4 changes: 3 additions & 1 deletion js/common/view/RatioHalf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ class RatioHalf extends Rectangle {

// @public {Property.<number>} - Create a mapping directly to just this ratio term value. This is to support
// AccessibleValueHandler, which powers the PDOM interaction off of {Property.<number>}.
// @ts-ignore
const ratioTermSpecificProperty = new DynamicProperty( new Property( this.ratioTupleProperty ), {
bidirectional: true,
reentrant: true,
Expand All @@ -218,7 +219,7 @@ class RatioHalf extends Rectangle {
inverseMap: ( term: number ) => this.ratioTerm === RatioTerm.ANTECEDENT ? this.ratioTupleProperty.value.withAntecedent( term ) :
this.ratioTerm === RatioTerm.CONSEQUENT ? this.ratioTupleProperty.value.withConsequent( term ) :
assert && assert( false, `unexpected ratioTerm ${this.ratioTerm}` )
} );
} ) as Property<number>;

// @private - The draggable element inside the Node framed with thick rectangles on the top and bottom.
this.ratioHandNode = new RatioHandNode( ratioTermSpecificProperty, config.enabledRatioTermsRangeProperty, config.tickMarkViewProperty,
Expand Down Expand Up @@ -339,6 +340,7 @@ class RatioHalf extends Rectangle {
viewSounds.boundarySoundClip.onEndInteraction( positionProperty.value.y );

// Support context response on interaction end from mouse/touch input.
// @ts-ignore
this.ratioHandNode.alertContextResponse();
},

Expand Down
5 changes: 4 additions & 1 deletion js/common/view/RatioHandNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,23 @@ class RatioHandNode extends Node {
isRight: true, // right hand or left hand
asIcon: false, // when true, no input will be attached

ariaOrientation: Orientation.VERTICAL,
ariaOrientation: ( Orientation as any ).VERTICAL,
keyboardStep: keyboardStep,
pageKeyboardStep: 1 / 5,
shiftKeyboardStep: shiftKeyboardStep,

// Because this interaction uses the keyboard, snap to the keyboard step to handle the case where the hands were
// previously moved via mouse/touch. See https://github.com/phetsims/ratio-and-proportion/issues/156
a11yMapValue: ( newValue: number, oldValue: number ) => {

// @ts-ignore
return mapKeyboardInput( newValue, oldValue, this.shiftKeyDown, inProportionProperty.value );
}
}, options );
super();

// Always the same range, always enabled
// @ts-ignore
!options.asIcon && this.initializeAccessibleSlider( valueProperty, enabledRatioTermsRangeProperty, new BooleanProperty( true ), options );

// @private
Expand Down
11 changes: 11 additions & 0 deletions js/common/view/describers/RatioDescriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,27 @@ const RATIO_FITNESS_STRINGS_LOWERCASE = [
];

const NUMBER_TO_WORD = [
// @ts-ignore
sceneryPhetStrings.zero,
// @ts-ignore
sceneryPhetStrings.one,
// @ts-ignore
sceneryPhetStrings.two,
// @ts-ignore
sceneryPhetStrings.three,
// @ts-ignore
sceneryPhetStrings.four,
// @ts-ignore
sceneryPhetStrings.five,
// @ts-ignore
sceneryPhetStrings.six,
// @ts-ignore
sceneryPhetStrings.seven,
// @ts-ignore
sceneryPhetStrings.eight,
// @ts-ignore
sceneryPhetStrings.nine,
// @ts-ignore
sceneryPhetStrings.ten
];

Expand Down
2 changes: 1 addition & 1 deletion js/create/view/CreateScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import CreateScreenSummaryNode from './CreateScreenSummaryNode.js';
import MyChallengeAccordionBox from './MyChallengeAccordionBox.js';
import TickMarkRangeComboBoxNode from './TickMarkRangeComboBoxNode.js';
import RAPModel from '../../common/model/RAPModel.js';
import Bounds2 from '../../../../dot/js/Bounds2';
import Bounds2 from '../../../../dot/js/Bounds2.js';


class CreateScreenView extends RAPScreenView {
Expand Down
6 changes: 3 additions & 3 deletions js/discover/view/ChallengeRatioComboBoxNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,17 @@ class ChallengeRatioComboBoxNode extends Node {
tagName: 'h3'
} );
this.comboBox = new ComboBox( [
new ChallengeComboBoxItem( this.ratioToChallengeNameMap.get( 1 / 2 ).capitalized, RAPColors.discoverChallenge1Property.value, 1 / 2, targetRatioProperty, colorProperty, {
new ChallengeComboBoxItem( ( this.ratioToChallengeNameMap.get( 1 / 2 ) as any ).capitalized, RAPColors.discoverChallenge1Property.value, 1 / 2, targetRatioProperty, colorProperty, {
soundPlayer: soundGenerators[ 0 ],
a11yLabel: ratioAndProportionStrings.challenge1,
tandemName: 'challenge1Item'
} ),
new ChallengeComboBoxItem( this.ratioToChallengeNameMap.get( 1 / 3 ).capitalized, RAPColors.discoverChallenge2Property.value, 1 / 3, targetRatioProperty, colorProperty, {
new ChallengeComboBoxItem( ( this.ratioToChallengeNameMap.get( 1 / 3 ) as any ).capitalized, RAPColors.discoverChallenge2Property.value, 1 / 3, targetRatioProperty, colorProperty, {
soundPlayer: soundGenerators[ 1 ],
a11yLabel: ratioAndProportionStrings.challenge2,
tandemName: 'challenge2Item'
} ),
new ChallengeComboBoxItem( this.ratioToChallengeNameMap.get( 3 / 4 ).capitalized, RAPColors.discoverChallenge3Property.value, 3 / 4, targetRatioProperty, colorProperty, {
new ChallengeComboBoxItem( ( this.ratioToChallengeNameMap.get( 3 / 4 ) as any ).capitalized, RAPColors.discoverChallenge3Property.value, 3 / 4, targetRatioProperty, colorProperty, {
soundPlayer: soundGenerators[ 2 ],
a11yLabel: ratioAndProportionStrings.challenge3,
tandemName: 'challenge3Item'
Expand Down
2 changes: 1 addition & 1 deletion js/discover/view/DiscoverScreenSummaryNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class DiscoverScreenSummaryNode extends Node {
], ( currentTargetRatio: number, tickMarkView: TickMarkViewType, currentTuple: RAPRatioTuple ) => {
stateOfSimNode.innerContent = StringUtils.fillIn( ratioAndProportionStrings.a11y.discover.screenSummary.qualitativeStateOfSim, {
ratioFitness: ratioDescriber.getRatioFitness( false ), // lowercase
currentChallenge: ratioToChallengeNameMap.get( currentTargetRatio ).lowercase,
currentChallenge: ( ratioToChallengeNameMap.get( currentTargetRatio ) as any ).lowercase,
distance: handPositionsDescriber.getDistanceRegion( true )
} );
leftHandBullet.innerContent = StringUtils.fillIn( ratioAndProportionStrings.a11y.leftHandBullet, {
Expand Down

0 comments on commit 6afc279

Please sign in to comment.