# Typescript and Mesh/AbstractMesh Issue

**URL:** <https://forum.babylonjs.com/t/typescript-and-mesh-abstractmesh-issue/8808>\
**Category:** Bugs\
**Created:** [February 26, 2020, 6:44pm UTC](https://forum.babylonjs.com/t/typescript-and-mesh-abstractmesh-issue/8808 "2020-02-26T18:44:07Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![MugOfPaul](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mugofpaul/32/6688_2.png) [@MugOfPaul](https://forum.babylonjs.com/u/MugOfPaul)\
**Post date:** [February 26, 2020, 6:44pm UTC](https://forum.babylonjs.com/t/typescript-and-mesh-abstractmesh-issue/8808/1 "2020-02-26T18:44:07Z")

</div>

I am using all of the preview packages (4.1.0-rc.5) which are working ok so far. But I have a compile error trying to create an AdvancedDynamicTexture for WebXR UI:

```
const plane = Mesh.CreatePlane('ui', 1, this.scene);
plane.visibility = 0;
plane.position = new Vector3(0, 1, 0);
const advancedTexture = AdvancedDynamicTexture.CreateForMesh(plane);

```

This causes this error:

```
TS2345: Argument of type 'Mesh' is not assignable to parameter of type 'AbstractMesh'.
  Type 'Mesh' is missing the following properties from type 'AbstractMesh': _resyncLighSource, addToSceneRootNodes, removeFromSceneRootNodes
```

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [February 26, 2020, 6:50pm UTC](https://forum.babylonjs.com/t/typescript-and-mesh-abstractmesh-issue/8808/2 "2020-02-26T18:50:17Z")

</div>

Well this is really weird as Mesh inherits from AbstracMesh

Do you have special linting tools or something?

---

<div class="post-metadata">

**Author:** ![MugOfPaul](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mugofpaul/32/6688_2.png) [@MugOfPaul](https://forum.babylonjs.com/u/MugOfPaul)\
**Post date:** [February 26, 2020, 7:10pm UTC](https://forum.babylonjs.com/t/typescript-and-mesh-abstractmesh-issue/8808/3 "2020-02-26T19:10:39Z")

</div>

I am using tslint and tslint-loader via webpack. Trying to explicitly cast gives an error that looks like there’s a conflict with the gui package vs core. So this could DEFINITELY be a configuration issue 😓. Especially given this. (`<deleted>` is just extra long path):

```
Argument of type 'import("<deleted>/node_modules/@babylonjs/core/Meshes/abstractMesh").AbstractMesh' is not assignable to parameter of type 'import("<deleted>/node_modules/@babylonjs/gui/node_modules/@babylonjs/core/Meshes/abstractMesh").AbstractMesh'.
  Type 'AbstractMesh' is missing the following properties from type 'AbstractMesh': _resyncLighSource, addToSceneRootNodes, removeFromSceneRootNodes
```

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [February 26, 2020, 7:11pm UTC](https://forum.babylonjs.com/t/typescript-and-mesh-abstractmesh-issue/8808/4 "2020-02-26T19:11:38Z")

</div>

make sure you are getting all the packages from the same version (including GUI of course)

---

<div class="post-metadata">

**Author:** ![MugOfPaul](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mugofpaul/32/6688_2.png) [@MugOfPaul](https://forum.babylonjs.com/u/MugOfPaul)\
**Post date:** [February 26, 2020, 7:18pm UTC](https://forum.babylonjs.com/t/typescript-and-mesh-abstractmesh-issue/8808/5 "2020-02-26T19:18:08Z")

</div>

> [@MugOfPaul](#):
>
> om type ‘AbstractMesh’: \_resyncLighSource, addToSceneRootNodes, removeFromSceneRootNodes

AHA! It looks like RC 9 snuck up on me. Indeed GUI was newer than the other packages. I am back in business. Thank you @Deltakosh

---

<div class="post-metadata">

**Author:** ![Andrea\_Bisello](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/andrea_bisello/32/26752_2.png) [@Andrea\_Bisello](https://forum.babylonjs.com/u/Andrea_Bisello)\
**Post date:** [September 3, 2022, 9:33pm UTC](https://forum.babylonjs.com/t/typescript-and-mesh-abstractmesh-issue/8808/6 "2022-09-03T21:33:42Z")

</div>

sorry @MugOfPaul , same issue here, two years after.

Following this documentation [Instances | Babylon.js Documentation](https://doc.babylonjs.com/divingDeeper/mesh/copies/instances#how-to-use-instances) i’m doing, in typescript,

i have these imports

`import {Scene, Engine, FreeCamera, HemisphericLight, MeshBuilder, Vector3, StandardMaterial, Texture, SceneLoader, Mesh} from "@babylonjs/core"`

and this code

```auto
    async CreateTrees(howMany=1):Promise<void>{
         const models = await SceneLoader.ImportMeshAsync("", "./models/", "alberino3.glb")
        const meshes = models.meshes
        const theMesh:Mesh = meshes[0]
        theMesh.isVisible = false
        for (let i = 0; i < howMany; i++) {
            const newInstance = theMesh.createInstance("tree-"+i)
            newInstance.position.x = 5 * i
            newInstance.position.y = 0
          }
    }

```

but not working due to the AbrastractMesh class

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/4/9/4901c7480737092d95579316d800e0a8e2074ae1.png)

please can you help me?

thanks

---

<div class="post-metadata">

**Author:** ![Abhishek\_Shakya](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/abhishek_shakya/32/22668_2.png) [@Abhishek\_Shakya](https://forum.babylonjs.com/u/Abhishek_Shakya)\
**Post date:** [September 3, 2022, 10:12pm UTC](https://forum.babylonjs.com/t/typescript-and-mesh-abstractmesh-issue/8808/7 "2022-09-03T22:12:11Z")

</div>

If you want to use AbstractMesh class as mesh you can try

```auto
const theMesh = meshes[0] as Mesh

```

It works for me.

---

<div class="post-metadata">

**Author:** ![Andrea\_Bisello](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/andrea_bisello/32/26752_2.png) [@Andrea\_Bisello](https://forum.babylonjs.com/u/Andrea_Bisello)\
**Post date:** [September 4, 2022, 6:25pm UTC](https://forum.babylonjs.com/t/typescript-and-mesh-abstractmesh-issue/8808/8 "2022-09-04T18:25:47Z")

</div>

Thanks @Abhishek_Shakya  
it works also for me.

i obtain only a object and the console log if filled by

> logger.js?57a9:48 BJS - [20:24:49]: Instances should only be created for meshes with geometry.

but this is another problem 🙂

---

<div class="post-metadata">

**Author:** ![Abhishek\_Shakya](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/abhishek_shakya/32/22668_2.png) [@Abhishek\_Shakya](https://forum.babylonjs.com/u/Abhishek_Shakya)\
**Post date:** [September 4, 2022, 8:00pm UTC](https://forum.babylonjs.com/t/typescript-and-mesh-abstractmesh-issue/8808/9 "2022-09-04T20:00:16Z")

</div>

Cool…
