[sensors] Undefined values makes GS a pain to work with using TypeScript

kenchris has just created a new issue for https://github.com/w3c/sensors:

== Undefined values makes GS a pain to work with using TypeScript ==
As values like x, y, z, xBias, yBias, zBias can be undefined, TypeScript will complain and complain unless you check for undefined in all methods using any of these. Speaking from experience, that is very painful, and given the polularity of TS, it would be nice if we could find a better solution, like giving them default values and *one* property to check whether the values are set or not.

Like

```
gyro.onreading = () => {
  let value = gyro.x; // its in onreading, so will be valid.

  if (accel.valid) { // Accelerometer values might not be valid;
    let otherValue = accel.x;
    ...
  }
  ...
}
```

Please view or discuss this issue at https://github.com/w3c/sensors/issues/269 using your GitHub account

Received on Monday, 18 September 2017 10:16:47 UTC