Closed
Description
Bug Report
π Search Terms
operator cannot be applied enum number comparison
π Version & Regression Information
- This changed between versions 4.9 and 5.0
β― Playground Link
π» Code
const enum Constants {
DefaultName = "foo",
DefaultTimeout = 1000,
MaxItems = 25,
}
declare var someValue: number
if (someValue > Constants.MaxItems) {
someValue = Constants.MaxItems;
}
π Actual behavior
Operator '>' cannot be applied to types 'number' and 'Constants'.(2365)
Removing the string-ish value from Constants
stops the error.
π Expected behavior
No error; even though Constants
shouldn't be comparable thanks to #52048, this seems like it should work because it's only referencing a specific value.
/cc @Andarist @ahejlsberg