Closed
Description
TypeScript Version: 2.8.0
Search Terms:
string literal enum
Code
const enum TypeOfValue
{
Boolean = 'boolean',
Number = 'number',
String = 'string',
Symbol = 'symbol',
Object = 'object',
Undefined = 'undefined',
Function = 'function'
}
if(typeof x==TypeOfValue.String) {
// Type guard fails for string.
}
Expected behavior:
The code in the within the if block should understand that x is a string.
Actual behavior:
The if block is unaware of the type.