# Possible TS definition bug or incorrect use

**URL:** <https://forum.babylonjs.com/t/possible-ts-definition-bug-or-incorrect-use/14552>\
**Category:** Bugs\
**Created:** [September 30, 2020, 4:26pm UTC](https://forum.babylonjs.com/t/possible-ts-definition-bug-or-incorrect-use/14552 "2020-09-30T16:26:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![dbase](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/dbase/32/9431_2.png) [@dbase](https://forum.babylonjs.com/u/dbase)\
**Post date:** [September 30, 2020, 4:26pm UTC](https://forum.babylonjs.com/t/possible-ts-definition-bug-or-incorrect-use/14552/1 "2020-09-30T16:26:50Z")

</div>

I’m having some trouble getting past my linter. I recently forced my project to being more strict _gasps_ which caused one of my Babylon components to screech to a halt. I’m working with StandardMaterial like so:

```auto
const material = new StandardMaterial('AM', this._scene);
material.emissiveColor = Color3.White();
material.roughness = 1;
// Apply different effects based on substrate
switch (type) {
  case Substrate.Canvas:
    material.diffuseTexture = new Texture(url, this._scene);
    material.detailMap.isEnabled = true;
    material.detailMap.texture = new Texture(
      `${this.assetBase}/textures/substrate_canvas.png`, this._scene
    );
    material.detailMap.texture.uScale = 3;
    material.detailMap.texture.vScale = 3;
    material.detailMap.diffuseBlendLevel = 0.4;
    material.detailMap.bumpLevel = 0.5;
    this.disableLighting();
}

```

The code itself works ie. somehow the detailMap gets applied and adjusted (I know this from disabling the linter). It also creates the effect that I want. The code is based on some examples I found. However when I add the linting in, it’s starts complaining:

```auto
TypeError: Cannot set property 'isEnabled' of undefined

```

There’s an 80% chance I’ve done some wildly wrong ie. I suspect detailMap was moved in a release and the doc/example I read is old OR perhaps the type definitions in TS are causing troubles? It’s just strange that my texture does end up being correct.

I’m on BJS 4.1.0

---

<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:** [September 30, 2020, 4:30pm UTC](https://forum.babylonjs.com/t/possible-ts-definition-bug-or-incorrect-use/14552/2 "2020-09-30T16:30:41Z")

</div>

This is because `material.detailMap` is Nullable. so you should use this code:

```auto
material.diffuseTexture = new Texture(url, this._scene);
    material.detailMap!.isEnabled = true;
    material.detailMap!.texture = new Texture(
      `${this.assetBase}/textures/substrate_canvas.png`, this._scene
    );
    material.detailMap!.texture.uScale = 3;
    material.detailMap!.texture.vScale = 3;
    material.detailMap!.diffuseBlendLevel = 0.4;
    material.detailMap!.bumpLevel = 0.5;

```

(note the bangs)

---

<div class="post-metadata">

**Author:** ![dbase](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/dbase/32/9431_2.png) [@dbase](https://forum.babylonjs.com/u/dbase)\
**Post date:** [September 30, 2020, 4:33pm UTC](https://forum.babylonjs.com/t/possible-ts-definition-bug-or-incorrect-use/14552/3 "2020-09-30T16:33:38Z")

</div>

Thanks for the super fast response, I did try that and it still complains.

```auto
Property 'detailMap' does not exist on type 'StandardMaterial'. TS2339

```

Even getting warnings from VSCodium.

---

<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:** [September 30, 2020, 5:08pm UTC](https://forum.babylonjs.com/t/possible-ts-definition-bug-or-incorrect-use/14552/4 "2020-09-30T17:08:58Z")

</div>

well I think you do not have the right d.ts then

---

<div class="post-metadata">

**Author:** ![dbase](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/dbase/32/9431_2.png) [@dbase](https://forum.babylonjs.com/u/dbase)\
**Post date:** [September 30, 2020, 5:52pm UTC](https://forum.babylonjs.com/t/possible-ts-definition-bug-or-incorrect-use/14552/5 "2020-09-30T17:52:49Z")

</div>

I’m just importing Babylon properly as I normally would. Is there something else I should be using? _confused_

I found these types: [@types/babylonjs - npm](https://www.npmjs.com/package/@types/babylonjs) but as the deprecation notice says it should be included in the regular package import.

---

<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:** [September 30, 2020, 6:06pm UTC](https://forum.babylonjs.com/t/possible-ts-definition-bug-or-incorrect-use/14552/6 "2020-09-30T18:06:07Z")

</div>

it is in the package (at least for 4.2) which version are you importing?

---

<div class="post-metadata">

**Author:** ![dbase](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/dbase/32/9431_2.png) [@dbase](https://forum.babylonjs.com/u/dbase)\
**Post date:** [September 30, 2020, 6:10pm UTC](https://forum.babylonjs.com/t/possible-ts-definition-bug-or-incorrect-use/14552/7 "2020-09-30T18:10:33Z")

</div>

I thought 4.1.0 had it, I had to directly install 4.2.0 beta 6 to get the right types. Sigh.

That solved it. Sorry for the silliness. 😛
