Created
January 10, 2019 22:08
-
-
Save jdpigeon/95ded0fd60df2f527e93a9f8ed76f0b4 to your computer and use it in GitHub Desktop.
Typescript Class Enum Pattern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type BothOptions = 'raw_emg'; | |
class Both { | |
public static RawEMG: Both = new Both('raw_emg'); | |
private value: BothOptions; | |
private constructor(value: BothOptions) { | |
this.value = value; | |
} | |
public rawValue(): BothOptions { | |
return this.value; | |
} | |
public targetName(): string { | |
return this.value + "_target"; | |
} | |
public batchTypeName(): string { | |
return this.value + "_batch"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment