Problem with typescript and overlap

So I have been learning phaser with typescript for the last few days and I found somewhat of a problem when it comes to typescript and overlap.

Basically I am making a very simple space-invaders clone and I have some type problems in my code that i cannot solve. I am able to run the project and if i use any as a type vs code will let it slide and not note it as an error. Nonetheless I want to try to make this project ad correct as I possibly can so I can learn as much as possible from it.

In my project I have this 3 custom objects:
Bullet of type Phaser.GameObject.Image.
Player of type Phaser.GameObject.Image.
Enemy of type Phaser.GameObject.Image.

And I am trying to check for overlap of bullets with either the player or some enemy. Both the player and every enemy have a variable bullets of type Phaser.GameObjects.Group made of Bullets.

As you can see the functions are giving an error due to the type of objects I pass in the overlap method as object1 and object2 and the types I give in the callback function (ex: this.bulletHitPlayer).

This is the error I get for this.bulletHitEnemy:

This is the error I get for this.bulletHitPlayer

This is the error I get for this.enemyInteractions:

Am I doing something wrong or is this just the way things are?

I think this is the way things are, but try

private bulletHitEnemy = (bullet, enemy): void => {
  (enemy as Enemy).hurt();

Actually, I think your overlap callback args need to be (player, bullet) and (enemy, bullet), although that’s not related to the TypeScript error.

using the as keyword seems to have solved it, thank you