-1

Execution of code is not giving any error. But VSCode is giving this error. Saying property 'maxPointers' does not exist on type 'HammerInput'. Though it exists when I see in console. But how to remove this bug?

1 Answer 1

0

Like it says, it's a TS Lint issue. It is shown because the type of variable eve isn't explicit.

Option 1

One way to workaround it is to use bracket notation instead of dot notation to access the maxPointers property

mc.on('some event', (eve) => {
  if(eve['maxPointers'] === 1) {
    console.log('maxp');
  }
});

Option 2

Another workaround would be to define the variable eve as type any

mc.on('some event', (eve: any) => { // <-- `any` type
  if(eve.maxPointers === 1) {
    console.log('maxp');
  }
});
0

Not the answer you're looking for? Browse other questions tagged or ask your own question.