I'm still learning various coding styles with regard to Typescript and Angular.
Today I came across this with no comments to the method that was coded.
It appears to me that it is somehow enforcing that the value passed in must be one of the defined values but does not make use of ENUM to enforce it which leads to other issues in a large codebase with no documentation.
Am I correct that this is enforcing the value must be equal to one of the || options?
static getEndpoint = (type: string = 'alpha' || 'bravo' || 'charlie) => {}
To me I would have done something along the lines of and ENUM and
export enum MyTypes {
ALPHA = 'alpha',
BRAVO = 'bravo',
CHARLIE = 'charlie',
}
and then
static getEndpoint = (type: MyTypes = MyTypes.ALPHA) => {}