I am trying to implement a generic discrete interval encoding tree with typescript. Generic here means I want to allow interval endpoints to be arbitrary classes that extends a simple interface specifying discrete linear orders which enforces the existence of two method members next and lessThan. Because I want to type the methods I assume I need a generic interface (all the code can be found in this jsfiddle):
interface DiscreteLinearOrder<T> {
next = () => T;
lessThan = (y: T) => Boolean;
}
Then I instantiated this with number (ok, it is not discrete, but think of it as integers ;-)
class DLOnumber implements DiscreteLinearOrder<number> {
private value: number;
constructor(x: number) { this.value = x; }
next = () => { return(this.value + 1); };
lessThan = (y: number) => { return(this.value < y); };
getValue = () => { return(this.value.toString()); }
}
Up to here it worked, and running things like
const bar = new DLOnumber(5);
worked out.
Having this I planed to provide a class DLOinterval that takes two parameters, one extending the discrete linear order interface:
class DLOinterval<T, U extends DiscreteLinearOrder<T>> {
private start: U;
private end: U;
private data: any;
constructor(s: U, e: U, d: any) {
this.start = s;
this.end = e;
this.data = d;
}
}
But here the troubles are starting: I cannot define a type alias and use it:
type NumberInterval = DLOinterval<number, DLOnumber>;
const ggg = new NumberInterval(new DLOnumber(3),new DLOnumber(5),null)
neither can I instantiate it directly:
const aaa = new DLOinterval<number, DLOnumber>(new DLOnumber(3),new DLOnumber(5),null)
What am I missing here?

type NumberInterval = DLOInterval<number, DLOnumber>;, you are defining a type, not a class constructor, so I don't believe you should be callingnew NumberInterval(...). Also, note that, intype NumberInterval = DLOInterval<number, DLOnumber>;, DLOinterval should use a lowercase 'i' (based on your class constructor).