@@ -2551,7 +2551,7 @@ namespace ts {
25512551 isUnknownSymbol ( symbol : Symbol ) : boolean ;
25522552 /* @internal */ getMergedSymbol ( symbol : Symbol ) : Symbol ;
25532553
2554- getConstantValue ( node : EnumMember | PropertyAccessExpression | ElementAccessExpression ) : number | undefined ;
2554+ getConstantValue ( node : EnumMember | PropertyAccessExpression | ElementAccessExpression ) : string | number | undefined ;
25552555 isValidPropertyAccess ( node : PropertyAccessExpression | QualifiedName , propertyName : string ) : boolean ;
25562556 /** Follow all aliases to get the original symbol. */
25572557 getAliasedSymbol ( symbol : Symbol ) : Symbol ;
@@ -2776,7 +2776,7 @@ namespace ts {
27762776 isSymbolAccessible ( symbol : Symbol , enclosingDeclaration : Node , meaning : SymbolFlags , shouldComputeAliasToMarkVisible : boolean ) : SymbolAccessibilityResult ;
27772777 isEntityNameVisible ( entityName : EntityNameOrEntityNameExpression , enclosingDeclaration : Node ) : SymbolVisibilityResult ;
27782778 // Returns the constant value this property access resolves to, or 'undefined' for a non-constant
2779- getConstantValue ( node : EnumMember | PropertyAccessExpression | ElementAccessExpression ) : number ;
2779+ getConstantValue ( node : EnumMember | PropertyAccessExpression | ElementAccessExpression ) : string | number ;
27802780 getReferencedValueDeclaration ( reference : Identifier ) : Declaration ;
27812781 getTypeReferenceSerializationKind ( typeName : EntityName , location ?: Node ) : TypeReferenceSerializationKind ;
27822782 isOptionalParameter ( node : ParameterDeclaration ) : boolean ;
@@ -2914,6 +2914,13 @@ namespace ts {
29142914 isDeclarationWithCollidingName ?: boolean ; // True if symbol is block scoped redeclaration
29152915 bindingElement ?: BindingElement ; // Binding element associated with property symbol
29162916 exportsSomeValue ?: boolean ; // True if module exports some value (not just types)
2917+ enumKind ?: EnumKind ; // Enum declaration classification
2918+ }
2919+
2920+ /* @internal */
2921+ export const enum EnumKind {
2922+ Numeric , // Numeric enum (each member has a TypeFlags.Enum type)
2923+ Literal // Literal enum (each member has a TypeFlags.EnumLiteral type)
29172924 }
29182925
29192926 /* @internal */
@@ -2986,7 +2993,7 @@ namespace ts {
29862993 resolvedSymbol ?: Symbol ; // Cached name resolution result
29872994 resolvedIndexInfo ?: IndexInfo ; // Cached indexing info resolution result
29882995 maybeTypePredicate ?: boolean ; // Cached check whether call expression might reference a type predicate
2989- enumMemberValue ?: number ; // Constant value of enum member
2996+ enumMemberValue ?: string | number ; // Constant value of enum member
29902997 isVisible ?: boolean ; // Is this node visible
29912998 containsArgumentsReference ?: boolean ; // Whether a function-like declaration contains an 'arguments' reference
29922999 hasReportedStatementInAmbientContext ?: boolean ; // Cache boolean if we report statements in ambient context
@@ -3006,7 +3013,7 @@ namespace ts {
30063013 StringLiteral = 1 << 5 ,
30073014 NumberLiteral = 1 << 6 ,
30083015 BooleanLiteral = 1 << 7 ,
3009- EnumLiteral = 1 << 8 ,
3016+ EnumLiteral = 1 << 8 , // Always combined with StringLiteral, NumberLiteral, or Union
30103017 ESSymbol = 1 << 9 , // Type of symbol primitive introduced in ES6
30113018 Void = 1 << 10 ,
30123019 Undefined = 1 << 11 ,
@@ -3032,17 +3039,17 @@ namespace ts {
30323039
30333040 /* @internal */
30343041 Nullable = Undefined | Null ,
3035- Literal = StringLiteral | NumberLiteral | BooleanLiteral | EnumLiteral ,
3042+ Literal = StringLiteral | NumberLiteral | BooleanLiteral ,
30363043 StringOrNumberLiteral = StringLiteral | NumberLiteral ,
30373044 /* @internal */
30383045 DefinitelyFalsy = StringLiteral | NumberLiteral | BooleanLiteral | Void | Undefined | Null ,
30393046 PossiblyFalsy = DefinitelyFalsy | String | Number | Boolean ,
30403047 /* @internal */
30413048 Intrinsic = Any | String | Number | Boolean | BooleanLiteral | ESSymbol | Void | Undefined | Null | Never | NonPrimitive ,
30423049 /* @internal */
3043- Primitive = String | Number | Boolean | Enum | ESSymbol | Void | Undefined | Null | Literal ,
3050+ Primitive = String | Number | Boolean | Enum | EnumLiteral | ESSymbol | Void | Undefined | Null | Literal ,
30443051 StringLike = String | StringLiteral | Index ,
3045- NumberLike = Number | NumberLiteral | Enum | EnumLiteral ,
3052+ NumberLike = Number | NumberLiteral | Enum ,
30463053 BooleanLike = Boolean | BooleanLiteral ,
30473054 EnumLike = Enum | EnumLiteral ,
30483055 UnionOrIntersection = Union | Intersection ,
@@ -3081,19 +3088,21 @@ namespace ts {
30813088 // String literal types (TypeFlags.StringLiteral)
30823089 // Numeric literal types (TypeFlags.NumberLiteral)
30833090 export interface LiteralType extends Type {
3084- text : string ; // Text of literal
3091+ value : string | number ; // Value of literal
30853092 freshType ?: LiteralType ; // Fresh version of type
30863093 regularType ?: LiteralType ; // Regular version of type
30873094 }
30883095
3089- // Enum types (TypeFlags.Enum)
3090- export interface EnumType extends Type {
3091- memberTypes : EnumLiteralType [ ] ;
3096+ export interface StringLiteralType extends LiteralType {
3097+ value : string ;
30923098 }
30933099
3094- // Enum types (TypeFlags.EnumLiteral)
3095- export interface EnumLiteralType extends LiteralType {
3096- baseType : EnumType & UnionType ; // Base enum type
3100+ export interface NumberLiteralType extends LiteralType {
3101+ value : number ;
3102+ }
3103+
3104+ // Enum types (TypeFlags.Enum)
3105+ export interface EnumType extends Type {
30973106 }
30983107
30993108 export const enum ObjectFlags {
@@ -3961,7 +3970,7 @@ namespace ts {
39613970 commentRange ?: TextRange ; // The text range to use when emitting leading or trailing comments
39623971 sourceMapRange ?: TextRange ; // The text range to use when emitting leading or trailing source mappings
39633972 tokenSourceMapRanges ?: TextRange [ ] ; // The text range to use when emitting source mappings for tokens
3964- constantValue ?: number ; // The constant value of an expression
3973+ constantValue ?: string | number ; // The constant value of an expression
39653974 externalHelpersModuleName ?: Identifier ; // The local name for an imported helpers module
39663975 helpers ?: EmitHelper [ ] ; // Emit helpers for the node
39673976 }
0 commit comments