Closed
Description
String literals are already valid types now. This is very nice, but I would like the ability to use const enum members to the same effect. They don't change, they take a lot less memory, and they're faster to check. Plus, you have a clearer distinction of what the type is, where strings are pretty free-form at times.
// Now
type NodeType = "start" | "end"; // etc.
interface Node {
type: NodeType;
}
interface StartNode {
type: "start";
}
// What I'd like:
const enum NodeType {
Start,
End,
// etc.
}
interface Node {
type: NodeType;
}
interface StartNode {
type: NodeType.Start;
}