Let's say I have a class like this
class StaticClass {
static readonly HELLO = 1
static readonly WORLD = 2
}
How can i access the values of the static class as a type such that the result would be as such.
type ValueOfStaticClassMember = 1 | 2;
You can get the type of the
StaticClassobject itself viatypeof StaticClass. Then your task is to remove theprototypeproperty and (I'm guessing) any static methods so we're left only with static properties. You can do that with a mapped type where you map the keyprototypeand any key referring to a function tonever(so it doesn't show up in the resulting type), like this:Playground link
If you do want to include static methods, just remove the second conditional from the key:
Playground link