melonJS icon indicating copy to clipboard operation
melonJS copied to clipboard

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

Open brunofunnie opened this issue 1 year ago • 3 comments

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/

brunofunnie avatar Aug 08 '23 11:08 brunofunnie

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.

obiot avatar Aug 08 '23 11:08 obiot

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 avatar Nov 02 '23 19:11 muyaszed

Do I need to commit the updated Doc as well?

muyaszed avatar Nov 02 '23 22:11 muyaszed

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!

daniel-centore avatar Mar 20 '24 01:03 daniel-centore

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 avatar Mar 20 '24 03:03 obiot

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 avatar Mar 24 '24 09:03 obiot

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

obiot avatar Mar 29 '24 00:03 obiot

closing this one, working on my side.

obiot avatar Apr 14 '24 01:04 obiot