Skip to content

Commit

Permalink
document my ts-expect-errors, see phetsims/chipper#1366
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegreenberg committed Dec 8, 2022
1 parent 0ec50a0 commit 9913535
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion js/quadrilateral-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ simLauncher.launch( () => {
const sim = new Sim( quadrilateralTitleStringProperty, [ quadrilateralScreen ], simOptions );
sim.start();

// @ts-expect-error
// @ts-expect-error - navigator.vibrate isn't available yet in TypeScript's native types (experimental technology)
if ( QuadrilateralQueryParameters.showInitialTouchDialog && window.navigator.vibrate ) {

// Put up a dialog that will essentially force the user to interact with the sim, thus enabling haptics right away.
Expand Down
25 changes: 14 additions & 11 deletions js/quadrilateral/view/QuadrilateralBluetoothConnectionButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,54 +149,57 @@ class QuadrilateralBluetoothConnectionButton extends TextPushButton {

/**
* Respond to a characteristicvaluechanged event.
* TODO: Implement this function. This is the main event we get when we receive new data from the device.
*
* NOTE: ts-expect-errors are reasonable for this "experimental" web technology. event.target.value is defined for
* the `characteristicvaluechanged` event of the Web Bluetooth API. I believe the type of target is
* https://developer.mozilla.org/en-US/docs/Web/API/BluetoothRemoteGATTCharacteristic, but haven't tested in a while.
*/
private handleCharacteristicValueChanged( event: Event ): void {
if ( event.target ) {
// @ts-expect-error
// @ts-expect-error - See note at handleCharacteristicValueChanged() about this.
console.log( '1: ', event.target.value.getFloat32( 0, true ) );

// @ts-expect-error
// @ts-expect-error - See note at handleCharacteristicValueChanged() about this.
this.topLength = event.target.value.getFloat32( 0, true );
}
}

private handleCharacteristicValue2Changed( event: Event ): void {
if ( event.target ) {
// @ts-expect-error
// @ts-expect-error - See note at handleCharacteristicValueChanged() about this.
console.log( '2: ', event.target.value.getFloat32( 0, true ) );

// @ts-expect-error
// @ts-expect-error - See note at handleCharacteristicValueChanged() about this.
this.rightLength = event.target.value.getFloat32( 0, true );
}
}

private handleCharacteristicValue3Changed( event: Event ): void {
if ( event.target ) {
// @ts-expect-error
// @ts-expect-error - See note at handleCharacteristicValueChanged() about this.
console.log( '3: ', event.target.value.getFloat32( 0, true ) );

// @ts-expect-error
// @ts-expect-error - See note at handleCharacteristicValueChanged() about this.
this.leftLength = event.target.value.getFloat32( 0, true );
}
}

private handleCharacteristicValue4Changed( event: Event ): void {
if ( event.target ) {
// @ts-expect-error
// @ts-expect-error - See note at handleCharacteristicValueChanged() about this.
console.log( '4: ', event.target.value.getFloat32( 0, true ) );

// @ts-expect-error
// @ts-expect-error - See note at handleCharacteristicValueChanged() about this.
this.topLeftAngle = event.target.value.getFloat32( 0, true );
}
}

private handleCharacteristicValue5Changed( event: Event ): void {
if ( event.target ) {
// @ts-expect-error
// @ts-expect-error - See note at handleCharacteristicValueChanged() about this.
console.log( '5: ', event.target.value.getFloat32( 0, true ) );

// @ts-expect-error
// @ts-expect-error - See note at handleCharacteristicValueChanged() about this.
this.topRightAngle = event.target.value.getFloat32( 0, true );

// signify that it is time to update the simulation
Expand Down

0 comments on commit 9913535

Please sign in to comment.