melonjs / melonJS

a fresh, modern & lightweight HTML5 game engine
https://melonjs.org
MIT License
5.77k stars 641 forks source link

this.body is pointing to Dom type when using Typescript Boilerplate #1199

Closed brunofunnie closed 2 months ago

brunofunnie commented 11 months ago

I notice that when using the Typescript boilerplate and when setting a new Body it refers to the DOM instead of MelonJS.

The code: image

On VSCODE shows: image

Typescript reference of Body: image

Using a just cloned Typescript Boilerplate and following the https://codemonkey.club/getting-started-with-melonjs/

obiot commented 11 months ago

thank you very much for the report, we will look into it.

We are still in the process of providing proper typings for melonJS, please do share if you find any other issues. In the mean time, you can use @ts-ignore to remove the warning/error report in VSC.

muyaszed commented 8 months ago

I have a fix for this, just need the suitable replacement name for Body class. Atm I'm using BodyObject for it. the Method will still be using body

muyaszed commented 8 months ago

Do I need to commit the updated Doc as well?

daniel-centore commented 3 months ago

For now I'm working around this with:

import { Body } from "melonjs";

const body = this.body as unknown as Body;
//  use `body` wherever needed

Would be great to get a real fix for it!

obiot commented 3 months ago

me too It has been bothering me, but I really don't know how to fix it properly (I mean without renaming the object!)

obiot commented 3 months ago

This one should be fixed now, I just simply "tricked" it by importing Body within the Renderable class (together with referencing the Body class, so that the bundler doesnt complain).

I found out another issue is that rollup does not always respect the right module order in the bundle if I add import/reference for Application. Another issue, but at least the Body one should be resolved now.

I will leave this one open until the next 17.1 version is released and the fix confirmed to work.

obiot commented 3 months ago

17.1.0 released, if you guys could confirm it's now correct from your side as well, thanks !

obiot commented 2 months ago

closing this one, working on my side.