What I'm trying to do is convert a const object into a class so that I can create readonly properties for example. This to ensure that the values never changes.
In my class I'm trying to create a module property which should be defined, but always empty.
I tried a number of different things:
public modules: Readonly<[]> = []; // Error: A tuple type element list cannot be empty.
public readonly modules: IModule[] = []; // Disallows re-assignment, but still allows things such as push, pop etc.
interface EmptyTuple {
length: 0;
}
// Types of property 'length' are incompatible. Type 'number' is not assignable to type '0'.
public modules: Readonly<EmptyTuple> = [];
The latest one doesn't make any sense since 0 is a number... I really have no idea what I'm doing here really so some guidance would be perfect.
I tried looking at https://github.com/Microsoft/TypeScript/issues/13126 to see if I could find some sort of answer but to no avail.
Does anyone know how to achieve having an empty array that cannot be modified?