(member, autoValue)
| 84686 | } |
| 84687 | } |
| 84688 | function computeMemberValue(member, autoValue) { |
| 84689 | if (ts.isComputedNonLiteralName(member.name)) { |
| 84690 | error(member.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); |
| 84691 | } |
| 84692 | else { |
| 84693 | var text = ts.getTextOfPropertyName(member.name); |
| 84694 | if (ts.isNumericLiteralName(text) && !ts.isInfinityOrNaNString(text)) { |
| 84695 | error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); |
| 84696 | } |
| 84697 | } |
| 84698 | if (member.initializer) { |
| 84699 | return computeConstantValue(member); |
| 84700 | } |
| 84701 | // In ambient non-const numeric enum declarations, enum members without initializers are |
| 84702 | // considered computed members (as opposed to having auto-incremented values). |
| 84703 | if (member.parent.flags & 16777216 /* NodeFlags.Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* EnumKind.Numeric */) { |
| 84704 | return undefined; |
| 84705 | } |
| 84706 | // If the member declaration specifies no value, the member is considered a constant enum member. |
| 84707 | // If the member is the first member in the enum declaration, it is assigned the value zero. |
| 84708 | // Otherwise, it is assigned the value of the immediately preceding member plus one, and an error |
| 84709 | // occurs if the immediately preceding member is not a constant enum member. |
| 84710 | if (autoValue !== undefined) { |
| 84711 | return autoValue; |
| 84712 | } |
| 84713 | error(member.name, ts.Diagnostics.Enum_member_must_have_initializer); |
| 84714 | return undefined; |
| 84715 | } |
| 84716 | function computeConstantValue(member) { |
| 84717 | var enumKind = getEnumKind(getSymbolOfNode(member.parent)); |
| 84718 | var isConstEnum = ts.isEnumConst(member.parent); |
no test coverage detected
searching dependent graphs…