# ReflectionProbe.renderList.add() using ES6/Typescript

**URL:** <https://forum.babylonjs.com/t/reflectionprobe-renderlist-add-using-es6-typescript/14701>\
**Category:** Questions\
**Created:** [October 6, 2020, 4:41am UTC](https://forum.babylonjs.com/t/reflectionprobe-renderlist-add-using-es6-typescript/14701 "2020-10-06T04:41:41Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![rdurnin](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/rdurnin/32/11381_2.png) [@rdurnin](https://forum.babylonjs.com/u/rdurnin)\
**Post date:** [October 6, 2020, 4:41am UTC](https://forum.babylonjs.com/t/reflectionprobe-renderlist-add-using-es6-typescript/14701/1 "2020-10-06T04:41:41Z")

</div>

Hey guys, and I am looking through an example which uses the ReflectionProbe as follows:

var attachReflectionProbe = function (scene, root, others) {  
var probe = new BABYLON.ReflectionProbe(root+“ReflectionProbe”, 128, scene, true);  
for (var index = 0; index \< others.length; index++) {  
probe.renderList.push(others[index]);  
};  
root.material.reflectionTexture = probe.cubeTexture;  
root.material.disableLighting = true;  
probe.attachToMesh(root);  
}

For use with typescript and ES6 I have converted the code to the following:

attachReflectionProbe (scene:Scene, root: Mesh, others: Mesh) {  
var probe = new ReflectionProbe(root+“ReflectionProbe”, 128, scene, true);  
for (var index = 0; index \< others.length; index++) {  
// The following line throws errors on compile  
probe.renderList.push(others[index]);  
};  
(root.material as StandardMaterial).reflectionTexture = probe.cubeTexture;  
(root.material as StandardMaterial).disableLighting = true;  
probe.attachToMesh(root);  
}

I am using strict checking and it throws the following error:  
// The line number associated with the error is commented above  
TS2531: Object is possibly ‘null’.

How can I access the list to add new meshes to it? It looks like the renderList parameter is read-only, and the RenderTargetTexture which hosts the value on ReflectionProbe is also inaccessible.

Thanks for any help,  
r

---

<div class="post-metadata">

**Author:** ![rdurnin](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/rdurnin/32/11381_2.png) [@rdurnin](https://forum.babylonjs.com/u/rdurnin)\
**Post date:** [October 6, 2020, 4:58am UTC](https://forum.babylonjs.com/t/reflectionprobe-renderlist-add-using-es6-typescript/14701/2 "2020-10-06T04:58:48Z")

</div>

A simple check for the object seems to have solved the problem.

if (probe.renderList) {  
// put in work  
}

r

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [October 6, 2020, 9:22am UTC](https://forum.babylonjs.com/t/reflectionprobe-renderlist-add-using-es6-typescript/14701/3 "2020-10-06T09:22:24Z")

</div>

Strange, it works here without checking first:

> **[Babylon.js Playground](https://playground.babylonjs.com/#R9MJ6W)**

`renderList` is not declared as nullable…

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [October 6, 2020, 9:34am UTC](https://forum.babylonjs.com/t/reflectionprobe-renderlist-add-using-es6-typescript/14701/4 "2020-10-06T09:34:35Z")

</div>

The getter signature is:

```javascript
public get renderList(): Nullable<AbstractMesh[]>

```

Mainly because the RenderTargetTexture is Nullable as well. checking that it is not null is the safest way to go here 🙂

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [October 6, 2020, 9:38am UTC](https://forum.babylonjs.com/t/reflectionprobe-renderlist-add-using-es6-typescript/14701/5 "2020-10-06T09:38:40Z")

</div>

Ah, strange (bis), the PG does not show it’s nullable:

![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/2/28ec636ff2cb31621d94d5b3dbd916b64bd76b0d.png)

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [October 6, 2020, 10:08am UTC](https://forum.babylonjs.com/t/reflectionprobe-renderlist-add-using-es6-typescript/14701/6 "2020-10-06T10:08:19Z")

</div>

Interesting!

This is from the latest babylon.d.ts:

![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/c/ccca2add39cda995f46d526ec72dc9ad73268728.png)

Need to see why it does that

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [October 6, 2020, 10:26am UTC](https://forum.babylonjs.com/t/reflectionprobe-renderlist-add-using-es6-typescript/14701/7 "2020-10-06T10:26:03Z")

</div>

it seems Nullable is completely ignored on the playground. For example:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/f/f2df7cafbb2ae431dd7ccbd0367f2323f1a4d2b8.png)

Which should return Nullable

Before digging in - anyone has an idea why it happens?

---

<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:** [October 6, 2020, 3:52pm UTC](https://forum.babylonjs.com/t/reflectionprobe-renderlist-add-using-es6-typescript/14701/8 "2020-10-06T15:52:57Z")

</div>

no idea…

---

<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:** [October 7, 2020, 12:36pm UTC](https://forum.babylonjs.com/t/reflectionprobe-renderlist-add-using-es6-typescript/14701/9 "2020-10-07T12:36:04Z")

</div>

strictNullCheck might not be turned on ??? just an idea though 🙂
