Argument of type 'import("babylonjs/Meshes/abstractMesh").AbstractMesh' Error

Hello fellow devs,

I am getting an error with the latest Alpha (v21) when trying to add the loadedmeshes from the asset manager to an empty Babylon.Mesh instance. Here is the error I get:

Type 'import("babylonjs/Animations/animationGroup").AnimationGroup[]' is not assignable to type 'BABYLON.AnimationGroup[]'.
Type 'import("babylonjs/Animations/animationGroup").AnimationGroup' is not assignable to type 'BABYLON.AnimationGroup'.
Types have separate declarations of a private property '_scene'. [2322]

Argument of type 'import("babylonjs/Meshes/abstractMesh").AbstractMesh' is not assignable to parameter of type 'BABYLON.AbstractMesh'.
Types of property 'edgesRenderer' are incompatible.
Type 'import("babylonjs/Rendering/edgesRenderer").EdgesRenderer' is not assignable to type 'BABYLON.EdgesRenderer'.
Property '_source' is protected but type 'EdgesRenderer' is not a class derived from 'EdgesRenderer'. ts(2345)

Wondering what the issue could be?

Would be amazing if we could see your code or project. At a first glance you are mixing the use of imports and namespace use ?

No it was working fine until v15. This is a recent development after my update to v21. Hence the question. My current import is

import * as BABYLON from 'babylonjs';

Just pinging @bghgary to see if he may have an idea because this may have come after the commit to add loadedAnimationGroups to the meshassettask in the assets manager. Sorry if my guess is wrong here. Just trying to make a sense of this error. Happens when I do something like

this.player.PlayerAnimGroups = (task as BABYLON.MeshAssetTask).loadedAnimationGroups;

(task as BABYLON.MeshAssetTask).loadedMeshes.forEach((mesh)=>{
                this.player.PlayerMesh.addChild(mesh);
}

The issue is definitely related to the move to modules.

I tried the following :

var task = new BABYLON.MeshAssetTask("", β€œβ€, β€œβ€, β€œβ€);

var PlayerAnimGroups = (task as BABYLON.MeshAssetTask).loadedAnimationGroups;

(task as BABYLON.MeshAssetTask).loadedMeshes.forEach((mesh)=>{
sphere.addChild(mesh);
});

on alpha 21 and it compiles ok. The problem lies down in some typings conflicts and this would be hard to troubleshoot without knowing a bit more about your code. It definitely looks like some parts of the codes relies on the BABYLON (internal namespace typings) and other on the module typings resulting of the import.

1 Like

Ok that’s really strange. Thanks @sebavan I will try and fix this at my end. Will keep you posted

And you are bang on @sebavan! Feeling so stupid :frowning:

The import line in the player script fixed the problem :slight_smile:

Thank you so much for the help!

1 Like