@@ -154,6 +154,7 @@ module ts {
154
154
TypeLiteral ,
155
155
ArrayType ,
156
156
TupleType ,
157
+ UnionType ,
157
158
// Expression
158
159
ArrayLiteral ,
159
160
ObjectLiteral ,
@@ -224,7 +225,7 @@ module ts {
224
225
FirstFutureReservedWord = ImplementsKeyword ,
225
226
LastFutureReservedWord = YieldKeyword ,
226
227
FirstTypeNode = TypeReference ,
227
- LastTypeNode = TupleType ,
228
+ LastTypeNode = UnionType ,
228
229
FirstPunctuation = OpenBraceToken ,
229
230
LastPunctuation = CaretEqualsToken ,
230
231
FirstToken = EndOfFileToken ,
@@ -337,6 +338,10 @@ module ts {
337
338
elementTypes : NodeArray < TypeNode > ;
338
339
}
339
340
341
+ export interface UnionTypeNode extends TypeNode {
342
+ types : NodeArray < TypeNode > ;
343
+ }
344
+
340
345
export interface StringLiteralTypeNode extends TypeNode {
341
346
text : string ;
342
347
}
@@ -648,7 +653,7 @@ module ts {
648
653
writeSymbol ( symbol : Symbol , writer : SymbolWriter , enclosingDeclaration ?: Node , meaning ?: SymbolFlags , flags ?: SymbolFormatFlags ) : void ;
649
654
getFullyQualifiedName ( symbol : Symbol ) : string ;
650
655
getAugmentedPropertiesOfApparentType ( type : Type ) : Symbol [ ] ;
651
- getRootSymbol ( symbol : Symbol ) : Symbol ;
656
+ getRootSymbols ( symbol : Symbol ) : Symbol [ ] ;
652
657
getContextualType ( node : Node ) : Type ;
653
658
getResolvedSignature ( node : CallExpression , candidatesOutArray ?: Signature [ ] ) : Signature ;
654
659
getSignatureFromDeclaration ( declaration : SignatureDeclaration ) : Signature ;
@@ -757,19 +762,22 @@ module ts {
757
762
ConstructSignature = 0x00010000 , // Construct signature
758
763
IndexSignature = 0x00020000 , // Index signature
759
764
TypeParameter = 0x00040000 , // Type parameter
765
+ UnionProperty = 0x00080000 , // Property in union type
760
766
761
767
// Export markers (see comment in declareModuleMember in binder)
762
- ExportValue = 0x00080000 , // Exported value marker
763
- ExportType = 0x00100000 , // Exported type marker
764
- ExportNamespace = 0x00200000 , // Exported namespace marker
765
-
766
- Import = 0x00400000 , // Import
767
- Instantiated = 0x00800000 , // Instantiated symbol
768
- Merged = 0x01000000 , // Merged symbol (created during program binding)
769
- Transient = 0x02000000 , // Transient symbol (created during type check)
770
- Prototype = 0x04000000 , // Symbol for the prototype property (without source code representation)
771
-
772
- Value = Variable | Property | EnumMember | Function | Class | Enum | ValueModule | Method | GetAccessor | SetAccessor ,
768
+ ExportValue = 0x00100000 , // Exported value marker
769
+ ExportType = 0x00200000 , // Exported type marker
770
+ ExportNamespace = 0x00400000 , // Exported namespace marker
771
+
772
+ Import = 0x00800000 , // Import
773
+ Instantiated = 0x01000000 , // Instantiated symbol
774
+ Merged = 0x02000000 , // Merged symbol (created during program binding)
775
+ Transient = 0x04000000 , // Transient symbol (created during type check)
776
+ Prototype = 0x08000000 , // Prototype property (no source representation)
777
+ Undefined = 0x10000000 , // Symbol for the undefined
778
+
779
+ Value = Variable | Property | EnumMember | Function | Class | Enum | ValueModule | Method | GetAccessor | SetAccessor | UnionProperty ,
780
+
773
781
Type = Class | Interface | Enum | TypeLiteral | ObjectLiteral | TypeParameter ,
774
782
Namespace = ValueModule | NamespaceModule ,
775
783
Module = ValueModule | NamespaceModule ,
@@ -827,6 +835,7 @@ module ts {
827
835
mapper ?: TypeMapper ; // Type mapper for instantiation alias
828
836
referenced ?: boolean ; // True if alias symbol has been referenced as a value
829
837
exportAssignSymbol ?: Symbol ; // Symbol exported from external module
838
+ unionType ?: UnionType ; // Containing union type for union property
830
839
}
831
840
832
841
export interface TransientSymbol extends Symbol , SymbolLinks { }
@@ -849,14 +858,15 @@ module ts {
849
858
}
850
859
851
860
export interface NodeLinks {
852
- resolvedType ?: Type ; // Cached type of type node
853
- resolvedSignature ?: Signature ; // Cached signature of signature node or call expression
854
- resolvedSymbol ?: Symbol ; // Cached name resolution result
855
- flags ?: NodeCheckFlags ; // Set of flags specific to Node
856
- enumMemberValue ?: number ; // Constant value of enum member
861
+ resolvedType ?: Type ; // Cached type of type node
862
+ resolvedSignature ?: Signature ; // Cached signature of signature node or call expression
863
+ resolvedSymbol ?: Symbol ; // Cached name resolution result
864
+ flags ?: NodeCheckFlags ; // Set of flags specific to Node
865
+ enumMemberValue ?: number ; // Constant value of enum member
857
866
isIllegalTypeReferenceInConstraint ?: boolean ; // Is type reference in constraint refers to the type parameter from the same list
858
- isVisible ?: boolean ; // Is this node visible
859
- localModuleName ?: string ; // Local name for module instance
867
+ isVisible ?: boolean ; // Is this node visible
868
+ localModuleName ?: string ; // Local name for module instance
869
+ assignmentChecks ?: Map < boolean > ; // Cache of assignment checks
860
870
}
861
871
862
872
export enum TypeFlags {
@@ -874,13 +884,14 @@ module ts {
874
884
Interface = 0x00000800 , // Interface
875
885
Reference = 0x00001000 , // Generic type reference
876
886
Tuple = 0x00002000 , // Tuple
877
- Anonymous = 0x00004000 , // Anonymous
878
- FromSignature = 0x00008000 , // Created for signature assignment check
887
+ Union = 0x00004000 , // Union
888
+ Anonymous = 0x00008000 , // Anonymous
889
+ FromSignature = 0x00010000 , // Created for signature assignment check
879
890
880
- Intrinsic = Any | String | Number | Boolean | Void | Undefined | Null ,
891
+ Intrinsic = Any | String | Number | Boolean | Void | Undefined | Null ,
881
892
StringLike = String | StringLiteral ,
882
893
NumberLike = Number | Enum ,
883
- ObjectType = Class | Interface | Reference | Tuple | Anonymous
894
+ ObjectType = Class | Interface | Reference | Tuple | Union | Anonymous ,
884
895
}
885
896
886
897
// Properties common to all types
@@ -938,6 +949,10 @@ module ts {
938
949
baseArrayType : TypeReference ; // Array<T> where T is best common type of element types
939
950
}
940
951
952
+ export interface UnionType extends ObjectType {
953
+ types : Type [ ] ; // Constituent types
954
+ }
955
+
941
956
// Resolved object type
942
957
export interface ResolvedObjectType extends ObjectType {
943
958
members : SymbolTable ; // Properties by name
@@ -970,6 +985,7 @@ module ts {
970
985
hasStringLiterals : boolean ; // True if specialized
971
986
target ?: Signature ; // Instantiation target
972
987
mapper ?: TypeMapper ; // Instantiation mapper
988
+ unionSignatures ?: Signature [ ] ; // Underlying signatures of a union signature
973
989
erasedSignatureCache ?: Signature ; // Erased version of signature (deferred)
974
990
isolatedSignatureType ?: ObjectType ; // A manufactured type that just contains the signature for purposes of signature comparison
975
991
}
@@ -984,9 +1000,10 @@ module ts {
984
1000
}
985
1001
986
1002
export interface InferenceContext {
987
- typeParameters : TypeParameter [ ] ;
988
- inferences : Type [ ] [ ] ;
989
- inferredTypes : Type [ ] ;
1003
+ typeParameters : TypeParameter [ ] ; // Type parameters for which inferences are made
1004
+ inferenceCount : number ; // Incremented for every inference made (whether new or not)
1005
+ inferences : Type [ ] [ ] ; // Inferences made for each type parameter
1006
+ inferredTypes : Type [ ] ; // Inferred type for each type parameter
990
1007
}
991
1008
992
1009
export interface DiagnosticMessage {
0 commit comments