Babylon Types and NodeNext imports

I’m not yet positive this is a Babylon.js issue, but I’m having trouble pinpointing root cause. The issue seems to be that when tsconfig.json specifies moduleResolution of “NodeNext” / “Node16”, the Babylon.js types do not all work correctly. Minimally, there seems to be issues with any class that extends another class. For some reason, TypeScript loses the parent type information.

This commit triggers the issue, where the only thing that is changed is the moduleResolution setting:

This code will not compile due to TypeScript saying that Engine does not have runRenderLoop method (which should come from the parent ThinEngine type). Switch modeResolution back to “Node”, and everything is fine. I added some comments to show the issue more clearly. The same issue exists for things like AssetManager extending AbstractScene. i.e. The fields from AbstractScene are no longer available for anything of type AssetManager.

I’m checking to see if this is known issue before I dig much more. I don’t think this is specific to recent Babylon.js versions, but I’m not yet 100% sure.

cc @RaananW

i’ll have to check that and get back to you!

Yep, our types are not ready for nodeNext!
I will need to add extensions to imports in the generated declaration files.

I’ll add a task to do that, thanks for reporting

[Build] Support module resolution node16 and nodeNext · Issue #13797 · BabylonJS/Babylon.js (github.com)

1 Like