Skip to content

Event and subclasses in lib.dom.d.ts are missing several standard properties #35634

Closed
@dmzza

Description

@dmzza

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions