DeviceMotionEvent and DeviceOrientationEvent has lost static function signature requestPermission
See original GitHub issue(I was referred to this repo by Typescripts main repo issue template)
DeviceMotionEvent and DeviceOrientationEvent has lost static function signature requestPermission
in Typescript 4.4
I believe that it should be added back?
Configuration Check
My compilation target is esnext
and my lib is lib.dom.d.ts
.
Missing / Incorrect Definition
In 4.4.x (and latest nightly build) DeviceMotionEvent and DeviceOrientationEvent has lost its static function signature for requestPermission. This function should be called to trigger permission dialog to collect motion/gyro events. I believe it’s still spec and at least it has to be called in practice. This commit removed definitions in lib.dom.d.ts https://github.com/microsoft/TypeScript/commit/9d443b76aac0832d7f3c890441264d39307fe31a#diff-796971dc74a3f3cd77ca0a3a776d6fe27ab224cd501d9652dbeffcf45ba0f058L4376
Sample Code
DeviceMotionEvent.requestPermission()
DeviceOrientationEvent.requestPermissions()
The change/regression(?) can be tested here by toggling between versions 4.4 and 4.3
Documentation Link
https://www.w3.org/TR/orientation-event/#deviceorientation https://www.w3.org/TR/orientation-event/#devicemotionevent
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (4 by maintainers)
Top GitHub Comments
Ok, i opened this issue believing this was a mistake so i won’t argue. Leaving the following information here for anyone coming from Google:
It’s not possible to get global inference for
requestPermission
back, the event constructors does not have explicit types to extend. However, adding the following in the file which contains the function invocation currently works.And if it’s true, please file an issue from this page, it will be helpful!: https://developer.mozilla.org/en-US/docs/Web/API/DeviceMotionEvent#browser_compatibility