An instantiable type is a type that the end-user can create objects from. This includes:
- all branded andflavoured types
- all classes that aren't base classes
For example:
For example:
// `ValueObject` is a base class.
class ValueObject<T> {
protected value T;
protected constructor(input: T) {
this.value = T;
}
public valueOf(): T {
return this.value;
}
}
// the end-user can't create new objects of type `ValueObject`
// they cannot instantiate this type
const myValue1 = new ValueObject("not allowed!");
// `MediaType` is a child class
class MediaType extends ValueObject<string> {
public constructor(input: string) {
mustBeMediaTypeData(input);
super(input);
}
}
// the end-user can create new objects of type `MediaType`
// they CAN instantiate this type
const myValue2 = new MediaType("text/html; charset=UTF-8");