# Importing Babylon classes seperatly causes incompatible types

**URL:** <https://forum.babylonjs.com/t/importing-babylon-classes-seperatly-causes-incompatible-types/12579>\
**Category:** Bugs\
**Created:** [July 17, 2020, 7:30am UTC](https://forum.babylonjs.com/t/importing-babylon-classes-seperatly-causes-incompatible-types/12579 "2020-07-17T07:30:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Browork](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/browork/32/13350_2.png) [@Browork](https://forum.babylonjs.com/u/Browork)\
**Post date:** [July 17, 2020, 7:30am UTC](https://forum.babylonjs.com/t/importing-babylon-classes-seperatly-causes-incompatible-types/12579/1 "2020-07-17T07:30:22Z")

</div>

To take advantage of tree shaking I started to import every class I use seperatly.  
`import { Scene, Engine, ArcRotateCamera, HemisphericLight, StandardMaterial,Material, Vector3, Color3, Color4, Mesh, AbstractMesh, PointerEventTypes, DynamicTexture } from 'babylonjs';`

before I imported it like

```
import * as BABYLON from 'babylonjs';

```

After changing this line I removed every “BABYLON” before any babylon class.  
The code still works, but my IDE is complaining following things:

```
Severity	Code	Description	Project	File	Line	Suppression State
Error	TS2322	(TS) Type 'StandardMaterial' is not assignable to type 'Material'.
  Types of property 'customShaderNameResolve' are incompatible.
    Type '(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: string[] | import("babylonjs/Materials/materialDefines").MaterialDefines, attributes?: string[], options?: import("babylonjs/Materials/material").ICustomShaderNameResolveOptions) => string' is not assignable to type '(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: string[] | BABYLON.MaterialDefines, attributes?: string[], options?: BABYLON.ICustomShaderNameResolveOptions) => string'.
      Types of parameters 'defines' and 'defines' are incompatible.
        Type 'string[] | BABYLON.MaterialDefines' is not assignable to type 'string[] | import("babylonjs/Materials/materialDefines").MaterialDefines'.
          Type 'MaterialDefines' is not assignable to type 'string[] | MaterialDefines'.
            Type 'MaterialDefines' is missing the following properties from type 'string[]': length, pop, push, concat, and 25 more.

```

In this particular example I try to assign the material of a mesh to a pre defined material.

mesh.material = myMaterial:

myMaterial is type of StandardMaterial  
mesh.material is of type Material

 ![grafik](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/5/5d78fb9f5e0b13ad30b2b42ed5a2e73629fd9301.png)  
myMaterial is of type StandardMaterial.

The code works in the browser without problems, but my IDE (Visual Studio 2019) im complaining.

---

<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:** [July 17, 2020, 5:36pm UTC](https://forum.babylonjs.com/t/importing-babylon-classes-seperatly-causes-incompatible-types/12579/2 "2020-07-17T17:36:05Z")

</div>

pinging @sebavan

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [July 17, 2020, 7:22pm UTC](https://forum.babylonjs.com/t/importing-babylon-classes-seperatly-causes-incompatible-types/12579/3 "2020-07-17T19:22:44Z")

</div>

This can only work with our es6 packages e.g. @babylonjs/core and not the former babylonjs.

I can see your imports on babylonjs and not @babylonjs/core in the error.

[ES6 - Babylon.js Documentation](https://doc.babylonjs.com/features/es6_support) migh help.

---

<div class="post-metadata">

**Author:** ![Browork](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/browork/32/13350_2.png) [@Browork](https://forum.babylonjs.com/u/Browork)\
**Post date:** [November 5, 2020, 2:07pm UTC](https://forum.babylonjs.com/t/importing-babylon-classes-seperatly-causes-incompatible-types/12579/4 "2020-11-05T14:07:41Z")

</div>

When importing babylonjs/core I get a prompt for GitHub Login, which I dont’t have. Is a GitHub Account required?

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [November 5, 2020, 2:31pm UTC](https://forum.babylonjs.com/t/importing-babylon-classes-seperatly-causes-incompatible-types/12579/5 "2020-11-05T14:31:12Z")

</div>

nope it is all public on npm: [@babylonjs/core - npm](https://www.npmjs.com/package/@babylonjs/core)
