swc/crates/swc_ecma_parser/tests/tsc/enumConstantMembers.ts
2022-02-04 17:08:38 +09:00

40 lines
559 B
TypeScript

// Constant members allow negatives, but not decimals. Also hex literals are allowed
enum E1 {
a = 1,
b
}
enum E2 {
a = - 1,
b
}
enum E3 {
a = 0.1,
b // Error because 0.1 is not a constant
}
declare enum E4 {
a = 1,
b = -1,
c = 0.1 // Not a constant
}
enum E5 {
a = 1 / 0,
b = 2 / 0.0,
c = 1.0 / 0.0,
d = 0.0 / 0.0,
e = NaN,
f = Infinity,
g = -Infinity
}
const enum E6 {
a = 1 / 0,
b = 2 / 0.0,
c = 1.0 / 0.0,
d = 0.0 / 0.0,
e = NaN,
f = Infinity,
g = -Infinity
}