Property 'animations' does not exist on type 'Rectangle'

Many GUI examples are using the Rectangle class and adding an animation to them, e.g

I’m wondering how come I’m getting the error Property 'animations' does not exist on type 'Rectangle'

Is it possible because I’m importing the library this way? (I was previously getting the problem with BABYLON.GUI not being found)

import { AssetsManager, Color3, CubeTexture, ... } from "babylonjs";
import { AdvancedDynamicTexture, Rectangle } from 'babylonjs-gui';

You’re not crazy, the property doesn’t exist on the Rectangle… not without a small intervention on your part.

Add a new array to the rectangle named animations and then see if the example works in your code:

myRectangle.animations = [];
1 Like

Hmmm, that’s exactly what I have. I copied the code directly from the example:

rect1.animations = [];

EDIT: elsewhere I’m also getting similar errors using GUI classes, e.g

TS2339: Property 'parseFromSnippetAsync' does not exist on type 'AdvancedDynamicTexture'.
TS2339: Property 'text' does not exist on type 'Control'.

resolve with

rect1['animations'] = [];

1 Like

IMHO @jelster has provided the solution. If you are on TypeScript in your project that changes the situation a bit. So you have to:


1 Like

Are you on BJ 4.2.1?


is available in BJS5+ only.

1 Like

@roland many thanks for the confirmation

1 Like

@echan00 Thank you for marking my response as a solution however I still believe @jelster deserves the solution tag :slight_smile: Let’s be fair with him! If he decides otherwise you can change it to the more elaborated version provided by me. Thank you!

1 Like

I added the tag to @jelster for the moment :slight_smile:

1 Like