enum TokenKind {
LeftBrace,
}
function scan(text: string, pos: number) {
let c = text[pos];
switch (c) {
case '{': return TokenKind.LeftBrace;
case '}': return TokenKind.RightBrace;
}
}
We should have a quick fix for the error message
Property 'RightBrace' does not exist on type 'typeof TokenKind'.
to add RightBrace as a missing enum member. The resulting code should look like
enum TokenKind {
LeftBrace,
RightBrace,
}
function scan(text: string, pos: number) {
let c = text[pos];
switch (c) {
case '{': return TokenKind.LeftBrace;
case '}': return TokenKind.RightBrace;
}
}
One could probably fold in the logic into the existing "add missing member" quick fix, which would be preferable.
"What happens if you have something that's both a class and enum?"
I don't really know. Don't offer the quick fix in that case.
Err, @DanielRosenwasser this already exists, I think. Copy & pasting that sample into the playground does give a quick fix.
Playground Link: Provided
Most helpful comment
Err, @DanielRosenwasser this already exists, I think. Copy & pasting that sample into the playground does give a quick fix.
Playground Link: Provided