TypeScript Version: 3.8.0-dev.20191210
Search Terms:
uievent, MouseEvent, PointerEvent, MSGestureEvent, event.layerX, event.screenX, event.pageX,
Code
// A *self-contained* demonstration of the problem follows...
// Test this by running `tsc` on the command-line, rather than through another build tool such as Gulp, Webpack, etc.
function example1(event: MSGestureEvent) {
const layerPosition = {
x: event.layerX,
y: event.layerY
}
}
function example2(event: Event) {
const layerPosition = {
x: event.layerX,
y: event.layerY
}
}
function example3(event: UIEvent) {
const layerPosition = {
x: event.layerX,
y: event.layerY
}
}
Expected behavior:
It should compile without errors
Actual behavior:
It compiles with these errors:
typescript-event-playground.ts(3,14): error TS2339: Property 'layerX' does not exist on type 'MSGestureEvent'.
typescript-event-playground.ts(4,14): error TS2339: Property 'layerY' does not exist on type 'MSGestureEvent'.
typescript-event-playground.ts(10,14): error TS2339: Property 'layerX' does not exist on type 'Event'.
typescript-event-playground.ts(11,14): error TS2339: Property 'layerY' does not exist on type 'Event'.
typescript-event-playground.ts(17,14): error TS2339: Property 'layerX' does not exist on type 'UIEvent'.
typescript-event-playground.ts(18,14): error TS2339: Property 'layerY' does not exist on type 'UIEvent'.
Playground Link: Provided
Related Issues: None
MDN disagrees that layerX, layerY etc. are "standard prperties" see https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/layerX
And they cannot be found in DOM Spec (https://dom.spec.whatwg.org/) or in UI Events spec (https://www.w3.org/TR/uievents/)
Most likely you'll need to extend standard interfaces with these properties https://github.com/microsoft/TypeScript/wiki/Breaking-Changes#some-vendor-specific-types-are-removed-from-libdts
@IllusionMH Thanks for the explanation and the link to the wiki page. However, that wiki page doesn't actually mention anything about these event properties being removed. I didn't think this was an oversight because the Event class is so important in Javascript, but I was surprised that I couldn't find any documentation or issue acknowledging these missing properties.
As a counter-example, MDN doesn't say MSGestureEvent is on a standards track either, and yet that appears in lib.dom.d.ts: https://github.com/microsoft/TypeScript/blob/master/lib/lib.dom.d.ts#L10041
I'm curious about why some non-standards-track type definitions have been including in the library while others have been excluded.
I would assume that this is due to the fact that they are generated by microsoft/TSJS-lib-generator which in turn uses "JSON webidl file generated by the Microsoft Edge browser".
Therefore you can observe MS specific interfaces which are supported by MS Edge.
Not sure if it's just an oversight or they are left intentionally (e.g. might require more work to exclude them than leave as is).
This issue has been marked as 'Question' and has seen no recent activity. It has been automatically closed for house-keeping purposes. If you're still waiting on a response, questions are usually better suited to stackoverflow.
@RyanCavanaugh This wasn't a question. In my view, this is a problem and I have provided steps to reproduce the problem. Additionally, @IllusionMH acknowledges that the properties I mention are missing, although he argues there is good reason for it.
I respectfully request that you reopen this issue.
I have this problem too.
I am missing the compositionupdate event. Funny enough the corresponding CompositionEvent is in the lib. This seem to be at least inkonsequent. But a lot of specs are "Working Drafts" and work very well.
Either compositionupdate and compositionend are legitimate Dom events and should be in the library. @ts-ignore should not be the solution.
Just for completeness: compositionstart is also being missed (can be found on https://www.w3.org/TR/uievents/).
FYI @RyanCavanaugh.
Composition events are being added via TypeScript-DOM-lib-generator PR #949.