PointerInfo returning IMouseEvent instead of IPointerEvent


Currently I am upgrading a project from version 4.2 to latest version (5.17 at this moment).
I am noticing a mismatch between type definition that wasn’t happening on 4.2 version.

I am using a PointerInfo object to get info related to which resource did the user used (mouse, touch, pen). We have different approaches depending upon the action. Below is just a simplified function to show here the situation happens

// simplified code
function example(pointerInfo: PointerInfo) {
    if (pointerInfo.event.pointerType !== 'touch') {

On version 4.2, that works properly (even thought it has a incorrectly inference to type any).

At the latest version, I receive this compilation error:

Property ‘pointerType’ does not exist on type ‘IMouseEvent’.

On latest version, event is a IMouseEvent:

But as it is a PointerEvent it should be IPointerEvent.

It is also stated on the class description about its purpose

Native friendly interface for PointerEvent Object

Also, as some answers from the forum, it is the proper way to get the type of the pointer, like this answer: Is there any way to know whether an onPointerObservable is touch input or mouse input?

cc @PolygonalSun

So originally this change was made because how both PointerEvent and WheelEvent both inherit from MouseEvent, rather than WheelEvent inheriting from PointerEvent. This is important because PointerInfo handled both pointer input and wheel input. That being said, it might be good look into possibly changing it to treat its event something like event: IPointerEvent | IWheelEvent and using context to narrow it down. Lemme look into this and I’ll get back to you.

1 Like

I’m still looking at this but, in the meantime, you should be able to cast the event inside of the pointerInfo to IPointerEvent to get access to the pointerId.

1 Like

At the version 4.2, it indeed was being handled as IPointerEvent | IWheelEvent, but for some reason that I didn’t investigate, event was being inferred as any.