I am using Typescript and I am trying to add a variable to another library (Babylonjs). I know in javascript I could freely just add any variable to an object and it would let me do it. Typescript is notifying me that that I can't. Part of the joy I suppose that it notifies you, but in this case I want to do it.
For example:
var mesh = BABYLON.Mesh('name', scene);
mesh.myVariable = 'tada!';
Now myVariable is not part of BabylonJS Mesh class. How can I add a typedef file to say, sure it is. (I will be sure to check every time I access myVariable that it has been set)
I have tried:
declare module BABYLON{
export interface Mesh {
myVariable : any;
}
}
and typescript is being kind in letting me know Duplicate identifier 'Mesh'. In the Babylon typedef file, Mesh is declared as:
declare module BABYLON {
class Mesh extends AbstractMesh implements IGetSetVerticesData {
...
}
}