@@ -88,7 +88,7 @@ module ts {
88
88
symbolToString : symbolToString ,
89
89
symbolToDisplayParts : symbolToDisplayParts ,
90
90
getAugmentedPropertiesOfApparentType : getAugmentedPropertiesOfApparentType ,
91
- getRootSymbol : getRootSymbol ,
91
+ getRootSymbols : getRootSymbols ,
92
92
getContextualType : getContextualType ,
93
93
getFullyQualifiedName : getFullyQualifiedName ,
94
94
getResolvedSignature : getResolvedSignature ,
@@ -2144,6 +2144,14 @@ module ts {
2144
2144
}
2145
2145
var symbol = < TransientSymbol > createSymbol ( SymbolFlags . UnionProperty | SymbolFlags . Transient , prop . name ) ;
2146
2146
symbol . unionType = type ;
2147
+
2148
+ symbol . declarations = [ ] ;
2149
+ for ( var i = 0 ; i < types . length ; i ++ ) {
2150
+ var s = getPropertyOfType ( types [ i ] , prop . name ) ;
2151
+ if ( s . declarations )
2152
+ symbol . declarations . push . apply ( symbol . declarations , s . declarations ) ;
2153
+ }
2154
+
2147
2155
members [ prop . name ] = symbol ;
2148
2156
} ) ;
2149
2157
var callSignatures = getUnionSignatures ( types , SignatureKind . Call ) ;
@@ -3635,7 +3643,8 @@ module ts {
3635
3643
}
3636
3644
3637
3645
function getBestCommonType ( types : Type [ ] , contextualType : Type ) : Type {
3638
- return contextualType && isSupertypeOfEach ( contextualType , types ) ? contextualType : getUnionType ( types ) ; }
3646
+ return contextualType && isSupertypeOfEach ( contextualType , types ) ? contextualType : getUnionType ( types ) ;
3647
+ }
3639
3648
3640
3649
function isTypeOfObjectLiteral ( type : Type ) : boolean {
3641
3650
return ( type . flags & TypeFlags . Anonymous ) && type . symbol && ( type . symbol . flags & SymbolFlags . ObjectLiteral ) ? true : false ;
@@ -7928,8 +7937,22 @@ module ts {
7928
7937
}
7929
7938
}
7930
7939
7931
- function getRootSymbol ( symbol : Symbol ) {
7932
- return ( ( symbol . flags & SymbolFlags . Transient ) && getSymbolLinks ( symbol ) . target ) || symbol ;
7940
+ function getRootSymbols ( symbol : Symbol ) : Symbol [ ] {
7941
+ if ( symbol . flags & SymbolFlags . UnionProperty ) {
7942
+ var symbols : Symbol [ ] = [ ] ;
7943
+ var name = symbol . name ;
7944
+ forEach ( getSymbolLinks ( symbol ) . unionType . types , t => {
7945
+ symbols . push ( getPropertyOfType ( getApparentType ( t ) , name ) ) ;
7946
+ } ) ;
7947
+ return symbols ;
7948
+ }
7949
+ else if ( symbol . flags & SymbolFlags . Transient ) {
7950
+ var target = getSymbolLinks ( symbol ) . target ;
7951
+ if ( target ) {
7952
+ return [ target ] ;
7953
+ }
7954
+ }
7955
+ return [ symbol ] ;
7933
7956
}
7934
7957
7935
7958
// Emitter support
0 commit comments