How to add a Type to a Class in Javascript?

I’m creating a generic class to work with my other classes. This Class takes a Type of T

public class Heap<T> {

T[] items;


I don’t know how to write this in Javascript. Its the “public class Heap {” line that throws an error.
In javascript I have.

public class Heap {

var items :  T[];


Anyone have an Idea of what I can do?

I’m not seeing evidence that you can declare a class with a type parametric in Unity’s dialect of JavaScript. You can use them.

There are dozens, perhaps hundreds, of of examples of using a generic class in a JavaScript class. However, I can’t find any examples of how you might define one.

Maybe the assumption was that people wanting to use parametric polymorphism would want a big boy language anyway? :wink:

I don’t know. I would just define the class using C#. If you need it to work in non-Unity JavaScript, use Bridge.NET to generate the JavaScript.